Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onAttack = function(champion, weapon)
-- check if it is the ice_sword
if weapon.name == "ice_sword" then
print ("hello world")
end
end,
}Empty hand returns nil and nil.name --> crash, I guess.
I solve this with one more if:
Code: Select all
onAttack = function(champion, weapon)
if weapon == nil then
print("empty hand")
return
else
-- check if it is the ice_sword
if weapon.name == "ice_sword" then
print ("hello world")
end
end
end,
