guibutton / exectrigger ??

guibutton / exectrigger ??

Postby unixfreak » 02 Oct 2013, 21:25

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?
User avatar
unixfreak
 
Posts: 82
Joined: 02 Feb 2012, 11:54
Location: Bristol, England

Re: guibutton / exectrigger ??

Postby unixfreak » 02 Oct 2013, 21:33

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
User avatar
unixfreak
 
Posts: 82
Joined: 02 Feb 2012, 11:54
Location: Bristol, England

Re: guibutton / exectrigger ??

Postby qreeves » 03 Oct 2013, 00:58

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.
Quinton "quin" Reeves | Lead Developer, Red Eclipse | http://redeclipse.net/ | http://www.facebook.com/redeclipse.net
User avatar
qreeves
 
Posts: 1294
Joined: 17 Mar 2011, 03:46
Location: Queensland, Australia

Re: guibutton / exectrigger ??

Postby unixfreak » 03 Oct 2013, 01:35

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
User avatar
unixfreak
 
Posts: 82
Joined: 02 Feb 2012, 11:54
Location: Bristol, England

Re: guibutton / exectrigger ??

Postby qreeves » 03 Oct 2013, 02:33

Thanks for the extra info, please try r5913 and tell me if that fixes the issue.
Quinton "quin" Reeves | Lead Developer, Red Eclipse | http://redeclipse.net/ | http://www.facebook.com/redeclipse.net
User avatar
qreeves
 
Posts: 1294
Joined: 17 Mar 2011, 03:46
Location: Queensland, Australia

Re: guibutton / exectrigger ??

Postby unixfreak » 03 Oct 2013, 03:07

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.
User avatar
unixfreak
 
Posts: 82
Joined: 02 Feb 2012, 11:54
Location: Bristol, England

Re: guibutton / exectrigger ??

Postby srbs » 26 Jan 2014, 10:14

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 ] ]
srbs
 
Posts: 94
Joined: 17 Mar 2011, 07:00

Who is online

Users browsing this forum: No registered users and 1 guest

cron