i guess i'm hopeless at scripting :D

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
azidahaka
Posts: 91
Joined: Fri Apr 13, 2012 9:48 pm

i guess i'm hopeless at scripting :D

Post by azidahaka »

I did many complex scripts but i get stuck in the most stupid things :P

Code: Select all

function caterina()
if dungeon_secret_button_small_4:toggle() == true and
dungeon_secret_button_small_3:toggle() == true
then
dungeon_door_metal_2:open()
else
dungeon_door_metal_2:closed()
end
end
so it check if both switches have been toggled and should open the door afterwards. What do i do wrong?
SpacialKatana
Posts: 163
Joined: Fri Sep 14, 2012 6:20 pm

Re: i guess i'm hopeless at scripting :D

Post by SpacialKatana »

'closed' should be 'close'
azidahaka
Posts: 91
Joined: Fri Apr 13, 2012 9:48 pm

Re: i guess i'm hopeless at scripting :D

Post by azidahaka »

it's not that the problem it says
attempt to call method toggle a nil value
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: i guess i'm hopeless at scripting :D

Post by Komag »

there is no script method like that to check if a button has been toggled. the toggle script is to toggle the thing, not check whether it has been toggled. you'll want to connect the buttons to a counter of 2 and have that open the door (with each button set to "once" to avoid cheating. or you could use levers and check the lever states in a script
Finished Dungeons - complete mods to play
User avatar
Kuningas
Posts: 268
Joined: Wed Apr 11, 2012 10:29 pm
Location: Northern Finland

Re: i guess i'm hopeless at scripting :D

Post by Kuningas »

Komag here is right. I'll illustrate a bit, (if you don't mind):

If you want to do the whole thing without scripting, make a counter and set it to start from 2.

Then, connect your buttons to the counter, and set them to "decrement()" it, and set them to go off only once (so pressing the same button twice won't open the door).

I learned today, that counters go off automatically when they hit zero, so this is the reason you'll want to decrement() them -- to avoid unnecessary script to see what the counter's value is.

Now the door should open when you have pressed both buttons.

If, on the other hand, you want a system where a door will open when both the buttons are "pressed", or activated, you'll either need to use levers or pressure plates -- buttons don't have states like that. That will require some scripting, possibly. (because the counter won't close the door automatically if it rises up from zero again, I think.)
BASILEUS
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: i guess i'm hopeless at scripting :D

Post by Komag »

yes, it will, if you connect the counter to the door with "any"-->"toggle"
Finished Dungeons - complete mods to play
User avatar
Kuningas
Posts: 268
Joined: Wed Apr 11, 2012 10:29 pm
Location: Northern Finland

Re: i guess i'm hopeless at scripting :D

Post by Kuningas »

Komag wrote:yes, it will, if you connect the counter to the door with "any"-->"toggle"
Is that so? Cool! This made several things more simple just like that.
BASILEUS
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: i guess i'm hopeless at scripting :D

Post by Komag »

it didn't used to work that way, but we requested during beta that counters would send a deactivate signal when going off from 0 so the dev's added that in, very nice
Finished Dungeons - complete mods to play
Post Reply