Game Development Community

Calling a GUI ::OnEnterTrigger

by Jonas · in Torque 3D Professional · 07/20/2010 (5:29 am) · 8 replies

Hey community!

i have attempted to call a GUI via a trigger like when he walks in the trigger a little msg should appear in the middle of the screen(like you picked up rocket launcher) but im kind of lost how i should go about doing that.

This is what i got so far:

function DoorTrigger::onEnterTrigger( %this, %trigger, %obj)
{
   if(%obj.getInventory(Map01Key01))
   {
      echo("You opened the door with the key and left it there!");
      %trigger.doorRef.playThread( 0, "open");
      %obj.decInventory(Map01Key01, 1);
      canvas.pushDialog(you_have_key_gui);    //this is the line that isn't working the rest is fine
   }
   else
   {
      echo("You do not have the key!");
   }
}

Note: i have gui in the name of the actual file its not a typo.
Also the gui is a bitmap.

best regards

About the author

Freelance 3D artist at day scripter/coder on Enduring Life at night. Lover of all things TorqueScript.


#1
07/20/2010 (6:53 am)
open the console, you_have_key_gui.dump();

#2
07/20/2010 (8:02 am)
that gives me the msg: <input> (0): Unable to find object: 'you_have_key_gui' attempting to call function 'dump'
#3
07/20/2010 (9:48 am)
Have you exec the you_have_key_gui.gui, or the file where the definiton of this gui is?
#4
07/20/2010 (6:38 pm)
Also keep in mind that your event is firing on the server and not the client. You would need to make a cmdtoclient call to show your GUI.
#5
07/20/2010 (8:21 pm)
Hey again guys, ok i forgot to exec it so problem solved there, However now i face the problem that the gui pops up but it shuts my cursor ...

basically i want it to pop up a sign that won't interfere at all with the game play its just a little notice.

Also how would i go about giving the gui a life time? i want it to go away after a while .

Best regards
/Jonas
#6
07/20/2010 (8:24 pm)
Ok i fixed the cursor error with a simple line : NoCursor = "1";

its just the issue with giving the gui a life time (i want it to go away after about 5-6 seconds)

best regards
#7
07/20/2010 (10:49 pm)
try this:

Canvas.schedule(5500, popDialog, you_have_key_gui);

It should work as far as I can tell. :)

Edit: add this after the pushDialog line.
#8
07/21/2010 (6:18 am)
ye it works perfectly ! thank you Konrad.