krafttomten
Well-Known Member
Okay so here's the thing. I have made an altar that turns life crystals into life rings when the crystal is moved onto the altar. Problem is that even if I add more than one life crystal, I will only get one life ring in return.
Now, I know that I have no code to count items visible here, but that is because I have no idea how to do that. I have compared the code to the dough into bread code that can turn X dough into X bread with no problem. Here is that code, just for reference:
As you can see, that code does not seem to count the items. So the counting must happen somewhere else, right? I can't find it though. I'm thinking the "moveitem" variable contains an amount but I do not know how to access it. Like, moveitem:count() or whatever..
So.. if anyone can help me out I'd appreciate it a lot!
XML:
<movevent event="AddItem" tileitem="1" actionid="10003" script="lifecrystal.lua" />
Lua:
-- This is the broken lifecrystal code
function onAddItem(moveitem, tileitem, position)
if moveitem:getId() == 2177 then
moveitem:transform(2168)
position:sendMagicEffect(CONST_ME_MAGIC_GREEN)
position:sendMagicEffect(CONST_ME_BUBBLES)
return true
end
end
Now, I know that I have no code to count items visible here, but that is because I have no idea how to do that. I have compared the code to the dough into bread code that can turn X dough into X bread with no problem. Here is that code, just for reference:
Lua:
-- This is the working bread code
function onAddItem(moveitem, tileitem, position)
if moveitem:getId() == 2693 then
moveitem:transform(2689)
position:sendMagicEffect(CONST_ME_HITBYFIRE)
elseif moveitem:getId() == 6277 then
moveitem:transform(2687, 12)
position:sendMagicEffect(CONST_ME_HITBYFIRE)
end
return true
end
As you can see, that code does not seem to count the items. So the counting must happen somewhere else, right? I can't find it though. I'm thinking the "moveitem" variable contains an amount but I do not know how to access it. Like, moveitem:count() or whatever..
So.. if anyone can help me out I'd appreciate it a lot!