• 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!

Lua How does "doTransformItem" work?

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
Here is my script that I was just messing around with, what I wanted it to do was to just change a tile at a certain location to another id, example would be to pull a lever to make a bridge appear, but my script just did nothing when I pulled the lever. Yes, I did search around (and yes I did put it in actions.lua and the lever has the right unique id, thats not the problem) and I did try so there it is:

pohlever.lua
Code:
function onUse(cid, item, frompos, item2, topos)
	doTransformItem(item.uid, item.itemid + 1)
	doTransformItem( cid, 103, { x = 1377, y = 1088, z = 7 }, 407, { x = 1377, y = 1088, z = 7} )
	if item.actionid ~= 0 then
		doSetItemActionId(item.uid, item.actionid)
	end
	doDecayItem(item.uid)
	return true
end

I just figured cid, item, frompos, item2, topos was how it worked but I dont know....

Here is another attempt that failed and just did nothing

Code:
function onUse(cid, item, frompos, item2, topos) 
gatepos = {x=1377, y=1088, z=7, stackpos=1} 
getgate = getThingfromPos(gatepos) 

if item.uid == 1017 and item.itemid == 1945 and getgate.itemid == 103 then 
doRemoveItem(getgate.uid,1)
doCreateItem(407,1,gatepos) 
doTransformItem(item.uid,item.itemid+1) 
elseif item.uid == 1017 and item.itemid == 1946 and getgate.itemid == 407 then 
doCreateItem(103,1,gatepos) 
doTransformItem(item.uid,item.itemid-1) 
else 
doPlayerSendCancel(cid,"Sorry, not possible.") 
end 
return 1 
end

Here is yet another attempt that does NOTHING

Code:
local pos, e = {x=1377, y=1088, z=7}, 0
local f = function(p)
	doCreateItem(407, 1, pos)
	doTransformItem(getTileItemById(p, 1946).uid, 1945)
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		doRemoveItem(getTileItemById(pos, 103).uid)
		e = addEvent(f, 5 * 60 * 1000, fromPosition)
		doTransformItem(item.uid, 1946)
	else
		stopEvent(e)
		e = 0
		f(fromPosition)
	end
	return true
end

What am I doing wrong? Is it something obvious that I'm not seeing?
 
Last edited:
Back
Top