Commit graph

85 commits

Author SHA1 Message Date
hispidence
c8de277d44 Remove GetLara as the Lara object is easier to use.
Add documentation for the Lara object.
2021-08-12 20:14:02 +01:00
hispidence
cd16268e19 Actually add documentation. 2021-08-12 19:58:22 +01:00
hispidence
3efa8f16b7 Take CalculateDistance and CalculateHorizontalDistance out of header file as they can be static now.
Add documentation for said functions.
2021-08-12 19:57:17 +01:00
hispidence
53cd3add4f Register CalculateDistance and CalculateHorizontalDistance in GameLogicScript. 2021-08-12 19:54:03 +01:00
hispidence
582b000fb9 Make OnControlPhase take a float, representing the delta time.
This is not ACTUALLY the amount of time that has passed, since things in the gameplay loop appear to assume they are being called thirty times per second, even if more or less time has passed. Thus to keep the scripts in sync with the the rest of the engine, we force a 1/30 second delta time.
2021-08-12 18:20:14 +01:00
hispidence
adf1361d99 Fix documentation; Level -> LevelVars. 2021-08-12 02:43:59 +01:00
hispidence
ea1649b7b1 Make "loop" arg to PlayAudioTrack optional; defaulting to false. 2021-08-12 02:39:29 +01:00
hispidence
b708a6068d Add comments and update documentation for InventoryAdd/InventoryRemove. 2021-08-12 02:38:30 +01:00
hispidence
c1b46afd62 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
156342ca14 Register GameScriptRotation in GameFlowScript and not GameLogicScript. 2021-08-11 01:26:35 +01:00
hispidence
7300193b47 More cleanup. 2021-08-09 00:54:09 +01:00
hispidence
61d9e00e63 Change InventoryAdd/Remove/GetCount/SetCount and GameScriptInventoryObject to use ItemEnumPair. 2021-08-09 00:01:40 +01:00
hispidence
05054a05fe Make the read-only table of kInventorySlots in GameFlowScript instead of GameLogicScript. 2021-08-08 23:53:52 +01:00
hispidence
4a2e61fcbc Don't register Color in GameScript (it's in GameFlow now). 2021-08-07 19:14:11 +01:00
hispidence
2d4c091b64 Make MakeReadOnlyTable a member function of LuaHandler so that GameFlow can use it too. 2021-08-07 19:00:45 +01:00
hispidence
7bc9e7b935 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
dc40060a63 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
354b21d4f4 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
1d1653f995 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
5929180395 Remove AddLuaId and GetItemById. 2021-08-04 16:21:00 +01:00
hispidence
a637701d63 Replace std::runtime_exception with TENScriptException. 2021-08-03 15:15:42 +01:00
hispidence
e6c076eb41 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
783d344185 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
447ba86d30 Add GameScriptSoundSourceInfo and GameScriptAIObject, and associated functions. 2021-07-24 12:29:25 +01:00
hispidence
f9ae0046c6 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
5257a3c074 Add m_camerasMapName, AddLuaNameCamera, RemoveLuaNameCamera, GetCameraByName, and GetMeshByName. 2021-07-23 02:09:52 +01:00
hispidence
bd4df80c46 Add documentation and constructor member initialisers for GameScript. 2021-07-21 18:19:57 +01:00
hispidence
23ec719020 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
63a696f25e 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
4fd68787dc 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
1ba7007d92 Make the contents of ObjectIDs.h part of the Lua interface. 2021-07-20 00:16:15 +01:00
hispidence
87ebe31767 Uncomment ExecuteFunction and make it take a const ref.
Make «Add/Remove»LuaName return a bool for future error checking, and pass them via lambdas to GameScriptItemInfo, allowing it to call them whenever an object is added or removed (they would not have access to the m_itemsMapName otherwise).
2021-07-17 22:26:07 +01:00
MontyTRC89
7c1e29e6d0 Added code (to finish) for executing LUA triggers 2021-07-17 05:56:40 +02:00
MontyTRC89
916d22759b Merge remote-tracking branch 'origin/lara_info'
# Conflicts:
#	TR5Main/Game/Lara/lara_flare.h
#	TR5Main/Scripting/GameLogicScript.cpp
2021-07-14 05:48:42 +02:00
Troye
5d8bb0014d FLARE_AGE constant; fix dynamic light intensity; fix release builds 2021-07-13 22:29:47 -05:00
hispidence
3599cf68d4 Make GameLogicScript use kInventorySlots. Make InvItem a read-only table. This means we do not need to write an enum directly in the Lua source. 2021-07-13 13:21:13 +01:00
hispidence
5dd8ca33a8 Implement GiveInvItem, TakeInvItem, GetInvItemCount and SetInvItemCount (names to be finalized). 2021-07-10 14:05:01 +01:00
MontyTRC89
c98c51f5b5 Made LUA script optional; Deleted my bugged test code for volumes; 2021-07-06 11:54:34 +02:00
hispidence
7a43cd156c Make InventoryAdd and InventoryRemove static. Add them as Lua functions. 2021-07-05 18:18:20 +01:00
hispidence
47f5745304 Register SetAmbientTrack and PlayAudioTrack. Make PlayAudioTrack static, pass its string arg by reference-to-const, and let it use the loop bool passed in instead of the one stored in global state.
Improve some text formatting in the header.
2021-07-04 14:33:57 +01:00
hispidence
b7d2a45a29 Make SetAmbientTrack take a string by const ref. Change functions to access GameScript[Position/Rotation] members directly instead of via getters/setters. 2021-07-03 23:18:10 +01:00
hispidence
4e09dc1d1d Add doCallback function to throw an exception if one of the callback encounters an error (and if WarningsAsErrors is on). 2021-07-03 23:16:28 +01:00
hispidence
932ac8f4a2 Add implementation of GameScript::InitCallbacks and the C++ holders of the callbacks. This might well be a needless layer of indirection, but it prevents the callbacks being reassigned outside of the class. 2021-07-01 19:33:48 +01:00
hispidence
b4a52de5d0 Register GameScriptRotation and GameScriptPosition in GameScript constructor. Remove GameScriptItem class, which has been merged into GameScriptItemInfo. 2021-07-01 19:29:58 +01:00
MontyTRC89
a507e9e1be Moved GameScriptPosition, GameScriptRotation and GameScriptColor classes in separate files 2021-06-29 05:28:17 +02:00
MontyTRC89
aaee0e833a Merge branch 'NewLuaScripting' of https://github.com/MontyTRC89/TR5Main into NewLuaScripting
# Conflicts:
#	TR5Main/Scripting/GameLogicScript.cpp
2021-06-29 05:03:57 +02:00
MontyTRC89
255393b589 Added FROM_DEGREES function; Added quantity param to PickedUpObject(); LUA scripting refactoring WIP; 2021-06-29 05:00:15 +02:00
hispidence
b2ace2c1bf Include and register GameScriptItemInfo. 2021-06-28 18:35:16 +01:00
MontyTRC89
a4d3ec9d26 Switched audio tracks from int index to string; Added Tracks.lua loading support; 2021-06-26 07:36:54 +02:00
MontyTRC89
127e142622 Merge branch 'NewLuaScripting' of https://github.com/MontyTRC89/TR5Main into NewLuaScripting
# Conflicts:
#	TR5Main/Scripting/GameLogicScript.cpp
2021-06-23 05:59:25 +02:00