Fix for Spell(int) not working in lua...

This commit is contained in:
KimLS 2013-07-03 15:20:42 -07:00
parent bccbc0f064
commit 8b8742b242
2 changed files with 10 additions and 1 deletions

View File

@ -6,6 +6,14 @@
#include "../common/spdat.h" #include "../common/spdat.h"
#include "lua_spell.h" #include "lua_spell.h"
Lua_Spell::Lua_Spell(int id) {
if(IsValidSpell(id)) {
SetLuaPtrData(&spells[id]);
} else {
SetLuaPtrData(nullptr);
}
}
int Lua_Spell::GetID() { int Lua_Spell::GetID() {
Lua_Safe_Call_Int(); Lua_Safe_Call_Int();
return self->id; return self->id;
@ -416,10 +424,10 @@ int Lua_Spell::GetDamageShieldType() {
return self->DamageShieldType; return self->DamageShieldType;
} }
luabind::scope lua_register_spell() { luabind::scope lua_register_spell() {
return luabind::class_<Lua_Spell>("Spell") return luabind::class_<Lua_Spell>("Spell")
.def(luabind::constructor<>()) .def(luabind::constructor<>())
.def(luabind::constructor<int>())
.property("null", &Lua_Spell::Null) .property("null", &Lua_Spell::Null)
.property("valid", &Lua_Spell::Valid) .property("valid", &Lua_Spell::Valid)
.def("ID", &Lua_Spell::GetID) .def("ID", &Lua_Spell::GetID)

View File

@ -16,6 +16,7 @@ class Lua_Spell : public Lua_Ptr<const SPDat_Spell_Struct>
{ {
typedef const SPDat_Spell_Struct NativeType; typedef const SPDat_Spell_Struct NativeType;
public: public:
Lua_Spell(int id);
Lua_Spell() : Lua_Ptr(nullptr) { } Lua_Spell() : Lua_Ptr(nullptr) { }
Lua_Spell(const SPDat_Spell_Struct *d) : Lua_Ptr(d) { } Lua_Spell(const SPDat_Spell_Struct *d) : Lua_Ptr(d) { }
virtual ~Lua_Spell() { } virtual ~Lua_Spell() { }