Add more reserved script names.

This commit is contained in:
hispidence 2021-08-29 17:03:51 +01:00
parent 72f925c3bc
commit 5e525bb545
2 changed files with 46 additions and 20 deletions

View file

@ -178,16 +178,15 @@ GameScript::GameScript(sol::state* lua) : LuaHandler{ lua }
@function SetAmbientTrack
@tparam string name of track (without file extension) to play
*/
m_lua->set_function("SetAmbientTrack", &SetAmbientTrack);
m_lua->set_function(ScriptReserved_SetAmbientTrack, &SetAmbientTrack);
/*** Play an audio track
@function PlayAudioTrack
@tparam string name of track (without file extension) to play
@tparam bool loop if true, the track will loop; if false, it won't (default: false)
*/
m_lua->set_function("PlayAudioTrack", &PlayAudioTrack);
m_lua->set_function(ScriptReserved_PlayAudioTrack, &PlayAudioTrack);
m_lua->set_function("PrintString", &GameScript::PrintString, this);
/*** Player inventory management
@section Inventory
@ -202,7 +201,7 @@ For example, giving "zero" crossbow ammo would give the player
@tparam InvItem item the item to be added
@tparam int count the number of items to add (default: 0)
*/
m_lua->set_function("GiveInvItem", &InventoryAdd);
m_lua->set_function(ScriptReserved_GiveInvItem, &InventoryAdd);
/***
Remove x of a certain item from the inventory.
@ -211,7 +210,7 @@ As in @{GiveInvItem}, a count of 0 will remove the "default" amount of that item
@tparam InvItem item the item to be removed
@tparam int count the number of items to remove (default: 0)
*/
m_lua->set_function("TakeInvItem", &InventoryRemove);
m_lua->set_function(ScriptReserved_TakeInvItem, &InventoryRemove);
/***
Get the amount the player holds of an item.
@ -219,7 +218,7 @@ Get the amount the player holds of an item.
@tparam InvItem item the item to check
@treturn int the amount of the item the player has in the inventory
*/
m_lua->set_function("GetInvItemCount", &InventoryGetCount);
m_lua->set_function(ScriptReserved_GetInvItemCount, &InventoryGetCount);
/***
Set the amount of a certain item the player has in the inventory.
@ -228,7 +227,7 @@ Similar to @{GiveInvItem} but replaces with the new amount instead of adding it.
@tparam @{InvItem} item the item to be set
@tparam int count the number of items the player will have
*/
m_lua->set_function("SetInvItemCount", &InventorySetCount);
m_lua->set_function(ScriptReserved_SetInvItemCount, &InventorySetCount);
/*** Game entity getters.
All Lua variables created with these functions will be non-owning.
@ -244,7 +243,7 @@ Get an ItemInfo by its name.
@tparam string name the unique name of the item as set in, or generated by, Tomb Editor
@treturn ItemInfo a non-owning ItemInfo referencing the item.
*/
m_lua->set_function("GetItemByName", &GameScript::GetByName<GameScriptItemInfo, ScriptReserved_ItemInfo>, this);
m_lua->set_function(ScriptReserved_GetItemByName, &GameScript::GetByName<GameScriptItemInfo, ScriptReserved_ItemInfo>, this);
/***
Get a MeshInfo by its name.
@ -252,7 +251,7 @@ Get a MeshInfo by its name.
@tparam string name the unique name of the mesh as set in, or generated by, Tomb Editor
@treturn MeshInfo a non-owning MeshInfo referencing the mesh.
*/
m_lua->set_function("GetMeshByName", &GameScript::GetByName<GameScriptMeshInfo, ScriptReserved_MeshInfo>, this);
m_lua->set_function(ScriptReserved_GetMeshByName, &GameScript::GetByName<GameScriptMeshInfo, ScriptReserved_MeshInfo>, this);
/***
Get a CameraInfo by its name.
@ -260,7 +259,7 @@ Get a CameraInfo by its name.
@tparam string name the unique name of the camera as set in, or generated by, Tomb Editor
@treturn CameraInfo a non-owning CameraInfo referencing the camera.
*/
m_lua->set_function("GetCameraByName", &GameScript::GetByName<GameScriptCameraInfo, ScriptReserved_CameraInfo>, this);
m_lua->set_function(ScriptReserved_GetCameraByName, &GameScript::GetByName<GameScriptCameraInfo, ScriptReserved_CameraInfo>, this);
/***
Get a SinkInfo by its name.
@ -268,7 +267,7 @@ Get a SinkInfo by its name.
@tparam string name the unique name of the sink as set in, or generated by, Tomb Editor
@treturn SinkInfo a non-owning SinkInfo referencing the sink.
*/
m_lua->set_function("GetSinkByName", &GameScript::GetByName<GameScriptSinkInfo, ScriptReserved_SinkInfo>, this);
m_lua->set_function(ScriptReserved_GetSinkByName, &GameScript::GetByName<GameScriptSinkInfo, ScriptReserved_SinkInfo>, this);
/***
Get a SoundSourceInfo by its name.
@ -276,7 +275,7 @@ Get a SoundSourceInfo by its name.
@tparam string name the unique name of the sink as set in, or generated by, Tomb Editor
@treturn SoundSourceInfo a non-owning SoundSourceInfo referencing the sink.
*/
m_lua->set_function("GetSoundSourceByName", &GameScript::GetByName<GameScriptSoundSourceInfo, ScriptReserved_SoundSourceInfo>, this);
m_lua->set_function(ScriptReserved_GetSoundSourceByName, &GameScript::GetByName<GameScriptSoundSourceInfo, ScriptReserved_SoundSourceInfo>, this);
/***
Calculate the distance between two positions.
@ -285,7 +284,7 @@ Calculate the distance between two positions.
@tparam Position posB second position
@treturn int the direct distance from one position to the other
*/
m_lua->set_function("CalculateDistance", &CalculateDistance);
m_lua->set_function(ScriptReserved_CalculateDistance, &CalculateDistance);
/***
Calculate the horizontal distance between two positions.
@ -294,7 +293,7 @@ Calculate the horizontal distance between two positions.
@tparam Position posB second position
@treturn int the direct distance on the XZ plane from one position to the other
*/
m_lua->set_function("CalculateHorizontalDistance", &CalculateHorizontalDistance);
m_lua->set_function(ScriptReserved_CalculateHorizontalDistance, &CalculateHorizontalDistance);
/***
Show some text on-screen.
@ -306,7 +305,7 @@ until @{HideString} is called or until the level is finished.
Default: nil (i.e. infinite)
*/
m_lua->set_function("ShowString", &GameScript::ShowString, this);
m_lua->set_function(ScriptReserved_ShowString, &GameScript::ShowString, this);
/***
Hide some on-screen text.
@ -314,13 +313,13 @@ Hide some on-screen text.
@tparam DisplayString str the string object to hide. Must previously have been shown
with a call to @{ShowString}, or this function will have no effect.
*/
m_lua->set_function("HideString", [this](GameScriptDisplayString const& s) {ShowString(s, 0.0f); });
m_lua->set_function(ScriptReserved_HideString, [this](GameScriptDisplayString const& s) {ShowString(s, 0.0f); });
MakeReadOnlyTable("ObjID", kObjIDs);
MakeReadOnlyTable(ScriptReserved_ObjID, kObjIDs);
ResetLevelTables();
MakeSpecialTable(m_lua, "GameVars", &LuaVariables::GetVariable, &LuaVariables::SetVariable, &m_globals);
MakeSpecialTable(m_lua, ScriptReserved_GameVars, &LuaVariables::GetVariable, &LuaVariables::SetVariable, &m_globals);
GameScriptItemInfo::Register(m_lua);
GameScriptItemInfo::SetNameCallbacks(
@ -372,8 +371,8 @@ with a call to @{ShowString}, or this function will have no effect.
void GameScript::ResetLevelTables()
{
MakeSpecialTable(m_lua, "LevelFuncs", &GameScript::GetLevelFunc, &GameScript::SetLevelFunc, this);
MakeSpecialTable(m_lua, "LevelVars", &LuaVariables::GetVariable, &LuaVariables::SetVariable, &m_locals);
MakeSpecialTable(m_lua, ScriptReserved_LevelFuncs, &GameScript::GetLevelFunc, &GameScript::SetLevelFunc, this);
MakeSpecialTable(m_lua, ScriptReserved_LevelVars, &LuaVariables::GetVariable, &LuaVariables::SetVariable, &m_locals);
}
sol::protected_function GameScript::GetLevelFunc(sol::table tab, std::string const& luaName)