Commit graph

238 commits

Author SHA1 Message Date
hispidence
b480ea23f7 Amend doc comment. 2021-08-12 17:20:09 +01:00
hispidence
801f47704f Fix documentation; Level -> LevelVars. 2021-08-12 02:43:59 +01:00
hispidence
634ab107ad Make "loop" arg to PlayAudioTrack optional; defaulting to false. 2021-08-12 02:39:29 +01:00
hispidence
c29af38f39 Add comments and update documentation for InventoryAdd/InventoryRemove. 2021-08-12 02:38:30 +01:00
hispidence
f4fb3786c9 Rename Lua tables Game and Level to GameVars and LevelVars to disambiguate the latter from the Level class. 2021-08-12 00:39:52 +01:00
hispidence
bf13661da6 Remove GameScriptLevel members which look superfluous. Mark some others as unused (for now). 2021-08-11 14:51:21 +01:00
hispidence
3a3afcaf38 Update Level documentation. 2021-08-11 14:50:10 +01:00
hispidence
855f67e1b9 Add default member initialisers and default constructor for GameScriptRotation.
These aren't intended (at the moment) to be exposed to the script writer; it's needed so that classes with a GameScriptRotation member can have a default member initialiser.
2021-08-11 14:39:26 +01:00
hispidence
978e61108c Add default member initialisers, SetSlot function, and default constructor for GameScriptInventoryObject.
Expose default constructor to Lua API. Use SetSlot as a sol::property instead of accessing the member directly.

Update documentation.
2021-08-11 14:38:24 +01:00
hispidence
b24d6e8841 Update GameFlowScript to account for the changes made to GameScriptInventoryObject.
Add FROM_DEGREES calls to fix the "rot" property.
2021-08-11 01:28:37 +01:00
hispidence
8de08be1de Register GameScriptRotation in GameFlowScript and not GameLogicScript. 2021-08-11 01:26:35 +01:00
hispidence
6f382a08e9 Refactor and add documenation for GameScriptInventoryObject. 2021-08-11 01:23:07 +01:00
hispidence
bd0a681fb0 Fix wrong name in ItemInfo documentation. 2021-08-11 01:21:11 +01:00
hispidence
1f6ca859b6 Rename some of GameScriptLevel's Lua "members" to better reflect their purpose.
Add documentation that was missing.
2021-08-09 20:02:55 +01:00
hispidence
ea08939509 Fix clusterfuck of a sentence. 2021-08-09 20:01:39 +01:00
hispidence
6257cf49b7 Give InventoryObject some documentation. Rename "name" to "nameKey". 2021-08-09 20:01:05 +01:00
hispidence
9ce4157d54 More cleanup. 2021-08-09 00:54:09 +01:00
hispidence
4eba60c941 Clean GameScriptInventoryObject a bit. 2021-08-09 00:22:58 +01:00
hispidence
b9806c25a1 Add some initial documentation for GameScriptMirror. 2021-08-09 00:07:53 +01:00
hispidence
72cd78ace7 Remove ResetHub; as it's almost certainly going to be made obsolete with the new scripts and save game rework. 2021-08-09 00:07:08 +01:00
hispidence
d3742cb87e Change InventoryAdd/Remove/GetCount/SetCount and GameScriptInventoryObject to use ItemEnumPair. 2021-08-09 00:01:40 +01:00
hispidence
5458e7a67e Make the read-only table of kInventorySlots in GameFlowScript instead of GameLogicScript. 2021-08-08 23:53:52 +01:00
hispidence
d386d55546 Modify InvItem table to map to both GAME_OBJECT_ID and inv_objects. We can't use a std::pair directly since sol::as_table will interpret the unordered_map weirdly if we do. 2021-08-08 23:52:38 +01:00
hispidence
9fbb3cc7b7 Improve GameScriptLevel.
Rename LARA_DRAW_TYPE to LARA_TYPE as it's used in more than just drawing code. Make WEATHER_TYPE a scoped enum (would have done this for LARA_TYPE too but didn't want to pepper casts in other parts of the codebase). Relabel constants in both enums.

Add kLaraTypes and kWeatherTypes and add them as tables in GameFlow.

Remove Background member - it's not level-specific so GameFlow is a better home for it.

Add (incomplete for now) documentation for some GameScriptLevel members - those I tested, at any rate.
2021-08-07 19:20:17 +01:00
hispidence
2dde169769 Don't register Color in GameScript (it's in GameFlow now). 2021-08-07 19:14:11 +01:00
hispidence
f4ef0dc468 Clean up GameFlowScript.
Remove a lot of members which were unused and which represented level properties already accounted for in GameScriptLevel.

Make TITLE_TYPE an enum class and relabel its values.

Add TitleScreenImagePath and SetTitleScreenImagePath, which replaces GameScriptLevel's Background member.

Register GameScriptColor in GameFlowScript since we will be using it for the fog and sky layer properties of levels.
2021-08-07 19:13:36 +01:00
hispidence
d60a86b9b8 Improve GameScriptSkyLayer.
Make its constructor take a GameScriptColor, and give it a SetColor function, exposing it to Lua as the color member.

Add documentation.
2021-08-07 19:06:22 +01:00
hispidence
23e1ab0f50 Clean up GameScriptColor.
Give it default member initialisers and a delegating constructor and expose the four-component version to Lua.
2021-08-07 19:03:27 +01:00
hispidence
9b29de8dda Make MakeReadOnlyTable a member function of LuaHandler so that GameFlow can use it too. 2021-08-07 19:00:45 +01:00
hispidence
aff468f964 Replace a TENLog call with ScriptWarn, so that it won't get logged in ERROR_MODE::SILENT. 2021-08-06 16:48:03 +01:00
hispidence
a34828b5d9 Make m_levelFuncs an unordered_set, as these seem to be the proper structure to use when the key IS the value.
Make all GameScript maps unordered_maps, as these are supposed to be more suitable for cases where we don't need the data to be sorted.

Add default member initialisers to GameScript.
2021-08-06 16:47:24 +01:00
hispidence
3fc779a60b Add ErrorMode to GameScriptSettings (C++) and errorMode to settings (Lua). Call SetErrorMode in LoadGameFlowScript. 2021-08-06 16:44:37 +01:00
hispidence
d9ba34e67e Add ScriptWarn and SetErrorMode.
SetErrorMode is called via Lua in settings.lua to allow us or the LD to choose between the three ERROR_MODEs for script asserts.

ScriptWarn is for when we want to follow up on a failed assert in ERROR_MODE::WARN. e.g. if the player gives in an invalid HP value, we would ScriptWarn to tell them that the HP is being set to zero instead. If we added this information in ScriptAssert, we would end up displaying this message in TERMINATE mode, too - which is incorrect, since we won't have set the HP to zero, as we will have terminated the game.
2021-08-06 16:43:01 +01:00
hispidence
8009ed9a3b Add m_levelFuncs and SetLevelFunc. These correspond to the table "LevelFuncs", which will hold trigger functions and the OnStart (etc) callbacks. Putting them into a table will make it much easier to discard them when the player goes from one level to another (through loading a save or finishing the current level).
Rework Level and Game tables as they weren't entirely working before. These correspond to m_locals and m_globals, which hold the level-specific and game-spanning data that will go into save files.

Make GetVariable and SetVariable take sol::table args. Sol seems to require this in order to use them as metamethods of a table (it doesn't require them for usertypes, but it seems more logical from the API point of view for Level and Game to be tables).

Add documentation for the above tables.

Move several functions out of the GameScript class in order to simplify its interface, and make them static functions that only live in GameLogicScript.cpp.

Remove g_GameScript from GameLogicScript.cpp as it's not used there; let winmain.cpp deal with it instead.
2021-08-05 21:36:18 +01:00
hispidence
80af3eb4d8 Make ScriptErrorMode static. 2021-08-04 16:51:58 +01:00
hispidence
ead31e63f2 Replace WarningsAsErrors usage with ScriptAssert usage.
For recoverable errors, add some recovery behaviour and logging so a level designer can see in the log what was done as a result of the error.

Warn about default behaviour if no callbacks are added.
2021-08-04 16:51:28 +01:00
hispidence
052b03ec96 Remove AddLuaId and GetItemById. 2021-08-04 16:21:00 +01:00
hispidence
895a7ae025 Add ScriptAssert.
This is to be used when an error is discovered in a Lua Script.

The var ScriptErrorMode refers to the error mode the user has chosen (silent, warn, terminate). At the moment this is hardcoded but will soon become editable to a LD via settings.

ScriptAssert will read this variable and take the appropriate action when an assert is failed.

IGNORE will do nothing (we should make a note in the documentation that this should almost certainly not be used by the LD if they can avoid it).
WARN will call TENLog with LogLevel::Warn.
TERMINATE will throw a TENScriptException, where it will be caught at GameMain, where TENLog will be called.

There are circumstances where we will HAVE to terminate, even if the user has opted not to (i.e. errors where there is nothing sensible that can be done, such as syntax errors that would terminate Lua anyway). For these, we can pass in ERROR_MODE::TERMINATE as the last variable.
2021-08-04 16:18:52 +01:00
hispidence
529e8f9a69 Fix indentation. 2021-08-03 15:16:55 +01:00
hispidence
2e3a845aa4 Rename GameScriptSettings to Settings on the Lua side. 2021-08-03 15:16:06 +01:00
hispidence
fde79b4704 Replace std::runtime_exception with TENScriptException. 2021-08-03 15:15:42 +01:00
hispidence
58a424e52f Change ExecuteScript and ExecuteString to return void and throw a TENScriptException on error. Remove my old comments which didn't really add info. Implement SetSettings. 2021-08-03 15:12:24 +01:00
hispidence
7216b7b0af Remove accidental scope specifier thingy. 2021-07-31 13:23:22 +01:00
hispidence
d31ecdf58e Change TitleType member initializer. 2021-07-31 12:50:52 +01:00
hispidence
8b7928d83e Missed these in the last commit. 2021-07-28 19:06:15 +01:00
hispidence
5562667f98 Move GameScriptLevel, GameScriptAudioTrack, GameScriptInventoryObject, GameScriptSkyLayer, GameScriptSettings and GameScriptMirror into their own files. This could be changed later as this does create many small .h and .cpp files, but for now this cleans things up and makes it easier to check things class by class.
Treat functions as global that would previously be accessed through the GameFlow table. This does pollute the global environment in Lua a bit, but keeps it consistent with the functions in GameLogicScript, which are all accessed as globals.

Add some default member initialisers.

Remove WriteDefaults. Rename Intro to IntroImagePath and make it a std::string.

Add some documentation for the functions of GameFlowScript.

Fix some comments.
2021-07-28 18:44:24 +01:00
hispidence
4de85da46a Include GameScriptColor.h in GameFlowScript.h as it uses it. 2021-07-26 18:28:13 +01:00
hispidence
dba2f8ac91 Delete copy operations for GameScriptAIObject, GameScriptCameraInfo, GameScriptSinkInfo and GameScriptSoundSourceInfo - this can be changed later, but for now is a safety measure since we hold a reference, which means copying these would take some extra thought. 2021-07-26 18:25:50 +01:00
hispidence
e33e821cb8 Clean up GameFlow and GameScriptLevel by adding default member initialisers. Replace GameScriptFog with GameScriptColor. Rename some enums for consistency. Make TITLE_TYPE and enum for consistency. 2021-07-26 18:23:29 +01:00
hispidence
9dd4bcf4ca Add SOUND_SOURCE_INFO and AI_OBJECT names when loading in the level data. Implement remaining functions on the GameLogicScript side. 2021-07-24 12:45:33 +01:00