Game Development Community

Adding text to screen

by Chris · in Torque Game Engine · 05/17/2009 (8:12 pm) · 3 replies

Hey guys, ok, all I'm trying to do is add one little sentence to the screen when a player enters the room. When the player enters the room, I want a line of text to pop up saying "Hey you're not allowed in there!". I've created a GUI file containing the text controls, here's what's in that file (orderlyHail.gui):

new GuiControl(orderlyHail) {
   canSaveDynamicFields = "0";
   Profile = "GuiDefaultProfile";
   HorizSizing = "right";
   VertSizing = "bottom";
   Position = "100 100";
   Extent = "640 480";
   MinExtent = "8 8";
   canSave = "1";
   Visible = "1";
   hovertime = "1000";
   
   new GuiMLTextCtrl(orderlyHailText) {
      profile = "GuiMLTextProfile";
      horizSizing = "width";
      vertSizing = "height";
      position = "500 1";
      extent = "100 20";
      minExtent = "8 8";
      visible = "1";
      helpTag = "0";
      lineSpacing = "2";
      allowColorChars = "0";
      maxChars = "-1";
         text = "<font:Arial Bold:20><color:0000ff>Hey!  You're not allowed in there!"";
   };

Then I'm trying to push the GUI to the front in the function as so:

canvas.pushdialog("C:/Documents and Settings/Administrator/Desktop/Torque/TGE_1_5_2/example/tutorial.base/client/ui/orderlyHail.gui");

However, whenever I enter the room and it tries to execute it says "pushDialog(): Invalid control"

Any help is greatly appreciated, thanks guys.

#1
05/17/2009 (8:23 pm)
And any time I try to save the GUIs I make in the GUI editor it says failed to save because it may be read only... gahhh this is irritating!
#2
05/18/2009 (12:25 am)
Two problems that I see is that you passed a full system path to your "pushDialog" command, which means you are calling the "pushDialog" incorrectly.
1) Torque really shouldn't have any concept of a filepath outside of it's own directory (although in a few special cases it can)
2) When you want to push or pop a dialog, do so with a call to the name given to the control not a path to the GUI's location:
canvas.pushdialog(orderlyHail);
One other thing that you should do is make sure that your GUI file is being exec'd.

As to why you're being told that the file is write only, could be because you're trying to write to a file that doesn't exist, or is in a location that cannot be written to.


Just a suggestion, but why not use the already built in centerprint/bottomprint controls? Just compose your message and pass it by telling the client in question to do a bottom/center-print.
BottomPrint(%client, "Hey!  You're not allowed in there!", 2, 1);
That will print the message to the bottom of the screen, if you have properly determined who %client is. Centerprint follows the same format and prints to the center of the screen.

BottomPrint(%client, %message, %time, %length);
CenterPrint(%client, %message, %time, %length);
- %client is who you're sending the message to
- %time is how long the message stays on the screen, in seconds
- %length is how many lines the message will take up (this determines the size of the HUD)

Little messages like that don't really justify the time and effort needed for a whole new GUI for me -- I'm a lazy coder! :D
#3
05/21/2009 (11:07 am)
Make sure you Name your GUI.

In the GUI editor:

Select the highest guiControl in the feature list (upper right of settings column on the right).
Enter the name: orderlyHail in the Name field and choose APPLY.
Save the gui and try.

An example of the mainScreenGui.gui file. Notice the (mainScreenGui).

//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(mainScreenGui) {