Contains general game-related functions.
This is a global object that can always be accessed.
GetGameLogic:Quit(); //quits the game
boolean SetUserProfileName(string name)
Re-initializes everything and attempts to load the profile sent in. Think of this as loading a saved game. If no profile exists, it is created.
Dangerous and illegal characters are stripped automatically, so the profile name may be slightly different than the one you sent in.
name | the name of the profile. If you say, “Player”, it will create/load/save profiles/Player/(active world name). |
False on error (for instance, the name passed in is not a valid path, or tries to access somewhere illegal), true on success
string GetUserProfileName()
The active user profile name. Will return a blank string if empty. (ie, “”, not nil)
nil ResetUserProfile(string name)
This completely deletes a profile, if it existed.
Input is stripped of dangerous/illegal characters.
name | The profile name you want to delete. |
Novashell never uses a dangerous deltree type way to delete things, it carefully verifies and scans the directory deletes only valid novashell data.
boolean UserProfileExists(string name)
name | The profile name you want to check for. Is stripped for dangerous/illegal characters. |
True if the profile exists.
boolean UserProfileActive()
True if a user profile is currently loaded/active.
boolean ToggleEditMode()
Enable/Disable the in-game editor.
True if the it just turned ON the editor, false if it was just turned off
nil SetRestartEngineFlage(boolean bRestart)
bRestart | If true, the engine will save all modified data and restart as soon as cybernetic ally possible. |
nil AddCallbackOnPostLogicUpdate(string callbackName, number entityID)
Allows you to add a function to be called after the entities logic updates happen. I added this as an easy way to make a game loop without needing to connect it with an entity.
The callback is automatically deleted when an Entity dies. In the case of a global function, there is no way to unregister it.
It must accept a single parm, this “Step” is a number that contains the ‘step-size’ used in the logic update, similar to an entities Update(step).
//Example to make a global game loop function, run this somewhere at the start:
GetGameLogic:AddCallbackOnPostLogicUpdate("OnGameLoop", C_ENTITY_NONE);
//this is run every logic tick
function OnGameLoop(step)
LogMsg("Game loop update");
//shake the camera randomly.. earthquake!
GetCamera:SetPos(GetCamera:GetPos() + Vector2(10-Random(20), 10-Random(20)));
end
string callBackName | The name of the callback function that should be called. (Must exist in your code) |
entityID | If it’s an Entity function and not a global function, you’ll need to enter the Entity’s ID here. Otherwise, <C_ENTITY_NONE>. |
boolean IsShuttingDown()
When a game is closing or restarting all maps are ‘shutdown’. During this time, each entity has its OnKill() run, during times like this is may be useful to know if the engine is currently shutting down or not, to avoid trying to access things that might already be deleted.
True if the engine is currently shutting down. (Either to exit, or to restart, both have the same shutdown process)
nil ClearModPaths()
Removes all overlaid paths. This should be done right before doing a SetRestartEngineFlag() call. Allows you to re-mount directories or go back to the world selection dialog. (that’s default if no mods are mounted)
nil AddModPath(string pathName)
This lets you mount a world path. Scripts, images, and resources are loaded in reverse order of mounting, ie, the last thing you mounted gets checked first.
”Base” is always mounted first automatically.
Worlds are also automatically mounted if specified in its .novashell configuration file.
pathName | A name of a world to mount. Example: “Test World”. |
nil InitGameGUI(string xmlFileName)
This xml file contains data about fonts, sizes, and colors that should be used for game dialogs and menus.
By editing this, you can use your own custom bitmap fonts.
Check the default one in base/game_gui/standard.xml for an example.
A world can only initialize this once.
xmlFileName | A path and filename to an xml file. |
DataManager Data()
This let’s you access a global DataManager that is automatically saved and loaded with the game per user profile.
Never use DataManager::Clear on this, the save-load game system uses it to store certain things as well, such as the game time.
A global DataManager object to store/retrieve anything you wish per profile.
DataManager WorldData()
This let’s you access a global DataManager that is automatically saved and loaded with the game.
Unlike <DataManager::Data> because it is shared between profiles. Useful for specifying global game tweaking variables that will never change for instance.
A global DataManager object to store/retrieve anything you wish.