mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-30 08:47:58 +03:00
Add documentation and constructor member initialisers for GameScript.
This commit is contained in:
parent
29d4f89263
commit
bd4df80c46
1 changed files with 71 additions and 1 deletions
|
@ -20,23 +20,92 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/***
|
||||||
|
Global functions and callbacks (not actually a module but a set of global functions)
|
||||||
|
@module global
|
||||||
|
@pragma nostrip
|
||||||
|
*/
|
||||||
|
|
||||||
extern GameFlow* g_GameFlow;
|
extern GameFlow* g_GameFlow;
|
||||||
GameScript* g_GameScript;
|
GameScript* g_GameScript;
|
||||||
extern bool const WarningsAsErrors = true;
|
extern bool const WarningsAsErrors = true;
|
||||||
|
|
||||||
GameScript::GameScript(sol::state* lua) : LuaHandler{ lua }
|
GameScript::GameScript(sol::state* lua) : LuaHandler{ lua }, m_itemsMapId{}, m_itemsMapName{}, m_meshesMapName{}
|
||||||
{
|
{
|
||||||
|
/***
|
||||||
|
Set the named track as the ambient track, and start playing it
|
||||||
|
@function SetAmbientTrack
|
||||||
|
@tparam string name of track (without file extension) to play
|
||||||
|
*/
|
||||||
m_lua->set_function("SetAmbientTrack", &GameScript::SetAmbientTrack);
|
m_lua->set_function("SetAmbientTrack", &GameScript::SetAmbientTrack);
|
||||||
|
|
||||||
|
/***
|
||||||
|
Start playing the named 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
|
||||||
|
*/
|
||||||
m_lua->set_function("PlayAudioTrack", &GameScript::PlayAudioTrack);
|
m_lua->set_function("PlayAudioTrack", &GameScript::PlayAudioTrack);
|
||||||
|
|
||||||
|
/***
|
||||||
|
Add x of a certain item to the inventory.
|
||||||
|
@function GiveInvItem
|
||||||
|
@tparam @{InvItem}) item the item to be added
|
||||||
|
@tparam int the number of items to add
|
||||||
|
*/
|
||||||
m_lua->set_function("GiveInvItem", &GameScript::InventoryAdd);
|
m_lua->set_function("GiveInvItem", &GameScript::InventoryAdd);
|
||||||
|
|
||||||
|
/***
|
||||||
|
Remove x of a certain item from the inventory.
|
||||||
|
@function TakeInvItem
|
||||||
|
@tparam @{InvItem}) item the item to be removed
|
||||||
|
@tparam int the number of items to remove
|
||||||
|
*/
|
||||||
m_lua->set_function("TakeInvItem", &GameScript::InventoryRemove);
|
m_lua->set_function("TakeInvItem", &GameScript::InventoryRemove);
|
||||||
|
|
||||||
|
/***
|
||||||
|
Get the amount the player holds of an item.
|
||||||
|
@function GetInvItemCount
|
||||||
|
@tparam @{InvItem}) item the item to check
|
||||||
|
@return the amount of the item the player has in the inventory
|
||||||
|
*/
|
||||||
m_lua->set_function("GetInvItemCount", &GameScript::InventoryGetCount);
|
m_lua->set_function("GetInvItemCount", &GameScript::InventoryGetCount);
|
||||||
|
|
||||||
|
/***
|
||||||
|
Set the amount of a certain item the player has in the inventory.
|
||||||
|
Similar to @{GiveInvItem} but replaces with the new amount instead of adding it.
|
||||||
|
@function SetInvItemCount
|
||||||
|
@tparam @{InvItem}) item the item to be set
|
||||||
|
@tparam int the number of items the player will have
|
||||||
|
*/
|
||||||
m_lua->set_function("SetInvItemCount", &GameScript::InventorySetCount);
|
m_lua->set_function("SetInvItemCount", &GameScript::InventorySetCount);
|
||||||
|
|
||||||
|
/***
|
||||||
|
Get an ItemInfo by its name. This is non-owning, meaning the actual item will not
|
||||||
|
be removed from the game if the ItemInfo object is destroyed.
|
||||||
|
@function GetItemByName
|
||||||
|
@tparam string name the unique name of the item as set in, or generated by, Tomb Editor
|
||||||
|
@return a non-owning ItemInfo referencing the item.
|
||||||
|
*/
|
||||||
m_lua->set_function("GetItemByName", &GameScript::GetItemByName, this);
|
m_lua->set_function("GetItemByName", &GameScript::GetItemByName, this);
|
||||||
|
|
||||||
|
/***
|
||||||
|
Get an ItemInfo by its integer ID.
|
||||||
|
Not sure if we're using this.
|
||||||
|
@function GetItemByID
|
||||||
|
@tparam int ID the ID of the item
|
||||||
|
@return a non-owning ItemInfo referencing the item.
|
||||||
|
*/
|
||||||
m_lua->set_function("GetItemByID", &GameScript::GetItemById, this);
|
m_lua->set_function("GetItemByID", &GameScript::GetItemById, this);
|
||||||
|
|
||||||
|
/***
|
||||||
|
Get a MeshInfo by its name. This is non-owning, meaning the actual mesh will not
|
||||||
|
be removed from the game if the MeshInfo object is destroyed.
|
||||||
|
@function GetMeshByName
|
||||||
|
@tparam string name the unique name of the mesh as set in, or generated by, Tomb Editor
|
||||||
|
@return a non-owning MeshInfo referencing the mesh.
|
||||||
|
*/
|
||||||
|
m_lua->set_function("GetMeshByName", &GameScript::GetMeshByName, this);
|
||||||
auto makeReadOnlyTable = [this](std::string const & tableName, auto const& container)
|
auto makeReadOnlyTable = [this](std::string const & tableName, auto const& container)
|
||||||
{
|
{
|
||||||
auto mt = tableName + "Meta";
|
auto mt = tableName + "Meta";
|
||||||
|
@ -84,6 +153,7 @@ GameScript::GameScript(sol::state* lua) : LuaHandler{ lua }
|
||||||
{"LARA", ID_LARA}
|
{"LARA", ID_LARA}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// todo document this when I get round to looking into it
|
||||||
m_lua->new_usertype<LuaVariables>("Variable",
|
m_lua->new_usertype<LuaVariables>("Variable",
|
||||||
sol::meta_function::index, &LuaVariables::GetVariable,
|
sol::meta_function::index, &LuaVariables::GetVariable,
|
||||||
sol::meta_function::new_index, &LuaVariables::SetVariable,
|
sol::meta_function::new_index, &LuaVariables::SetVariable,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue