Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ncw14 on Tue 01/01/2008 01:00:34

Title: GUI help (SOVLED)
Post by: ncw14 on Tue 01/01/2008 01:00:34
I learned scripting and much i read the manual they have help for this but i cant get it to work the way i want so hear

I want a Gui in Statusline to display xp

xp is currently GlobalInt(2, 0);

how would i put that in Gui


i have health as Hp: @SCORE@
i got that to work, but i dont know how to put globalints in gui

EDIT*

This Game can be very confusing, while in walking mode you cannot click objects for interactions, and while in Use/ (hand button) you cant walk but can i make it so that when I'm in walk mode, i can click buttons this i have NO idea how to do but my gaame is difficult without it
Title: Re: GUI help
Post by: RickJ on Tue 01/01/2008 02:09:40
First you need edit the Gui as follows.

1.  Open the desired GUI and give it a script name, something like gStatusline.

2.  Add a label contol to the GUI.  There should be some toolbar buttons above the GUI window in the editor, you can mouse over them to see a tool tip "Add GUI label".  Click on the button and then move your mouse to the GUI and drag a rectangle there.   

3.  Give a script name to the label something like gStatusLineXp. 

Next you will need to add some code to the repeatedly_execute() function in the global script.

function repeatedly_execute()  {

   // Write a value to XP
   gSTatuslineXp.Text = String.Format("%d", GetGlobalInt(2));

}

That should be it!

Title: Re: GUI help
Post by: Shane 'ProgZmax' Stevens on Tue 01/01/2008 11:30:08
You might also want to have a backup variable that stores a previous version of the xp so you can compare and see if you actually need to update the label, that way it's not constantly updating the label with the same value unnecessarily, something like:

if(oldxp != currxp)
{
  oldxp=currxp;

  //now update the label.


}
Title: Re: GUI help
Post by: ncw14 on Tue 01/01/2008 17:17:35
i solved that but how do i make a Gui not show up until i click quit
Title: Re: GUI help
Post by: Galen on Tue 01/01/2008 17:20:30
Quote from: ncw14 on Tue 01/01/2008 17:17:35
i solved that but how do i make a Gui not show up until i click quit

Set it to be not visible by default and then when you click the quit button, make it run a script and in that script put something like gWhateverthehellyoucalledthegui.Visible=true;
Title: Re: GUI help (SOVLED)
Post by: Khris on Tue 01/01/2008 20:08:42
Set the GUI to PopupModal, then it won't be visible from the start and will pause the game when it's being shown.

No offense, but why don't you just try out stuff and see what happens?
Or - pretty far-fetched, I know - just RTFM.
QuoteThe "Popup modal" option means that the GUI will be initially off and must be turned on by a script command. With this option, the game will be paused while the GUI is displayed, during which time the on_mouse_click and on_key_press functions will not get run.
-----
bool GUI.Visible

Gets/sets whether the GUI is visible or not. This property has behaves differently depending on the GUI popup style.
Title: Re: GUI help (SOVLED)
Post by: Galen on Tue 01/01/2008 20:15:01
*slaps head*
Ignore the first part of my advice Mr. Topicstarter.
Title: Re: GUI help (SOVLED) ----- Also Button help (Not Solved)
Post by: ncw14 on Wed 02/01/2008 01:42:32
I Didnt Want to Add on to my 50 open threads and make a new one, so i just edited this, plz help
Title: Re: GUI help (SOVLED) ----- Also Button help (Not Solved)
Post by: Creator on Wed 02/01/2008 08:14:55
All your questions have been answered.

Quote from: KhrisMUC on Tue 01/01/2008 20:08:42
Set the GUI to PopupModal, then it won't be visible from the start and will pause the game when it's being shown.

Quote from: Crazy on Tue 01/01/2008 17:20:30
Then when you click the quit button, make it run a script and in that script put something like gWhateverthehellyoucalledthegui.Visible=true;