vitorbertolucci
Member
- Joined
- Apr 15, 2014
- Messages
- 75
- Reaction score
- 18
I need to clone an item and it must be in a way that all these item's attributes get copied. Is there any way to do so? (even if its done with c++)
thanks
thanks
I need to clone an item and it must be in a way that all these item's attributes get copied. Is there any way to do so? (even if its done with c++)
thanks
I don't know if you know, it's not possible to create two identical items ( sprite ); but you can create a copy of the special item , this it what do you want ???
Im using tfs 0.4 and as far as I know there are no similar functions in this version... I will take a look at the one made for 1.x anyway to see if I can use somethingcant you just use item:clone() in tfs 1.x?
Could you be more specific.I need to clone an item and it must be in a way that all these item's attributes get copied. Is there any way to do so? (even if its done with c++)
thanks
Could you be more specific.
So basically you want to intentionally dupe items.Lets supose a player have a ring with 86 seconds of duration and I want to make an exact copy of this ring. Which means I want to create another item with the same ID and the same duration attribute.
Or a player have an armor with an special description and I want to make an exact copy of this armor.
So what I want is a generic way to copy ALL attributes of an item so I can create another one with the same attributes.
int32_t LuaScriptInterface::luaDoCreateItemEx(lua_State* L)
{
//doCloneItem(uid)
ScriptEnviroment* env = getEnv();
Item* item = env->getItemByUID(popNumber(L));
if(!item) {
errorEx(getError(LUA_ERROR_ITEM_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
Item* newItem = item->clone();
if(!newItem) {
errorEx(getError(LUA_ERROR_ITEM_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
newItem->setParent(VirtualCylinder::virtualCylinder);
env->addTempItem(env, newItem);
lua_pushnumber(L, env->addThing(newItem));
return 1;
}