Arn
Member
- Joined
- Mar 8, 2010
- Messages
- 282
- Reaction score
- 18
Hi, I'm having a problem. I'm checking several positions for creatures, and checking their names. Now, I realize that of the tiles checked, the vast majority will not contain the creature I'm looking for. Thats fine. I'm able to detect the creature correctly.
However, my problem is that an LUA error is generated each time I do this. Is there any way to catch or ignore LUA errors?
topleft is a position that works correctly.
the error:
- - - Updated - - -
Nevermind. Solution is to put isNpc or isMonster infront to check. That stops the error. So my solution is now:
if creature.isNpc and getCreatureName(creature.uid):lower() == npcName:lower() then
- - - Updated - - -
Edit again. isNpc doesn't work, but creature.type == 3 seems to work, now my script is working!
However, my problem is that an LUA error is generated each time I do this. Is there any way to catch or ignore LUA errors?
topleft is a position that works correctly.
Code:
local creature = getTopCreature(topleft)
if getCreatureName(creature.uid):lower() == npcName:lower() then
doCreatureSay(cid, "found", TALKTYPE_SAY)
end
the error:
Code:
[28/06/2012 13:42:45] Lua Script Error: [Spell Interface]
[28/06/2012 13:42:45] in a timer event called from:
[28/06/2012 13:42:45] data/spells/scripts/runesmith/runebomb.lua:onCastSpell
[28/06/2012 13:42:45] LuaScriptInterface::luaGetCreatureName(). Creature not found
[28/06/2012 13:42:45] stack traceback:
[28/06/2012 13:42:45] [C]: in function 'getCreatureName'
[28/06/2012 13:42:45] data/spells/scripts/runesmith/runebomb.lua:17: in function <data/spells/scripts/runesmith/runebomb.lua:1>
[28/06/2012 13:42:45] Lua Script Error: [Spell Interface]
[28/06/2012 13:42:45] in a timer event called from:
[28/06/2012 13:42:45] data/spells/scripts/runesmith/runebomb.lua:onCastSpell
[28/06/2012 13:42:45] data/spells/scripts/runesmith/runebomb.lua:17: attempt to index a boolean value
[28/06/2012 13:42:45] stack traceback:
[28/06/2012 13:42:45] [C]: in function '__index'
[28/06/2012 13:42:45] data/spells/scripts/runesmith/runebomb.lua:17: in function <data/spells/scripts/runesmith/runebomb.lua:1>
- - - Updated - - -
Nevermind. Solution is to put isNpc or isMonster infront to check. That stops the error. So my solution is now:
if creature.isNpc and getCreatureName(creature.uid):lower() == npcName:lower() then
- - - Updated - - -
Edit again. isNpc doesn't work, but creature.type == 3 seems to work, now my script is working!