Module ...
Represent a game A module should subclass it and initialize anything it needs to play inside
Functions
_M:cancelCoroutine (id) | Ask a registered coroutine to cancel The coroutine must accept a "cancel" action |
_M:checkResolutionChange (w, h, ow, oh) | Checks if we must reload to change resolution |
_M:commandLineArgs (args) | The C core gives us command line arguments |
_M:defaultMouseCursor () | Default mouse cursor |
_M:defaultSavedFields (t) | Defines the default fields to be saved by the savefile code |
_M:display (nb_keyframes) | Displays the screen Called by the engine core to redraw the screen every frame |
_M:getCoroutine (id) | Get the coroutine corresponding to the id |
_M:getPlayer (main) | Returns the player Reimplement it in your module, this can just return nil if you dont want/need the engine adjusting stuff to the player or if you have many players or whatever |
_M:getSaveDescription () | Called by savefile code to describe the current game |
_M:handleProfileEvent (evt) | Receives a profile event Usualy this just transfers it to the PlayerProfile class but you can overload it to handle special stuff |
_M:hasDialogUp () | Do we have a dialog running |
_M:init (keyhandler) | Constructor Sets up the default keyhandler. |
_M:isLoadable () | Says if this savefile is usable or not Reimplement it in your module, returning false when the player is dead |
_M:isTainted () | Checks if the current character is "tainted" by cheating |
_M:joinThreads (timeout) | Try to join all registered threads |
_M:leaveLevel (level, lev, old_lev) | Called when a zone leaves a level Going from "old_lev" to "lev", leaving level "level" |
_M:onQuit () | Called by the engine when the user tries to close the window |
_M:onResolutionChange () | Called when screen resolution changes |
_M:onTickEnd (f, name) | Register things to do on tick end |
_M:onTickEndExecute () | Run all registered tick end functions Usualy jsut let the engine call it |
_M:onWindowMoved (x, y) | Called when the game window is moved around |
_M:prerun () | Do not touch |
_M:registerCoroutine (id, co) | Add a coroutine to the pool Coroutines registered will be run each game tick |
_M:registerDialog (d) | Registers a dialog to display |
_M:registerDialogAt (d, pos) | Registers a dialog to display somewher in the stack |
_M:registerHighscore () | Saves the highscore of the current char |
_M:registerPersistentHook (hook, fct) | Register a hook that will be saved in the savefile Obviously only run it once per hook per save |
_M:registerThread (th, linda) | Save a thread into the thread pool Threads will be auto joined when the module exits or when it can ALL THREADS registered *MUST* return true when they exit |
_M:replaceDialog (src, dest) | Replaces a dialog to display with an other |
_M:run () | Starts the game Modules should reimplement it to do whatever their game needs |
_M:saveGame () | Requests the game to save |
_M:saveScreenshot (for_savefile) | Take a screenshot of the game |
_M:saveSettings (file, data) | Save a settings file |
_M:saveVersion (token) | Gets/increment the savefile version |
_M:setCurrent () | Tells the game engine to play this game |
_M:setFlyingText (fl) | Sets up a text flyers |
_M:setGamma (gamma) | Sets the gamma of the window By default it uses SDL gamma settings, but it can also use a fullscreen shader if available |
_M:setLevel (level) | Sets the current level |
_M:setPlayerName (name) | Sets the player name |
_M:setResolution (res, force) | Change screen resolution |
_M:takeScreenshot (for_savefile) | Take a screenshot of the game |
_M:tick () | This is the "main game loop", do something here |
_M:unregisterDialog (d) | Undisplay a dialog, removing its own keyhandler if needed |
Functions
- _M:cancelCoroutine (id)
-
Ask a registered coroutine to cancel The coroutine must accept a "cancel" action
Parameters
- id:
- _M:checkResolutionChange (w, h, ow, oh)
-
Checks if we must reload to change resolution
Parameters
- w:
- h:
- ow:
- oh:
- _M:commandLineArgs (args)
-
The C core gives us command line arguments
Parameters
- args:
- _M:defaultMouseCursor ()
- Default mouse cursor
- _M:defaultSavedFields (t)
-
Defines the default fields to be saved by the savefile code
Parameters
- t:
- _M:display (nb_keyframes)
-
Displays the screen Called by the engine core to redraw the screen every frame
Parameters
- nb_keyframes: The number of elapsed keyframes since last draw (this can be 0). This is set by the engine
- _M:getCoroutine (id)
-
Get the coroutine corresponding to the id
Parameters
- id:
- _M:getPlayer (main)
-
Returns the player Reimplement it in your module, this can just return nil if you dont want/need the engine adjusting stuff to the player or if you have many players or whatever
Parameters
- main: if true the game should try to return the "main" player, if any
- _M:getSaveDescription ()
- Called by savefile code to describe the current game
- _M:handleProfileEvent (evt)
-
Receives a profile event Usualy this just transfers it to the PlayerProfile class but you can overload it to handle special stuff
Parameters
- evt:
- _M:hasDialogUp ()
- Do we have a dialog running
- _M:init (keyhandler)
-
Constructor Sets up the default keyhandler. Also requests the display size and stores it in "w" and "h" properties
Parameters
- keyhandler:
- _M:isLoadable ()
- Says if this savefile is usable or not Reimplement it in your module, returning false when the player is dead
- _M:isTainted ()
- Checks if the current character is "tainted" by cheating
- _M:joinThreads (timeout)
-
Try to join all registered threads
Parameters
- timeout: the time in seconds to wait for each thread
- _M:leaveLevel (level, lev, old_lev)
-
Called when a zone leaves a level Going from "old_lev" to "lev", leaving level "level"
Parameters
- level:
- lev:
- old_lev:
- _M:onQuit ()
- Called by the engine when the user tries to close the window
- _M:onResolutionChange ()
- Called when screen resolution changes
- _M:onTickEnd (f, name)
-
Register things to do on tick end
Parameters
- f:
- name:
- _M:onTickEndExecute ()
- Run all registered tick end functions Usualy jsut let the engine call it
- _M:onWindowMoved (x, y)
-
Called when the game window is moved around
Parameters
- x:
- y:
- _M:prerun ()
- Do not touch
- _M:registerCoroutine (id, co)
-
Add a coroutine to the pool Coroutines registered will be run each game tick
Parameters
- id:
- co:
- _M:registerDialog (d)
-
Registers a dialog to display
Parameters
- d:
- _M:registerDialogAt (d, pos)
-
Registers a dialog to display somewher in the stack
Parameters
- d: the dialog
- pos: the stack position (1=top, 2=second, ...)
- _M:registerHighscore ()
- Saves the highscore of the current char
- _M:registerPersistentHook (hook, fct)
-
Register a hook that will be saved in the savefile Obviously only run it once per hook per save
Parameters
- hook:
- fct:
- _M:registerThread (th, linda)
-
Save a thread into the thread pool Threads will be auto joined when the module exits or when it can ALL THREADS registered *MUST* return true when they exit
Parameters
- th:
- linda:
- _M:replaceDialog (src, dest)
-
Replaces a dialog to display with an other
Parameters
- src:
- dest:
- _M:run ()
- Starts the game Modules should reimplement it to do whatever their game needs
- _M:saveGame ()
- Requests the game to save
- _M:saveScreenshot (for_savefile)
-
Take a screenshot of the game
Parameters
- for_savefile: The screenshot will be used for savefile display
- _M:saveSettings (file, data)
-
Save a settings file
Parameters
- file:
- data:
- _M:saveVersion (token)
-
Gets/increment the savefile version
Parameters
- token: if "new" this will create a new allowed save token and return it. Otherwise this checks the token against the allowed ones and returns true if it is allowed
- _M:setCurrent ()
- Tells the game engine to play this game
- _M:setFlyingText (fl)
-
Sets up a text flyers
Parameters
- fl:
- _M:setGamma (gamma)
-
Sets the gamma of the window By default it uses SDL gamma settings, but it can also use a fullscreen shader if available
Parameters
- gamma:
- _M:setLevel (level)
-
Sets the current level
Parameters
- level: an engine.Level (or subclass) object
- _M:setPlayerName (name)
-
Sets the player name
Parameters
- name:
- _M:setResolution (res, force)
-
Change screen resolution
Parameters
- res:
- force:
- _M:takeScreenshot (for_savefile)
-
Take a screenshot of the game
Parameters
- for_savefile: The screenshot will be used for savefile display
- _M:tick ()
- This is the "main game loop", do something here
- _M:unregisterDialog (d)
-
Undisplay a dialog, removing its own keyhandler if needed
Parameters
- d: