This is the levels documentation.
Just win the current level.
If you can't because you've destroyed a key/red key/sword that you needed, then do a suicide (there is for now no live count nor an other way to win in these condition).
If you can't win the current level because it is too hard, see How to play a particular level? to play the next one and restart the game.
To do that, you'll need the level number. It is simply the number of level there is before plus one (meaning the first level is the level 1). Warning: this is NOT the level ID.
Then, in level.lua@line357, there should be this line:
self.__level_number = 1If it is not this exact line, starting with two tabs, search around in the file.
Replace the 1 by the level number, then start the game.
If you want to submit a level, please put the code in add_contrib_nontest_levels in contribution.lua@line1 for a real level or in add_contrib_test_levels in contribution.lua@line13 for a test level (meaning, a level used for debugging purposes).
Please note that you can also call the addTestLevelInstance or addLevelInstance.
It takes in a level instance. It is designed to allow to add instances of subclasses of the Level class (created by instanciating a newly created subclass)
If you want to create a level, here's what to do:
It is planned to do a level editor, but there are none for now, sorry.
The current way to add a level is by using a level name and a big table and passing it to the level_manager:addLevel function.
To create a level, you need eight informations:
- The level table version. Currently, there are two. The last one (version 2) is described here.
- The level configuration. (You might not want to create a game configuration and use the
currentConfig:getLevelConfig()level configuration.) Goes into IDlevel_conf(optional). - The starting room. This is where you start. Goes into ID
starting_room. - The column count. It determines how many rooms per line there is. Goes into ID
column_count. - The level datas. Goes into ID
rooms_datas. It is a table made of:- A first line from
-[column count - 1]to0made of empty tables. These are internal rooms, but are (usually) never displayed nor accessible (as it otherwise crash the game). - A multiple of column count tables, which constitute the level itself. Each table can be empty, or contains the following:
- the exit:
exit: boolean (in that casetrue)dir_exit: string (up,down,left,right)
- a door: (needs and destroy a
key)door: boolean (in that casetrue)dir_door: string (up,down,left,right)
- a red door: (needs and destroy a
redkey)reddoor: boolean (in that casetrue)dir_reddoor: string (up,down,left,right)
up: boolean (can we go in that direction?)down: boolean (can we go in that direction?)left: boolean (can we go in that direction?)right: boolean (can we go in that direction?)monster: boolean (is there a monster in that room?)sword: boolean (is there a sword in that room?)key: boolean (is there a key in that room?)redkey: boolean (is there aredbloody key on that room?)trap: boolean (is this room a trap <=> instanteaneous death) (note that it is planned to have other types of traps)- a grave: It is a special case. A "grave" is a room, called
graveorig(set totrue) that leads to the left room, which is agraveroom.graveorig: boolean (is this the grave origin <=> right)grave: boolean (this is the grave destination <=> left)deadlygrave: boolean (is the grave a trap?)- (Optional)
keyneeded: ifdeadlygraveis set, this string gives the needed key (keyorredkey) to exit the grave - (Optional)
exitdir: ifdeadlygraveis set, this string gives the direction of the grave's exit
- (Optional)
- the exit:
- Then finally an empty line (of size of the number of columns) of empty tables.
- A first line from
- The map availability when you've finished the level. It is a function that takes in whether you're dead and what objects do you have and must return a boolean value (
truemeans you unlocked the full map). Goes into IDmap_reveal. - The level winning when you finish the level alive. It is a function that takes in what objects do you have and must return a boolean value (note that if you're dead, you cannot win) (
truemeans you win). Goes into IDwin_level. - Lores, texts that are at the beginning and the end of the level. It is a function that inputs whether you're dead and what objects you have and outputs a table with the
stateID is the key (mainly,deathorvictory) and thealtID is the alternative of the ending lore. Goes into IDalternative_lore. Lores are loaded from the level langs dictionaries.lld.
To test the level, you can either run it from the interactive mode (see INTERACTING.md#misc) or run it by putting the level as the last instruction of the add_contrib_levels in contribution.lua using the level registering template wrote in the very beginning of that function.