aberos
New Member
- Joined
- Feb 26, 2014
- Messages
- 17
- Reaction score
- 0
I wonder how do I getCreatureName read the true name of the creature whenever setcreaturename use the function that changes the name of the creature? getCreatureName reading this because the modified real name and not name
Here the function I use:
int32_t LuaScriptInterface::luaDoCreatureSetNick(lua_State* L)
{
//doCreatureSetNick(cid, newName)
std::string newName = popString(L);
ScriptEnviroment* env = getEnv();
Creature* creature;
if(creature = env->getCreatureByUID(popNumber(L))){
Monster* monster = (Monster*)creature;
monster->name = newName;
lua_pushboolean(L, true);
}
else{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
here getCreatureName
int32_t LuaScriptInterface::luaGetCreatureName(lua_State* L)
{
//getCreatureName(cid)
ScriptEnviroment* env = getEnv();
if(Creature* creature = env->getCreatureByUID(popNumber(L)))
lua_pushstring(L, creature->getName().c_str());
else
{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
Here the function I use:
int32_t LuaScriptInterface::luaDoCreatureSetNick(lua_State* L)
{
//doCreatureSetNick(cid, newName)
std::string newName = popString(L);
ScriptEnviroment* env = getEnv();
Creature* creature;
if(creature = env->getCreatureByUID(popNumber(L))){
Monster* monster = (Monster*)creature;
monster->name = newName;
lua_pushboolean(L, true);
}
else{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
here getCreatureName
int32_t LuaScriptInterface::luaGetCreatureName(lua_State* L)
{
//getCreatureName(cid)
ScriptEnviroment* env = getEnv();
if(Creature* creature = env->getCreatureByUID(popNumber(L)))
lua_pushstring(L, creature->getName().c_str());
else
{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
Last edited: