Page 5 of 10
Re: (WIP) Curious Conundrum / CFD 2012 submission
Posted: Wed Dec 05, 2012 7:16 pm
by msyblade
Re: monster onDie hook to open door
Okay, this one is courtesy of Komag
viewtopic.php?f=14&t=3239&hilit=ondie&start=10
His post:
But I ended up with it working now. Part of the problem I had was that I have a counter named "diecounter" and that script was also named "diecounter", and it didn't like that, something about calling a global script name or something when I tried to decrement the counter. So I renamed the script, both in the cloneObject and in the script in the editor.
Here is my monsters.lua clone:
Code: Select all
cloneObject{
model = "mod_assets/models/monsters/snail_ben.fbx",
name = "sick_snail",
baseObject = "snail",
health = 2,
sight = 1,
attackPower = 1,
onDie = function(monster)
return sickscript.snaildie()
end
}
and here is my script (named "sickscript") in the editor:
Code: Select all
function snaildie()
diecounter:decrement()
print("you got 'em")
end
I still don't understand how parameters work or quite how the monsters.lua affects this sicksnail script, but it works just how I want now - the counter decrements and in turn triggers the actions I want to happen when the snail dies.
Just change the names of the monster, script and reference to the script. and in the script entity in the editor, replace
"diecounter: decrement" to "your_door_1: open()
or if that gives you trouble, notice he uses a counter, to trigger to 0 to make things happen through connectors from there
Re: (WIP) Curious Conundrum / CFD 2012 submission
Posted: Wed Dec 05, 2012 7:18 pm
by Redweaver
I went into the monsters.lua and copied the block:
Code: Select all
cloneObject{
name = "redweaver_skeleton_warrior",
baseObject = "skeleton_warrior",
exp = 90 * xp_scale,
}
I pasted that block to the bottom of the file and modified it, thus:
Code: Select all
cloneObject{
name = "redweaver_skeleton_warriordoor",
baseObject = "skeleton_warrior",
onDie = function(self)
dungeon_secret_door_3:open()
playsound:("secret")
exp = 90 * xp_scale,
}
And now when I try to load my dungeon, I get an error. ...\My Documents\Almost Human\...\mod_assets\scripts\monsters.lua:159: '<name> expected near '('
What did I do wrong?
Re: (WIP) Curious Conundrum / CFD 2012 submission
Posted: Wed Dec 05, 2012 7:20 pm
by msyblade
did u place the 1st one in your dungeon than change its name? If so, it cannot find the definition for the one you placed, and you need to redefine it exactly.
Re: (WIP) Curious Conundrum / CFD 2012 submission
Posted: Wed Dec 05, 2012 7:24 pm
by Grimwold
Redweaver wrote:I went into the monsters.lua and copied the block:
Code: Select all
cloneObject{
name = "redweaver_skeleton_warrior",
baseObject = "skeleton_warrior",
exp = 90 * xp_scale,
}
I pasted that block to the bottom of the file and modified it, thus:
Code: Select all
cloneObject{
name = "redweaver_skeleton_warriordoor",
baseObject = "skeleton_warrior",
onDie = function(self)
dungeon_secret_door_3:open()
playsound:("secret")
exp = 90 * xp_scale,
}
And now when I try to load my dungeon, I get an error. ...\My Documents\Almost Human\...\mod_assets\scripts\monsters.lua:159: '<name> expected near '('
What did I do wrong?
looks like your onDie hook function is missing an end...
edit, also your playsound has an erroneous colon
Code: Select all
cloneObject{
name = "redweaver_skeleton_warriordoor",
baseObject = "skeleton_warrior",
onDie = function(self)
dungeon_secret_door_3:open()
playsound("secret")
end,
exp = 90 * xp_scale,
}
Re: (WIP) Curious Conundrum / CFD 2012 submission
Posted: Wed Dec 05, 2012 7:24 pm
by msyblade
scratch, check my post above. You have to make the actual function in an SE in the editor, the onDie hook, points to the lua entity you place. (Match the names)
Re: (WIP) Curious Conundrum / CFD 2012 submission
Posted: Wed Dec 05, 2012 7:27 pm
by Grimwold
msyblade wrote:scratch, check my post above. You have to make the actual function in an SE in the editor, the onDie hook, points to the lua entity you place. (Match the names)
onDie doesn't necessarily have to point to a script entity... you can write code in there.. it's just safer to do it as a SE because that way it won't crash the game when you write erroneous code.
Re: (WIP) Curious Conundrum / CFD 2012 submission
Posted: Wed Dec 05, 2012 7:33 pm
by Redweaver
New error:
Code: Select all
cloneObject{
name = "redweaver_skeleton_warriordoor",
baseObject = "skeleton_warrior",
onDie = function(monster)
dungeon_secret_door_3:open()
playsound("secret")
end
exp = 90 * xp_scale,
}
...monsters.lua:161: '}' expected (to close '{' at line 154) near 'exp'
but the "}" is very clearly there. WTF?
Re: (WIP) Curious Conundrum / CFD 2012 submission
Posted: Wed Dec 05, 2012 7:37 pm
by Grimwold
I'm just about to head out, so will be offline for a while, but if you could actually post the whole of your monsters.lua file so we can see if something is missing elsewhere. (unless of course that IS the whole of your monsters.lua file!!)
EDIT - OH.. did you miss the comma after the word end??
Re: (WIP) Curious Conundrum / CFD 2012 submission
Posted: Wed Dec 05, 2012 7:39 pm
by msyblade
Ya know, investigating this feature for redweaver is just showing me some more cool tricks, and now ideas for puzzles

LOVE this stuff!
Thanx grim, didn't know that!
Re: (WIP) Curious Conundrum / CFD 2012 submission
Posted: Wed Dec 05, 2012 7:41 pm
by Redweaver
Grimwold wrote:I'm just about to head out, so will be offline for a while, but if you could actually post the whole of your monsters.lua file so we can see if something is missing elsewhere. (unless of course that IS the whole of your monsters.lua file!!)
EDIT - OH.. did you miss the comma after the word end??
A ","!
I just f***ing LOVE programming!
That fixed it.