Bind Container item code to lua
This commit is contained in:
parent
9adab5f9bf
commit
9bdce800d8
|
@ -101,8 +101,7 @@ void Spawn::save(TiXmlElement* node)
|
||||||
for(const auto& pair : m_creatures) {
|
for(const auto& pair : m_creatures) {
|
||||||
const CreatureTypePtr& creature = pair.second;
|
const CreatureTypePtr& creature = pair.second;
|
||||||
if(!(creatureNode = new TiXmlElement(creature->getRace() == CreatureRaceNpc ? "npc" : "monster")))
|
if(!(creatureNode = new TiXmlElement(creature->getRace() == CreatureRaceNpc ? "npc" : "monster")))
|
||||||
stdext::throw_exception("oom?");
|
stdext::throw_exception("Spawn::save: Ran out of memory while allocating XML element! Terminating now.");
|
||||||
|
|
||||||
|
|
||||||
creatureNode->SetAttribute("name", creature->getName());
|
creatureNode->SetAttribute("name", creature->getName());
|
||||||
creatureNode->SetAttribute("spawntime", creature->getSpawnTime());
|
creatureNode->SetAttribute("spawntime", creature->getSpawnTime());
|
||||||
|
|
|
@ -136,7 +136,11 @@ public:
|
||||||
ItemPtr asItem() { return static_self_cast<Item>(); }
|
ItemPtr asItem() { return static_self_cast<Item>(); }
|
||||||
bool isItem() { return true; }
|
bool isItem() { return true; }
|
||||||
|
|
||||||
|
ItemVector getContainerItems() { return m_containerItems; }
|
||||||
|
ItemPtr getContainerItem(int slot) { return m_containerItems[slot]; }
|
||||||
|
void addContainerItemIndexed(const ItemPtr& i, int slot) { m_containerItems[slot] = i; }
|
||||||
void addContainerItem(const ItemPtr& i) { m_containerItems.push_back(i); }
|
void addContainerItem(const ItemPtr& i) { m_containerItems.push_back(i); }
|
||||||
|
void removeContainerItem(int slot) { m_containerItems[slot] = nullptr; }
|
||||||
void clearContainerItems() { m_containerItems.clear(); }
|
void clearContainerItems() { m_containerItems.clear(); }
|
||||||
|
|
||||||
void calculatePatterns(int& xPattern, int& yPattern, int& zPattern);
|
void calculatePatterns(int& xPattern, int& yPattern, int& zPattern);
|
||||||
|
@ -151,7 +155,7 @@ private:
|
||||||
uint16 m_serverId;
|
uint16 m_serverId;
|
||||||
uint8 m_countOrSubType;
|
uint8 m_countOrSubType;
|
||||||
stdext::packed_storage<uint8> m_attribs;
|
stdext::packed_storage<uint8> m_attribs;
|
||||||
ItemList m_containerItems;
|
ItemVector m_containerItems;
|
||||||
Color m_color;
|
Color m_color;
|
||||||
bool m_async;
|
bool m_async;
|
||||||
|
|
||||||
|
|
|
@ -463,6 +463,13 @@ void Client::registerLuaFunctions()
|
||||||
g_lua.bindClassStaticFunction<Item>("create", &Item::create);
|
g_lua.bindClassStaticFunction<Item>("create", &Item::create);
|
||||||
g_lua.bindClassStaticFunction<Item>("createOtb", &Item::createFromOtb);
|
g_lua.bindClassStaticFunction<Item>("createOtb", &Item::createFromOtb);
|
||||||
g_lua.bindClassMemberFunction<Item>("clone", &Item::clone);
|
g_lua.bindClassMemberFunction<Item>("clone", &Item::clone);
|
||||||
|
g_lua.bindClassMemberFunction<Item>("getContainerItems", &Item::getContainerItems);
|
||||||
|
g_lua.bindClassMemberFunction<Item>("getContainerItem", &Item::getContainerItem);
|
||||||
|
g_lua.bindClassMemberFunction<Item>("addContainerItem", &Item::addContainerItem);
|
||||||
|
g_lua.bindClassMemberFunction<Item>("addContainerItemIndexed", &Item::addContainerItemIndexed);
|
||||||
|
g_lua.bindClassMemberFunction<Item>("removeContainerItem", &Item::removeContainerItem);
|
||||||
|
g_lua.bindClassMemberFunction<Item>("clearContainerItems", &Item::clearContainerItems);
|
||||||
|
g_lua.bindClassMemberFunction<Item>("getContainerItem", &Item::getContainerItem);
|
||||||
g_lua.bindClassMemberFunction<Item>("setCount", &Item::setCount);
|
g_lua.bindClassMemberFunction<Item>("setCount", &Item::setCount);
|
||||||
g_lua.bindClassMemberFunction<Item>("getCount", &Item::getCount);
|
g_lua.bindClassMemberFunction<Item>("getCount", &Item::getCount);
|
||||||
g_lua.bindClassMemberFunction<Item>("getSubType", &Item::getSubType);
|
g_lua.bindClassMemberFunction<Item>("getSubType", &Item::getSubType);
|
||||||
|
|
Loading…
Reference in New Issue