Script Help

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
LocalFire
Posts: 261
Joined: Thu Feb 21, 2013 1:16 am
Location: Auckland, New Zealand

Re: Script Help

Post by LocalFire »

Thanks thats really helpful :)

I've had some puzzles in mind but couldn't get them to work, so this will make it easier to make better puzzles
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: Script Help

Post by Ryeath_Greystalk »

Getting away from the actual script / puzzle your working on, I just wanted to add something I like to do when creating stuff.

I like to use hudPrint() as a type of debug to keep track of variables at each step of the process.

For example if you have a puzzle where you push a button 3 times to open a door (i.e. counter decrements from 3 to 0 then linked to door). I put a hudPrint() in so I can actually see if the counter is decrementing.
Note, obviously this only works with a script, but if you need you can add a script with the only function on printing the counter, or lever state, or door opened or closed etc. I find it very helpful in seeing what is going on and I have solved many mysteries that way.

Hope it helps.
User avatar
LocalFire
Posts: 261
Joined: Thu Feb 21, 2013 1:16 am
Location: Auckland, New Zealand

Re: Script Help

Post by LocalFire »

Actually I had a setup like that with a button that told me what each counter was at, so when I got it working I knew which parts were causing the problem

In the end the puzzle works for the right answer, but even trying all the above scripts it would randomly change the counters value when a wrong answer was given, since the result was different every time I couldn't figure out what was the cause. In the end I went with a reset switch, it works fine once the puzzle is reset, and should help anyone who gets stuck

Might keep playing with it, just to see if I can get it working perfectly
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443
Alcator
Posts: 37
Joined: Fri Apr 13, 2012 9:59 am

Re: Script Help

Post by Alcator »

Just to make sure -- are all the shield-holders set to "Activate always" ?

you could use print("1: "..s1:isActivated().." 2: "..s2:isActivated().. (etc.) )
to always print what is the status of the holders as seen by the game.

You could also use
print(tostring(counter1:getValue())) to see what is the internal value of each counter -- this way, you will be able to exactly pinpoint what happens when the shields are added/removed, and pinpoint where the bug is in your code.
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Script Help

Post by Komag »

I found print much more useful than hudPrint because it sticks around, and you can see a lot more lines :)
Finished Dungeons - complete mods to play
Ryeath_Greystalk
Posts: 366
Joined: Tue Jan 15, 2013 3:26 am
Location: Oregon

Re: Script Help

Post by Ryeath_Greystalk »

Komag wrote:I found print much more useful than hudPrint because it sticks around, and you can see a lot more lines :)
I haven't figured that out yet. I think I read somewhere about changing a config file but I get a bit skittish about changing the actual game files.
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Script Help

Post by Grimfan »

Nice scripting going on around here. Love your shields and other bits and pieces LocalFire! :D
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Script Help

Post by Komag »

It's extremely failsafe to do it, no risk at all really, and very beneficial, there's no way I could have made my mods without it.
Finished Dungeons - complete mods to play
User avatar
LocalFire
Posts: 261
Joined: Thu Feb 21, 2013 1:16 am
Location: Auckland, New Zealand

Re: Script Help

Post by LocalFire »

Thanks guys i'm using (tostring(counter1:getValue())) to check the counters, the master counter works and the individual counters work for the right answer, the problem happens when a wrong answer is given

As expected a wrong shield won't activate the script and the counter resets to 2, but when the right answer is put in after the decrease is 1 most of the time (as opposed to 2) and sometimes 3, all without changing anything, same setup, same conditions, different result. I put in a reset button that fixes the problem, after a reset everything seems fine.

And Grimfan thanks I made them just as an experiment to see if I could, I'm quite happy with how they turned out
My Dungeons
Paths of the Earth: viewtopic.php?f=14&t=5136
Beneath the Sands: viewtopic.php?f=14&t=5216
Videos: viewtopic.php?f=11&t=5443
Post Reply