pimmie2333
New Member
- Joined
- Feb 12, 2008
- Messages
- 24
- Reaction score
- 1
Very nice script! Rep++
How i can make it without "new description"?
Donemonster.h
find
then add this under public:Code:class Monster : public Creature
findCode:std::string name;
replace withCode:virtual const std::string& getName() const {return mType->name;}
Code:virtual const std::string& getName() const {return name;}
monster.cpp
find
then add the following code right above isIdle = true;Code:Monster::Monster(MonsterType* _mType):
Code:name = _mType->name;
luascript.h
add near the similar lines
Code:static int32_t luaSetCreatureName(lua_State* L);
luascript.cpp
add near similar lines
add near similar linesCode://setCreatureName(cid, name) lua_register(m_luaState, "setCreatureName", LuaInterface::luaSetCreatureName);
Code:int32_t LuaInterface::luaSetCreatureName(lua_State* L) { //setCreatureName(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; }
An example for this would be:
Code:function createFakeTroll(spawnPos) local farAwayPos = {x = 100, y = 100, z = 7} --Change This!! local monster = doCreateMonster("Troll", farAwayPos) setCreatureName(monster, "FakeTroll") doTeleportThing(monster, spawnPos) end