(WIP) Curious Conundrum / CFD 2012 submission

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post 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:

SpoilerShow
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
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Redweaver
Posts: 68
Joined: Tue Dec 04, 2012 1:13 am
Location: Illinois, USA

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post 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?
My finished mods:
A Curious Conundrum http://grimrock.nexusmods.com/mods/135 also on Steam Workshop

Current WIP:
Lair of Unarak http://grimrock.nexusmods.com/mods/137
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post 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.
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post 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,
}
Last edited by Grimwold on Wed Dec 05, 2012 7:25 pm, edited 1 time in total.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post 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)
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post 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.
User avatar
Redweaver
Posts: 68
Joined: Tue Dec 04, 2012 1:13 am
Location: Illinois, USA

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post 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?
My finished mods:
A Curious Conundrum http://grimrock.nexusmods.com/mods/135 also on Steam Workshop

Current WIP:
Lair of Unarak http://grimrock.nexusmods.com/mods/137
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post 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??
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post 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!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Redweaver
Posts: 68
Joined: Tue Dec 04, 2012 1:13 am
Location: Illinois, USA

Re: (WIP) Curious Conundrum / CFD 2012 submission

Post 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! :roll:

That fixed it.
My finished mods:
A Curious Conundrum http://grimrock.nexusmods.com/mods/135 also on Steam Workshop

Current WIP:
Lair of Unarak http://grimrock.nexusmods.com/mods/137
Post Reply