Page 1 of 1
i guess i'm hopeless at scripting :D
Posted: Wed Oct 10, 2012 7:43 pm
by azidahaka
I did many complex scripts but i get stuck in the most stupid things
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?
Re: i guess i'm hopeless at scripting :D
Posted: Wed Oct 10, 2012 7:48 pm
by SpacialKatana
'closed' should be 'close'
Re: i guess i'm hopeless at scripting :D
Posted: Wed Oct 10, 2012 8:18 pm
by azidahaka
it's not that the problem it says
attempt to call method toggle a nil value
Re: i guess i'm hopeless at scripting :D
Posted: Wed Oct 10, 2012 8:26 pm
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
Re: i guess i'm hopeless at scripting :D
Posted: Wed Oct 10, 2012 9:47 pm
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.)
Re: i guess i'm hopeless at scripting :D
Posted: Wed Oct 10, 2012 9:55 pm
by Komag
yes, it will, if you connect the counter to the door with "any"-->"toggle"
Re: i guess i'm hopeless at scripting :D
Posted: Wed Oct 10, 2012 10:00 pm
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.
Re: i guess i'm hopeless at scripting :D
Posted: Wed Oct 10, 2012 10:16 pm
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