• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[request] Make an item transform back into another after X amount of time

Falazen

New Member
Joined
Feb 18, 2008
Messages
82
Reaction score
2
Greetings. Is it possible to make certain items transform back into another after X amount of time? I need to have it decay into something of my choosing, for my script breaks an item down 4 times, and that fourth item needs to be reverted back to the first item. I think its some form of "addevent" but I can't quite land on it.

Any help, please, is HIGHLY appreciated. I've been searching for a good 3+ hours and I'm just down on luck.

Please help. Thanks in advance.

-Falazen.
 
hmm look this:

PHP:
function transformBack(x)
 return doTransformItem(x[1].uid, x[2])
end

in script add:
PHP:
addEvent(transformBack, HOW_MANY_SECONDS*1000, {item, TRANSFORM_BACK_ITEM_ID})
:)
 
hmm look this:

PHP:
function transformBack(x)
 return doTransformItem(x[1].uid, x[2])
end

in script add:
PHP:
addEvent(transformBack, HOW_MANY_SECONDS*1000, {item, TRANSFORM_BACK_ITEM_ID})
:)


Hmm. It isn't working. When the item is supposed to transform back, I get an error in my console saying that the item isnt found or some garbage.

What am I doing wrong?

Thanks in advance ;)
 
You can do it only via items.xml + doDecayItem(uid)

ex.
<attribute key="decayTo" value="481"/>
<attribute key="duration" value="300"/>

and doDecayItem(item.uid)

You can look at data/actions/scripts/other/doors.lua for example usage.
 
You can do it only via items.xml + doDecayItem(uid)

ex.
<attribute key="decayTo" value="481"/>
<attribute key="duration" value="300"/>

and doDecayItem(item.uid)

You can look at data/actions/scripts/other/doors.lua for example usage.

If its only possible via Items.xml, could you explain why it doesn't work on TFS? (not being a smart a#%). I've done that for the latest TFS and it doesn't work. :(
 
Idk what do you want, but i found a function that transforms item A into item B for X ammount of time, then comes back to item A again: Check in the-other-forum for the function "dodecayitemto" made by AGS.

Another way is to check the script "increaseitemid" or "decreaseitemid"; That one works for the doors, lights and other things.

The functions "dodecayitem", "dotransformitem",and "doremoveitem" and "docreateitem" together may also work...

If you wanna do it with movements instead of actions (like the rings, soft boots, etc.) check items.xml, movements.xml and the movements scripts.

More info in your "LUA_FUNCTIONS" file, in the /yourserver/docs directory.

If you wish more specific help, plz post what you need exactly and the script you're trying to do.
 
Well, here is what I'm dealing with.

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerItemCount(cid, 2144) > 0 then
doPlayerRemoveItem(cid, 2144, 1)
doSendMagicEffect(toPosition, CONST_ME_HITBYFIRE)
doTransformItem(itemEx.uid, 8686)
doPlayerSendCancel(cid, 'You place the coal into the furnace and light it. It burns brilliantly.')
else
doPlayerSendCancel(cid, 'You need at least 1 coal to light the furnace.')
end
 return 0
end

I need it that once it transforms into item ID 8686, to transform BACK into 8687 after X amount of time. (8687 is the unlit furnace).

If someone could throw that in together for me, that would be just fantastic.
 
PHP:
seconds = 60 -- how mnay seconds to transform back?: D
decay_Item = 6666 -- item id of item when transform back. :)

function transformBack(x)
 return doTransformItem(x[1].uid, x[2])
end  

function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerItemCount(cid, 2144) > 0 then
doPlayerRemoveItem(cid, 2144, 1)
doSendMagicEffect(toPosition, CONST_ME_HITBYFIRE)
doTransformItem(itemEx.uid, 8686)
addEvent(transformBack, seconds*1000, {itemEx, decay_Item})
doPlayerSendCancel(cid, 'You place the coal into the furnace and light it. It burns brilliantly.')
else
doPlayerSendCancel(cid, 'You need at least 1 coal to light the furnace.')
end
 return 0
end
 
PHP:
seconds = 60 -- how mnay seconds to transform back?: D
decay_Item = 6666 -- item id of item when transform back. :)

function transformBack(x)
 return doTransformItem(x[1].uid, x[2])
end  

function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerItemCount(cid, 2144) > 0 then
doPlayerRemoveItem(cid, 2144, 1)
doSendMagicEffect(toPosition, CONST_ME_HITBYFIRE)
doTransformItem(itemEx.uid, 8686)
addEvent(transformBack, seconds*1000, {itemEx, decay_Item})
doPlayerSendCancel(cid, 'You place the coal into the furnace and light it. It burns brilliantly.')
else
doPlayerSendCancel(cid, 'You need at least 1 coal to light the furnace.')
end
 return 0
end

This is what comes up in the server log.

PHP:
[11/03/2009 18:51:57] Lua Script Error: [Action Interface] 
[11/03/2009 18:51:57] in a timer event called from: 
[11/03/2009 18:51:57] data/actions/scripts/mining/light_stove.lua:onUse

[11/03/2009 18:51:57] luaDoTransformItem(). Item not found

Ehhhh...? :(
 
Thanks for the help everyone, but I've figured it out myself. I made a script (even through a grueling 3 days of doing so >.>... Trial and error.) that sets it back to its original ID. However, this would not have been done without the help of all your knowledge. Without showing me scripts that MAY work, I wouldn't have been able to complete this one. As thanks, I'm giving a rep point to everyone that helped. (including you Darth, I see you reading this.)

Thanks again everyone! :)
 
PHP:
seconds = 60 -- how mnay seconds to transform back?: D
decay_Item = 6666 -- item id of item when transform back. :)

function transformBack(x)
 return doTransformItem(x[1], x[2])
end  

function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerItemCount(cid, 2144) > 0 then
doPlayerRemoveItem(cid, 2144, 1)
doSendMagicEffect(toPosition, CONST_ME_HITBYFIRE)
addEvent(transformBack, seconds*1000, {itemEx.uid, decay_Item})
doPlayerSendCancel(cid, 'You place the coal into the furnace and light it. It burns brilliantly.')
doTransformItem(itemEx.uid, 8686)
else
doPlayerSendCancel(cid, 'You need at least 1 coal to light the furnace.')
end
 return 0
end
now? :p
 
Im trying to fix this to my poi script

this is my error i get (i use TFS 0.3.2)
Code:
[01/06/2009 22:57:01] Lua Script Error: [Action Interface] 
[01/06/2009 22:57:01] data/actions/scripts/poi/oilswitch.lua:onUse

[01/06/2009 22:57:01] data/actions/scripts/poi/oilswitch.lua:18: attempt to index global 'itemEx' (a nil value)
[01/06/2009 22:57:01] stack traceback:
[01/06/2009 22:57:01] 	data/actions/scripts/poi/oilswitch.lua:18: in function <data/actions/scripts/poi/oilswitch.lua:8>

Edit: i did make it so the lever switched to the item i want on a other place how do i fix so the item will be changed on other place?
MY Script i use

Code:
seconds = 60 -- how mnay seconds to transform back?: D
decay_Item = 493 -- item id of item when transform back. :)

function transformBack(x)
 return doTransformItem(x[1], x[2])
end 

function onUse(cid, item, frompos, item2, topos)
bridge = {x=32801, y=32336, z=11, stackpos=1}
getbridge = getThingfromPos(bridge) 
splash = {x=32800, y=32339, z=11, stackpos=1}
oil = getThingfromPos(splash)

if item.uid == 3040 and item.itemid == 1945 and oil.itemid == 2016 and oil.type == 11 and getbridge.uid == 0 then
   doTransformItem(item.uid,item.itemid +1)
  	 doCreateItem(5770,1,bridge)
   	doSendMagicEffect(splash,13)
	addEvent(transformBack, seconds*1000, {itemEx.uid, decay_Item}) 
else
doCreatureSay(cid, "The lever is creaking and rusty.", 19)
end
end
 
Last edited:
Back
Top