Page 1 of 1

guibutton / exectrigger ??

PostPosted: 02 Oct 2013, 21:25
by unixfreak
Hi.
Trying to setup a trigger that has a red "tape" particle which can be toggled on/off by a gui, imagine a scenario when you interact with a console, that opens a gui and allows you to turn a laser on and off.

Here's the line that is bugging me:
{l Code}: {l Select All Code}
guibutton "Toggle ^frred" [ sound 253; exectrigger 61 ]


It plays the sound, but does not toggle the particle to appear/dissapear. Any reason why that is?
The trigger works outside of the guibutton function, and i have also tried this:

{l Code}: {l Select All Code}
somealias = [ sound 253; exectrigger 61 ]
guibutton "Toggle ^frred" $somealias


also

{l Code}: {l Select All Code}
somealias = [ exectrigger 61 ]
guibutton "Toggle ^frred" $somealias

But to no avail. :o

Ideas?

Re: guibutton / exectrigger ??

PostPosted: 02 Oct 2013, 21:33
by unixfreak
This might be useful in case i've done something else wrong; this is the part in question.
{l Code}: {l Select All Code}
//laser control on/off (there are 6 beams, each with 3 lasers)
room3_laser1_red = 0
room3_laser1_green = 0
room3_laser1_blue = 0
room3_laser2_red = 0
room3_laser2_green = 0
room3_laser2_blue = 0
room3_laser3_red = 0
room3_laser3_green = 0
room3_laser3_blue = 0
room3_laser4_red = 0
room3_laser4_green = 0
room3_laser4_blue = 0
room3_laser5_red = 0
room3_laser5_green = 0
room3_laser5_blue = 0
room3_laser6_red = 0
room3_laser6_green = 0
room3_laser6_blue = 0

//laser control trigger function (interact with console)
on_trigger_59 = [

        newgui laser_console [

                guistayopen [
                        guiheader "laser control"
                        guitext "select wavelength output
                        guistrut 1
                        guibar
                        guistrut 1

                        guitext "beam 1"
                        guibutton "Toggle ^fr650 nm" [ sound 253; exectrigger 61; if ($room3_laser1_red   0) [ room3_laser1_red   = 1 ][ room3_laser1_red  = 0 ]]
                        guibutton "Toggle ^fr532 nm" [ sound 253; exectrigger 60; if ($room3_laser1_green 0) [ room3_laser1_green = 1 ][ room3_laser1_blue = 0 ]]
                        guibutton "Toggle ^fr488 nm" [ sound 253; exectrigger 62; if ($room3_laser1_blue  0) [ room3_laser1_blue  = 1 ][ room3_laser1_blue = 0 ]]

                        // beam 2... etc
                        // ....................
                        // ....................

                        ]
        ]
        showgui laser_console
]


I can't screenshot it right now, but i have started a gimmick style map that has puzzle rooms with small minigames to unlock the next door etc, this room in particular has 6 beams.

Screenshot:
http://s21.postimg.org/sx8df44yu/20131002222749.jpg

That is, 6 devices where a laser travels from point A to B. You can toggle a red a blue and a green laser in each beam.... so if you enable the red and the blue beam, you get a purple one.

There is a passcode that requires you do mix the lasers so that each beams colour matches up, hoping that makes sense as to what i'm trying to do. That's the idea, I just can't seem to get the lasers to actually toggle from within a gui / guibutton. :p

Re: guibutton / exectrigger ??

PostPosted: 03 Oct 2013, 00:58
by qreeves
First, cube script uses hungarian notation -> if (= $var 0)

Second, the 'id' you trigger is not the index of the entity in the array, but whatever you set the 'id' attribute to.

Re: guibutton / exectrigger ??

PostPosted: 03 Oct 2013, 01:35
by unixfreak
qreeves {l Wrote}:First, cube script uses hungarian notation -> if (= $var 0)

Second, the 'id' you trigger is not the index of the entity in the array, but whatever you set the 'id' attribute to.


Ah, i'm aware of the notation thingy, seems i missed it when copy/pasting to that part. I've adjusted it, the exectrigger part isn't toggling the linked particle however.
PS; I have alot of triggers in this map (starting at id 20), the "61, 60 ,62" are id's :cool:

I'll try upload a video of the issue i'm having trouble with.
Edit: http://www.youtube.com/watch?v=cLJJ2C74wH8

Re: guibutton / exectrigger ??

PostPosted: 03 Oct 2013, 02:33
by qreeves
Thanks for the extra info, please try r5913 and tell me if that fixes the issue.

Re: guibutton / exectrigger ??

PostPosted: 03 Oct 2013, 03:07
by unixfreak
Just tried it out, i can't get a trigger to exec from inside "guibutton []" still, although, for the past hour, i've change my script to use checkboxes with a different method to toggle the lasers, it seems to work okay this way:

screenshot:
http://s11.postimg.org/rf1if24v6/20131003024346.jpg

{l Code}: {l Select All Code}
//laser control on/off (there are 6 beams) (each has 3 lasers; red, green, blue)
room3_laser1_r = 0
room3_laser1_g = 0
room3_laser1_b = 0
room3_laser2_r = 0
room3_laser2_g = 0
room3_laser2_b = 0
room3_laser3_r = 0
room3_laser3_g = 0
room3_laser3_b = 0
room3_laser4_r = 0
room3_laser4_g = 0
room3_laser4_b = 0
room3_laser5_r = 0
room3_laser5_g = 0
room3_laser5_b = 0
room3_laser6_r = 0
room3_laser6_g = 0
room3_laser6_b = 0

//laser control trigger function
on_trigger_59 = [

   newgui laser_console [

      guistayopen [
         guiheader "laser control"
         guicenter [ guitext "select wavelength output" ]


         guibar
         guitext "beam 1"
         guilist [
            guispring 10
            guicheckbox "650 nm" room3_laser1_r  [ sound 253 ]
            guibar
            guicheckbox "532 nm" room3_laser1_g  [ sound 253 ]
            guibar
            guicheckbox "488 nm" room3_laser1_b  [ sound 253 ]
         ]
         guistrut 0.2

         guibar
         guitext "beam 2"
         guilist [
            guispring 10
            guicheckbox "650 nm" room3_laser2_r  [ sound 253 ]
            guibar
            guicheckbox "532 nm" room3_laser2_g  [ sound 253 ]
            guibar
            guicheckbox "488 nm" room3_laser2_b  [ sound 253 ]
         ]
         guistrut 0.2

         guibar
         guitext "beam 3"
         guilist [
            guispring 10
            guicheckbox "650 nm" room3_laser3_r  [ sound 253 ]
            guibar
            guicheckbox "532 nm" room3_laser3_g  [ sound 253 ]
            guibar
            guicheckbox "488 nm" room3_laser3_b  [ sound 253 ]
         ]
         guistrut 0.2

         guibar
         guitext "beam 4"
         guilist [
            guispring 10
            guicheckbox "650 nm" room3_laser4_r  [ sound 253 ]
            guibar
            guicheckbox "532 nm" room3_laser4_g  [ sound 253 ]
            guibar
            guicheckbox "488 nm" room3_laser4_b  [ sound 253 ]
         ]
         guistrut 0.2

         guibar
         guitext "beam 5"
         guilist [
            guispring 10
            guicheckbox "650 nm" room3_laser5_r  [ sound 253 ]
            guibar
            guicheckbox "532 nm" room3_laser5_g  [ sound 253 ]
            guibar
            guicheckbox "488 nm" room3_laser5_b  [ sound 253 ]
         ]
         guistrut 0.2

         guibar
         guitext "beam 6"
         guilist [
            guispring 10
            guicheckbox "650 nm" room3_laser6_r  [ sound 253 ]
            guibar
            guicheckbox "532 nm" room3_laser6_g  [ sound 253 ]
            guibar
            guicheckbox "488 nm" room3_laser6_b  [ sound 253 ]
         ]
         guistrut 0.2
      ]
   ]
   showgui laser_console


]

on_trigger_63 = [

   sound 1;
   if (= $room3_laser1_r 1) [ exectrigger 61 ]
   if (= $room3_laser1_g 1) [ exectrigger 60 ]
   if (= $room3_laser1_b 1) [ exectrigger 62 ]

   if (= $room3_laser2_r 1) [ exectrigger 66 ]
   if (= $room3_laser2_g 1) [ exectrigger 65 ]
   if (= $room3_laser2_b 1) [ exectrigger 67 ]

   if (= $room3_laser3_r 1) [ exectrigger 68 ]
   if (= $room3_laser3_g 1) [ exectrigger 69 ]
   if (= $room3_laser3_b 1) [ exectrigger 70 ]

   if (= $room3_laser4_r 1) [ exectrigger 71 ]
   if (= $room3_laser4_g 1) [ exectrigger 72 ]
   if (= $room3_laser4_b 1) [ exectrigger 73 ]

   if (= $room3_laser5_r 1) [  ]
   if (= $room3_laser5_g 1) [  ]
   if (= $room3_laser5_b 1) [  ]

   if (= $room3_laser6_r 1) [  ]
   if (= $room3_laser6_g 1) [  ]
   if (= $room3_laser6_b 1) [  ]

   //fix this, breaks if you set all to "on" - white laser = cheat
   sleep 2000 [
      if (&& (&& (= $room3_laser1_r 1) (= $room3_laser1_g 1)) (= $room3_laser4_b 0)) [
         echo "debug: phase 1 complete"
      ]
      if (&& (&& (= $room3_laser1_r 1) (= $room3_laser1_g 0)) (= $room3_laser4_b 1)) [
            echo "debug: phase 2 complete"
      ]
      if (&& (&& (= $room3_laser1_r 0) (= $room3_laser1_g 1)) (= $room3_laser4_b 0)) [
            echo "debug: phase 3 complete"
      ]
      if (&& (&& (= $room3_laser4_r 1) (= $room3_laser4_g 1)) (= $room3_laser4_b 1)) [
            echo "debug: phase 4 complete"
      ]
   
      //
      // todo add beam 5 and 6 (triggers/particles)
      //
   ]
]]


It's kind of hack-ish but the idea seems to work!
Those last few lines are a mess, that i need to change, but i gotta sleep. I'll try finish this room of the map in the morning, and hopefully post the map so far once it works.

Re: guibutton / exectrigger ??

PostPosted: 26 Jan 2014, 10:14
by srbs
unixfreak {l Wrote}:Just tried it out, i can't get a trigger to exec from inside "guibutton []"


This might not be useful anymore, but I think this will work (untested):
{l Code}: {l Select All Code}
guibutton "Toggle ^fr650 nm" [ room3_laser1_red = (! $room3_laser1_red); sleep 1 [ sound 253; exectrigger 61 ] ]