WaspUK1966 wrote: Yeh, just checked out your vid. That's what I want it to do..I`ve copied/pasted your code exactly, but it just crashes to desktop when it is supposed to remove an item and print the message.
Try adding this monster to your map, and see if it crashes.
Code: Select all
defineObject{
name = "klepto_beast",
baseObject = "zarchton",
components = {
{
class = "MonsterAttack",
name = "basicAttack",
attackPower = 10,
accuracy = 15,
cooldown = 4,
sound = "zarchton_attack",
onDealDamage = function(self, champion, damage)
local x = 3 --math.random(1,6)
local y = 1 --math.random(1,10)
local it = champion:getItem(y)
if x == 3 and it ~= nil then
hudPrint(it:getUiName().." has been absorbed!")
champion:removeItemFromSlot(y)
playSound("consume_food")
end
end,
},
}
}
By the way, what's the diff between removeItem() and removeItemFromSlot(), as they both seem to work?
george
RemoveItemFromSlot() accepts the slot# as target, deleting any item in that slot; while removeItem() accepts the item itself ~specifically and deletes it.