• 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 What is wrong here onRemoveItem

Doggynub

LUA / C++
Joined
Sep 28, 2008
Messages
2,541
Reaction score
186
i have this
Lua:
function onRemoveItem(moveItem, tileItem, position, cid)
	local p = getThingPosition(moveItem.uid)
	local f = moveItem.uid
	
	if not isInRange(p,frompos,topos) then 
	
		doRemoveItem(getTileItemById(getThingPosition(f),moveItem.itemid).uid)
	
	end
	return true
end

and i get thins , though the item is remove , seems like it is excuting function twice or what lol :

Code:
[22:50:12.131] [Error - MoveEvents Interface]
[22:50:12.132] data/movements/scripts/tic.lua:onRemoveItem
[22:50:12.133] Description:
[22:50:12.135] data/lib/032-position.lua:2: attempt to index local 'position' (a
 boolean value)
[22:50:12.136] stack traceback:
[22:50:12.137]  data/lib/032-position.lua:2: in function 'isInRange'
[22:50:12.139]  data/movements/scripts/tic.lua:24: in function <data/movements/s
cripts/tic.lua:20>
[22:50:12.140]  [C]: in function 'doRemoveItem'
[22:50:12.141]  data/movements/scripts/tic.lua:26: in function <data/movements/s
cripts/tic.lua:20>
 
Nah, there is . But as you can see the error is in the param of 'position' which is the first isInRange param so this mean that after the item is removed the isInRange check is checked again?! And items is is tryed to be removed again?!
 
bump, once again the check is done the item is moved , then removed when outside range,
but i still get the error
 
Post full code then we can help, it says there's error at 24 and 26 line and script you posted is like 10 lines long.
 
Weird, that works fine in trap.lua
Code:
function onRemoveItem([B][COLOR="red"]item[/COLOR][/B], tile, pos)
	local [B][COLOR="red"]thingPos[/COLOR][/B] = [B][COLOR="red"]getThingPos(item.uid)[/COLOR][/B]
	if(getDistanceBetween([B][COLOR="red"]thingPos[/COLOR][/B], pos) > 0) then
		doTransformItem(item.uid, item.itemid - 1)
		doSendMagicEffect(thingPos, CONST_ME_POFF)
	end
	return true
end
 
Back
Top