Jaki Maoh
Member
- Joined
- Sep 13, 2017
- Messages
- 52
- Reaction score
- 12
Hello Community!
I can't figure out what is wrong with the script.
The idea is to add back (to the original tile) a small stone after x time with addEvent function.
The problems:
1 when the item is created, it spawns without the aID needed to activate the onRemoveItem function.
2 when the player moves the original item from tile, it holds the aID as an attribute and creates a new stone whenever it is moved (infinite times).
How should I approach this, any ideas?
Thanks in advance,
Jaki
I can't figure out what is wrong with the script.
Lua:
local resp_stone = 5000
local aid_small = 50001
local function addbacksmall()
-- local stoner = doCreateItem(1294, 1, position) -- commented because does not work here
local stoner = Game.createItem(1294, 1, position)
stoner:setActionId(aid_small)
end
function onRemoveItem(item, tile, position)
if item.actionid == aid_small then
position:sendMagicEffect(1) -- just to check if the script is responding
-- item:removeAttribute(ACTIONID) -- trying to remove the aID after the item is moved (failing miserably)
-- addEvent(function() doCreateItem(1294, 1, position) end, 5000) -- in one line i could make it respawn, but not attribute the action ID
addEvent(addbacksmall, resp_stone) -- trying to make a local function to add the aID when respawning the small stone to the map.
end
return true
end
The problems:
1 when the item is created, it spawns without the aID needed to activate the onRemoveItem function.
2 when the player moves the original item from tile, it holds the aID as an attribute and creates a new stone whenever it is moved (infinite times).
XML:
<movevent event="RemoveItem" actionid="50001" script="small_stones.lua" />
<!-- <movevent event="RemoveItem" itemid="1294" script="small_stones.lua" /> -->
How should I approach this, any ideas?
Thanks in advance,
Jaki