There seems to be a bug with passing parameters from the object hooks to level scripts. I tried to subtract certain integer values from script variable each time when party receives damage. This is how my scripts look like:
Object hook:
Code: Select all
-- mod_assets/scripts/party.lua
-- This file is included in init.lua as the first thing after standard_assets.lua
cloneObject{
name = "party",
baseObject = "party",
onDamage = function(champion, damage, type)
-- 34 is a magic number for testing purposes only.
-- In the end I want to be able to pass 'damage' here.
scoreLua:addScore(34)
return true
end,
}
Dungeon script:
Code: Select all
-- scoreLua defined within the first level of the dungeon
score = 100000
function addScore(dummy, val)
print("Printing")
print(dummy) -- prints "table 0xmemory-address"
print(val) -- prints correct value passed from the hook (34 in this case)
end
Now, all would be ok because it actually allows to pass the number from the hook to the dungeon function. Unfortunately this function can be called only
once, or twice if I get lucky. The next call will crash the game. What's even worse is that the crash window is the standard Windows CTD and not the neat LUA stack trace.
I think we're dealing here with either a bug in the game engine or with LUA engine limitation. I hope it's the first one.
EDIT:
I was wrong about CTDs. See my post which is after the next one.