Test Interface

From Hero of Allacrost Wiki
Revision as of 08:30, 9 August 2015 by Roots (talk | contribs) (Added explanation of accessing the test menu, useful page for both developers and game designers)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Allacrost uses a test interface to allow developers and designers quick and easy access to any content in the game. The test interface is meant to be used to test the various game modes (map, battle, menu, shop, etc). It is not used for testing of the game engine (except through its use in the game modes) nor the map editor. The test interface itself is a type of game mode (TestMode) that implements a GUI menu. The test menu displays the categories of tests, what tests are available, and a short description of what each test covers. Selecting a test will immediately load the necessary content and change the game state to that mode.

Accessing the Test Menu[edit]

There are a few different ways to get to the test menu.

  • When starting the application, supply either the "-t" or "--test" option to the command line (ex. ./allacrost --test)

This will skip the normal boot sequence and place the user directly in the test menu.

  • While in the title screen (BootMode), press "Ctrl+T"

This will terminate the BootMode instance, and the only way to return to it and completely exit from the test interface is to hit the quit command (ESC or Ctrl+Q) and select "Return to Main Menu".

  • If TestMode was used as an entry point to the current mode of play, pressing Ctrl+T will terminate all other game modes and return the user to the test menu.

This is detected by analyzing the game stack for an instance of TestMode, and if found all game modes above it are deleted. If it is not found in the game stack, the Ctrl+T command will do nothing. Once the test interface is activated, the only way to deactivate it completely is to select "Return to Main Menu" from the quit menu.

Note that in official releases of the game, the test interface will be disabled. Development releases and the latest repository code should not have this limitation.

Writing Tests[edit]

Writing your own tests is extremely easy to do and done in Lua. Tests are organized based on the game mode that they test and are all found in the directory lua/test/. Adding a new test should be self-explanatory after opening the corresponding file. You can take a look at how existing tests for the mode are structured and make modifications to add your own test.

There are a few things that most tests will have in common.

  • Characters - define which playable characters and in the player's party
  • Inventory - define what items, equipment, drunes (currency), and other objects are in the party's inventory
  • Global Events - define what global game events have transpired

Naturally, specific modes will have their own set of requirements.

  • MapMode tests need to know which map script file to load.
  • BattleMode tests need to have a list of enemies that face the character party.
  • ShopMode tests need to have a list of the objects and stock that they have available for the player to buy.

Test Interface Code[edit]

If you're interested in further development and enhancement of the test interface, you can build upon the existing code found in these locations.

  • lua/test/ contains both the test definitions as well as the file test_main.lua, which defines the categories and organizations of these tests.
  • src/modes/test.* implements TestMode and the GUI interface for the test menu
  • src/engine/input.* there's a small amount of processing in the input engine specific to TestMode, mostly related to processing the Ctrl+T key command