method which makes a reference to userdataint MonsterTypeFunctions::luaMonsterTypeSkull(lua_State* L)
{
// get: monsterType:skull() set: monsterType:skull(str/constant)
MonsterType* monsterType = getUserdata<MonsterType>(L, 1);
if (monsterType) {
if (lua_gettop(L) == 1) {
lua_pushnumber(L, monsterType->info.skull);
} else {
if (isNumber(L, 2)) {
monsterType->info.skull = getNumber<Skulls_t>(L, 2);
} else {
monsterType->info.skull = getSkullType(getString(L, 2));
}
pushBoolean(L, true);
}
} else {
lua_pushnil(L);
}
return 1;
}
registerMethod(L, "MonsterType", "skull", MonsterTypeFunctions::luaMonsterTypeSkull);
static int luaMonsterTypeSkull(lua_State * L);
Where do I use this?It saysmethodwhich makes a reference to userdata
src\lua\functions\creatures\monster\monster_type_functions.cpp
C++:int MonsterTypeFunctions::luaMonsterTypeSkull(lua_State* L) { // get: monsterType:skull() set: monsterType:skull(str/constant) MonsterType* monsterType = getUserdata<MonsterType>(L, 1); if (monsterType) { if (lua_gettop(L) == 1) { lua_pushnumber(L, monsterType->info.skull); } else { if (isNumber(L, 2)) { monsterType->info.skull = getNumber<Skulls_t>(L, 2); } else { monsterType->info.skull = getSkullType(getString(L, 2)); } pushBoolean(L, true); } } else { lua_pushnil(L); } return 1; }
src\lua\functions\creatures\monster\monster_type_functions.hpp
C++:registerMethod(L, "MonsterType", "skull", MonsterTypeFunctions::luaMonsterTypeSkull); static int luaMonsterTypeSkull(lua_State * L);
think you must add it at luascripts.cppWhere do I use this?