mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-10 20:46:47 +03:00
Implement GiveInvItem, TakeInvItem, GetInvItemCount and SetInvItemCount (names to be finalized).
This commit is contained in:
parent
9823087e32
commit
a00f3a23fb
2 changed files with 21 additions and 13 deletions
|
@ -11,6 +11,8 @@
|
||||||
#include "tomb4fx.h"
|
#include "tomb4fx.h"
|
||||||
#include "effect2.h"
|
#include "effect2.h"
|
||||||
#include "pickup.h"
|
#include "pickup.h"
|
||||||
|
#include "newinv2.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
extern GameFlow* g_GameFlow;
|
extern GameFlow* g_GameFlow;
|
||||||
GameScript* g_GameScript;
|
GameScript* g_GameScript;
|
||||||
|
@ -21,8 +23,11 @@ GameScript::GameScript(sol::state* lua) : LuaHandler{ lua }
|
||||||
m_lua->set_function("SetAmbientTrack", &GameScript::SetAmbientTrack);
|
m_lua->set_function("SetAmbientTrack", &GameScript::SetAmbientTrack);
|
||||||
m_lua->set_function("PlayAudioTrack", &GameScript::PlayAudioTrack);
|
m_lua->set_function("PlayAudioTrack", &GameScript::PlayAudioTrack);
|
||||||
|
|
||||||
m_lua->set_function("InventoryAdd", &GameScript::InventoryAdd);
|
m_lua->set_function("GiveInvItem", &GameScript::InventoryAdd);
|
||||||
m_lua->set_function("InventoryRemove", &GameScript::InventoryRemove);
|
m_lua->set_function("TakeInvItem", &GameScript::InventoryRemove);
|
||||||
|
|
||||||
|
m_lua->set_function("GetInvItemCount", &GameScript::InventoryGetCount);
|
||||||
|
m_lua->set_function("SetInvItemCount", &GameScript::InventorySetCount);
|
||||||
|
|
||||||
GameScriptItemInfo::Register(m_lua);
|
GameScriptItemInfo::Register(m_lua);
|
||||||
GameScriptPosition::Register(m_lua);
|
GameScriptPosition::Register(m_lua);
|
||||||
|
@ -306,24 +311,27 @@ void GameScript::Earthquake(int strength)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inventory
|
// Inventory
|
||||||
void GameScript::InventoryAdd(int slot, int count)
|
void GameScript::InventoryAdd(int slot, sol::optional<int> count)
|
||||||
{
|
{
|
||||||
PickedUpObject(slot, count);
|
PickedUpObject(static_cast<GAME_OBJECT_ID>(inventry_objects_list[slot].object_number), count.value_or(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScript::InventoryRemove(int slot, int count)
|
void GameScript::InventoryRemove(int slot, sol::optional<int> count)
|
||||||
{
|
{
|
||||||
RemoveObjectFromInventory(slot, count);
|
RemoveObjectFromInventory(static_cast<GAME_OBJECT_ID>(inventry_objects_list[slot].object_number), count.value_or(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScript::InventoryGetCount(int slot)
|
int GameScript::InventoryGetCount(int slot)
|
||||||
{
|
{
|
||||||
|
return GetInventoryCount(static_cast<GAME_OBJECT_ID>( inventry_objects_list[slot].object_number));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScript::InventorySetCount(int slot, int count)
|
void GameScript::InventorySetCount(int slot, int count)
|
||||||
{
|
{
|
||||||
|
auto result = static_cast<GAME_OBJECT_ID>( inventry_objects_list[slot].object_number );
|
||||||
|
// add the amount we'd need to add to get to count
|
||||||
|
int currAmt = GetInventoryCount(result);
|
||||||
|
InventoryAdd(slot, count - currAmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScript::InventoryCombine(int slot1, int slot2)
|
void GameScript::InventoryCombine(int slot1, int slot2)
|
||||||
|
|
|
@ -96,10 +96,10 @@ public:
|
||||||
void Earthquake(int strength);
|
void Earthquake(int strength);
|
||||||
|
|
||||||
// Inventory
|
// Inventory
|
||||||
static void InventoryAdd(int slot, int count);
|
static void InventoryAdd(int slot, sol::optional<int> count);
|
||||||
static void InventoryRemove(int slot, int count);
|
static void InventoryRemove(int slot, sol::optional<int> count);
|
||||||
void InventoryGetCount(int slot);
|
static int InventoryGetCount(int slot);
|
||||||
void InventorySetCount(int slot, int count);
|
static void InventorySetCount(int slot, int count);
|
||||||
void InventoryCombine(int slot1, int slot2);
|
void InventoryCombine(int slot1, int slot2);
|
||||||
void InventorySeparate(int slot);
|
void InventorySeparate(int slot);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue