Commit graph

203 commits

Author SHA1 Message Date
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
hispidence
07d8a254b9 Fix comment. 2021-07-24 12:29:54 +01:00
hispidence
cf8723c448 Add GameScriptSoundSourceInfo and GameScriptAIObject, and associated functions. 2021-07-24 12:29:25 +01:00
hispidence
6720fb2318 Make color getters const. 2021-07-24 12:26:48 +01:00
hispidence
b0089ef059 Make GetString return a char const *.
Make Intro a char const *.
2021-07-23 21:48:49 +01:00
hispidence
16a5998abc Declare WarningsAsErrors so that files which end up indirectly including GameScriptNamedBase.h don't complain 2021-07-23 21:43:08 +01:00
hispidence
97d5d85f7a Add AddLuaNameSink, RemoveLuaNameSink, and GetSinkByName.
Make a template that all GetXByName member functions work off, to reduce copypasted functions.
For consistency, rename RemoveLuaName and AddLuaName to RemoveLuaNameItem and AddLuaNameItem.
Fix some documentation comments, order function documentation into sections.
2021-07-23 16:02:30 +01:00
hispidence
278a52c49a Add GameScriptSinkInfo/SinkInfo. 2021-07-23 15:59:13 +01:00
hispidence
c13106252f Add m_camerasMapName, AddLuaNameCamera, RemoveLuaNameCamera, GetCameraByName, and GetMeshByName. 2021-07-23 02:09:52 +01:00
hispidence
1be51d0f9f Add GameScriptCameraInfo.h and GameScriptCameraInfo.cpp. 2021-07-23 02:08:13 +01:00
hispidence
c0c4310bed Add __tostring metamethod to GameScriptPosition, GameScriptRotation and GameScriptColor.
Make their properties lowercase to keep them consistent with the properties of other classes.

Move documentation from GameScriptPosition.h to GameScriptPosition.cpp.
2021-07-23 02:06:50 +01:00
hispidence
38291e7b60 Add m_temporary to GameScriptMeshInfo, as well as a constructor and destructor.
Fix documentation.

Remove duplicated pos property.
2021-07-23 02:04:47 +01:00
hispidence
1af07aa8b5 Rearrange GameScriptItemInfo a bit.
Exchange m_temporary in the move constructor.
Fix documentation to reference ObjID instead of int.
2021-07-23 02:03:31 +01:00
hispidence
16ea0f1aa2 Add documentation and constructor member initialisers for GameScript. 2021-07-21 18:19:57 +01:00
hispidence
936b7b36b6 Add conversions between GameScriptColor and Vector3/Vector4. 2021-07-21 18:18:51 +01:00
hispidence
f46e6222a2 Add GameScriptMeshInfo. This is still a fairly skeletal class for the time being. 2021-07-21 18:17:30 +01:00
hispidence
3d464becb2 Make GameScriptItemInfo inherit from GameScriptNamedBase and remove functions which now reside there. 2021-07-21 18:16:35 +01:00
hispidence
c82a505b67 Add GameScriptNameBase, which will serve as a base class for the GameScriptXInfo classes to avoid having to specify static callback-assignment functions and index metafunctions for each one individually. 2021-07-21 18:14:43 +01:00
hispidence
da5af327e9 Link up MeshInfo with GameLogicScript, adding a m_meshesMapName and implementing AddLuaNameMesh and RemoveLuaNameMesh.
Add GetMeshByName and make GetItemByName take a constant reference.

Remove no-longer-used headers.
2021-07-21 18:12:17 +01:00
hispidence
12dada0145 Make the "Lara" global non-owning. Will look into this and see if we actually need it. 2021-07-21 18:09:53 +01:00
hispidence
df11377a51 Make GetItemByName take a const ref, and make its error print the name of the item that could not be found.
Register GetItemByName in GameLogicScript instead of winmain. Register GameScriptColor too.

Define the lambdas passed to GameScriptItemInfo in terms of the actual functions we define. Functions that make a GameScriptItemInfo should pass false to make_unique (so the Lua object made does not control the lifetime of the ITEM_INFO).
2021-07-20 17:58:11 +01:00
hispidence
bf9bd13095 Make GameScriptColor::Register static. 2021-07-20 17:53:10 +01:00
hispidence
893c176c0c Move documentation from GameScriptRotation.h to ".cpp. 2021-07-20 17:49:14 +01:00
hispidence
12b28a38c6 Add Register function and documentation for GameScriptColor, since it will be used in GameScriptMeshInfo. 2021-07-20 17:48:39 +01:00
hispidence
ffa8791c03 Add concept of 'temporary' ItemInfo instances. These instances will kill the ITEM_INFO they reference when they are destroyed. This was previously the default behaviour. However, now that we're using things like GetItemByName, it makes more sense for ItemInfos to be non-owning by default.
Move LDoc from GameScriptItemInfo.h to GameScriptItemInfo.cpp. This might seem counter-intuitive, but LDoc is concerned with the Lua interfaces rather than the actual C++ functions; since the Lua interfaces are defined in GameScriptItemInfo::Register, it makes more sense for the comments to be nearby.
2021-07-20 17:18:39 +01:00
hispidence
e9b2026404 Make the contents of ObjectIDs.h part of the Lua interface. 2021-07-20 00:16:15 +01:00
hispidence
298f3905ec Add ObjectIDs.h. Add documentation comments to InventorySlots.h 2021-07-20 00:14:59 +01:00
hispidence
f379de7c89 Add m_initialised to GameScriptItemInfo. This is possibly temporary, and controls whether SetRoom calls ItemNewRoom or just sets the room number. This is because ItemNewRoom relies on InitialiseItem having been called, but InitialiseItem requires the roomNumber of the object to be correct.
Add and document GetLara.
2021-07-20 00:10:00 +01:00
MontyTRC89
81611e2bdd Added LUA name insertion on items loading; Fixed item rooms change (use ItemNewRoom); 2021-07-19 05:52:21 +02:00
hispidence
07d9fdae2f Add SetAnimNumber, GetAnimNumber, SetFrameNumber and GetFrameNumber. Fix SetGoalAnimState call. 2021-07-18 17:37:39 +01:00
hispidence
6e11570e3f Rename «Current/Goal/Required»Anim to «Current/Goal/Required»AnimState. 2021-07-18 15:29:40 +01:00
hispidence
21a867e821 Remove 'typedef' from enums and structs. This was required in C, but in C++ all it does is generate thousands of warnings. 2021-07-18 15:22:15 +01:00
hispidence
82e73efc27 Add initial documentation comments for GameScriptPosition and GameScriptRotation. 2021-07-17 23:51:01 +01:00
hispidence
552a4f07ae Fix some whitespace. 2021-07-17 23:50:10 +01:00
hispidence
5c30fdee5d Implementations for GameScriptItemInfo member functions «Get/Set»ObjectID, «Get/Set»Name, and default implementations for the callbacks. 2021-07-17 23:48:35 +01:00
hispidence
70d7ae4572 Add GameScriptItemInfo::«Set/Get»ObjectID and GameScriptItemInfo::SetNameCallbacks.
Add calls to the callbacks to GameScriptItemInfo::SetName, so that giving a Lua name to an object removes its existing object and any other object currently using the new name, before then putting the name into the map.

Add initial documentation for the Lua-exported parts.
2021-07-17 23:47:07 +01:00