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

Transform item request.

sibbe

New Member
Joined
Oct 28, 2007
Messages
51
Reaction score
0
I posted this on otfans but was not successful with getting it to work, so I'll try here.

The Forgotten Server - Version 0.2 <Mystic Spitit>.
Tibia 8.4


I want a script that transforms boots of haste + Soft boots + Steel boots into Golden boots when a lever is hit.

Here is a picture of how it could work out:
namnlsj.jpg


This is what somebody gave me to use:
-- CONFIG --
local itemID = 2358 -- Item ID1 required on coal basin
local itemId = 2646 -- Item ID2 required on coal basin
local item_ID = 6132 -- Item ID3 required on coal basin
local newItem = 5462 -- Item ID of the new item
local itemPOS = {x=135, y=763, z=12, stackpos=1} -- Item position1 on coal basin
local itemPos = {x=136, y=763, z=12, stackpos=1} -- Item position2 on coal basin
local itemPos = {x=137, y=763, z=12, stackpos=1} -- Item position3 on coal basin
local newPos = {x=136, y=762, z=12} -- Position of where the new item comes
local backTime = 1 -- How many minutes till the switch gets back by itself
-- CONFIG END --

function onUse(cid, item, frompos, item2, topos)

if item.itemid == 1945 and item.uid == 10010 then
local item_one = getTileItemById(itemPOS, itemID)
local item_two = getTileItemById(itemPos, itemId)
local item_three = getTileItemById(item_POS, item_ID)
if item_one.uid > 0 and item_two.uid > 0 and item_three.uid > 0 then
doSendMagicEffect(itemPOS, 13)
doSendMagicEffect(itemPos, 13)
doSendMagicEffect(item_POS, 13)
doRemoveItem(item_one.uid, 1)
doRemoveItem(item_two.uid, 1)
doRemoveItem(item_three.uid, 1)

doCreateItem(newItem,1,newPos)
doSendMagicEffect(newPos, 14)
doPlayerSendTextMessage(cid,22,"You have transformed all the boots into ultimate boots!")
doSendMagicEffect(getPlayerPosition(cid), 13)

doTransformItem(item.uid, 1946)

addEvent(switchBack, backTime * 60 * 1000, frompos)
else
doPlayerSendCancel(cid,"You have to put the item on the basin.")
end
end
return TRUE
end

function wallBack(x)
doTransformItem(3000, 1945)
end

This is the errors I recieve:
[27/02/2009 15:13:37] Lua Script Error: [Action Interface]
[27/02/2009 15:13:37] data/actions/scripts/boots.luanUse

[27/02/2009 15:13:37] attempt to index a nil value
[27/02/2009 15:13:37] stack traceback:
[27/02/2009 15:13:37] [C]: in function 'getTileItemById'
[27/02/2009 15:13:37] data/actions/scripts/boots.lua:18: in function <data/actions/scripts/boots.lua:13>

Somebody told me to add:
function getTileItemById(pos, itemid)
pos.stackpos = 0
local thing = getThingfromPos(pos)
while thing.uid > 0 and thing.itemid ~= itemid do
pos.stackpos = pos.stackpos + 1
thing = getThingfromPos(pos)
end

return thing
end

in global.lua but then I recieve:
[27/02/2009 16:53:35] Lua Script Error: [Action Interface]
[27/02/2009 16:53:35] data/actions/scripts/transformboots.luanUse

[27/02/2009 16:53:35] data/global.lua:532: attempt to index local 'pos' (a nil value)
[27/02/2009 16:53:35] stack traceback:
[27/02/2009 16:53:35] data/global.lua:532: in function 'getTileItemById'
[27/02/2009 16:53:35] data/actions/scripts/transformboots.lua:18: in function <data/actions/scripts/transformboots.lua:13>

I tried adding it into functions.lua, but it won't work either.
 
local itemPos = {x=137, y=763, z=12, stackpos=1} -- Item position3 on coal basin

I guess that one (the last) is supposed to be called item_POS
 
local itemPos = {x=137, y=763, z=12, stackpos=1} -- Item position3 on coal basin

I guess that one (the last) is supposed to be called item_POS

Didnt make a difference, same error.

I suspect my server doesent support the getTileItemById function. Doesent seem to be any way to go around this..
 
Yes there is, actually the function somebody told you to add was made by me, which was a way around its non-existance in older servers.

The error is saying the position you have speciefied is NIL (does not exist)... And I can see in the code that is true.
 
PHP:
-- CONFIG --
local itemId1 = 2358 -- Item ID1 required on coal basin
local itemId2 = 2646 -- Item ID2 required on coal basin
local itemId3 = 6132 -- Item ID3 required on coal basin
local newItem = 5462 -- Item ID of the new item
local itemPos1 = {x=135, y=763, z=12, stackpos=1} -- Item position1 on coal basin
local itemPos2 = {x=136, y=763, z=12, stackpos=1} -- Item position2 on coal basin
local itemPos3 = {x=137, y=763, z=12, stackpos=1} -- Item position3 on coal basin
local newPos = {x=136, y=762, z=12} -- Position of where the new item comes
local backTime = 1 -- How many minutes till the switch gets back by itself
-- CONFIG END --
function wallBack(x)
doTransformItem(x.uid, 1945)
end 
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 1945 and item.uid == 10010 then
if(getThingfromPos(itemPos1).itemid == itemId1 and getThingfromPos(itemPos2).itemid == itemId2 and  getThingfromPos(itemPos3).itemid == itemId3)then
doSendMagicEffect(itemPos1, 13)
doSendMagicEffect(itemPos2, 13)
doSendMagicEffect(itemPos3, 13)
doRemoveItem(getThingfromPos(itemPos1).uid, 1)
doRemoveItem(getThingfromPos(itemPos2).uid, 1)
doRemoveItem(getThingfromPos(itemPos3).uid, 1)
doCreateItem(newItem,1,newPos)
doSendMagicEffect(newPos, 14)
doPlayerSendTextMessage(cid,22,"You have transformed all the boots into ultimate boots!")
doSendMagicEffect(getPlayerPosition(cid), 13)
doTransformItem(item.uid, 1946)
addEvent(switchBack, backTime * 60 * 1000, item)
else
doPlayerSendCancel(cid,"You have to put the item on the basin.")
end
end
return TRUE
end
look this, but not tested ;d
 
PHP:
-- CONFIG --
local itemId1 = 2358 -- Item ID1 required on coal basin
local itemId2 = 2646 -- Item ID2 required on coal basin
local itemId3 = 6132 -- Item ID3 required on coal basin
local newItem = 5462 -- Item ID of the new item
local itemPos1 = {x=135, y=763, z=12, stackpos=1} -- Item position1 on coal basin
local itemPos2 = {x=136, y=763, z=12, stackpos=1} -- Item position2 on coal basin
local itemPos3 = {x=137, y=763, z=12, stackpos=1} -- Item position3 on coal basin
local newPos = {x=136, y=762, z=12} -- Position of where the new item comes
local backTime = 1 -- How many minutes till the switch gets back by itself
-- CONFIG END --
function wallBack(x)
doTransformItem(x.uid, 1945)
end 
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 1945 and item.uid == 10010 then
if(getThingfromPos(itemPos1).itemid == itemId1 and getThingfromPos(itemPos2).itemid == itemId2 and  getThingfromPos(itemPos3).itemid == itemId3)then
doSendMagicEffect(itemPos1, 13)
doSendMagicEffect(itemPos2, 13)
doSendMagicEffect(itemPos3, 13)
doRemoveItem(getThingfromPos(itemPos1).uid, 1)
doRemoveItem(getThingfromPos(itemPos2).uid, 1)
doRemoveItem(getThingfromPos(itemPos3).uid, 1)
doCreateItem(newItem,1,newPos)
doSendMagicEffect(newPos, 14)
doPlayerSendTextMessage(cid,22,"You have transformed all the boots into ultimate boots!")
doSendMagicEffect(getPlayerPosition(cid), 13)
doTransformItem(item.uid, 1946)
addEvent(switchBack, backTime * 60 * 1000, item)
else
doPlayerSendCancel(cid,"You have to put the item on the basin.")
end
end
return TRUE
end
look this, but not tested ;d

Your script worked for me.

Thankyou!
 
Back
Top