summaryrefslogtreecommitdiffstats
path: root/source/LuaItems.h
blob: f6f06c90335cc6e68c98c7b4cffaae2f1122c6f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

// LuaItems.h

// Interfaces to the cLuaItems class representing a wrapper class that allows Lua to access and manipulate cItems





#pragma once

#include "Item.h"





// tolua_begin
class cLuaItems
{
public:
	// tolua_end
	// The constructor is not to be Lua-exported, Lua cannot make use of this object
	cLuaItems(cItems & a_Items) :
		m_Items(a_Items)
	{
	}
	
	// tolua_begin
	cItem & Get   (int a_Idx) {return m_Items[a_Idx]; }
	void    Set   (int a_Idx, const cItem & a_Item) {m_Items[a_Idx] = a_Item; }
	void    Add   (const cItem & a_Item) {m_Items.push_back(a_Item); }
	void    Delete(int a_Idx) {m_Items.erase(m_Items.begin() + a_Idx); }
	void    Clear (void) {m_Items.clear(); }
	int     Size  (void) {return m_Items.size(); }

	void    Add   (ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemHealth)
	{
		m_Items.push_back(cItem(a_ItemType, a_ItemCount, a_ItemHealth));
	}
	
	void    Set   (int a_Idx, ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemHealth)
	{
		m_Items[a_Idx] = cItem(a_ItemType, a_ItemCount, a_ItemHealth);
	}
	
protected:
	cItems & m_Items;
} ;
// tolua_end