GUI help (SOVLED)

Started by ncw14, Tue 01/01/2008 01:00:34

Previous topic - Next topic

ncw14

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

RickJ

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!


Shane 'ProgZmax' Stevens

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.


}

ncw14

i solved that but how do i make a Gui not show up until i click quit

Galen

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;

Khris

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.

Galen

*slaps head*
Ignore the first part of my advice Mr. Topicstarter.

ncw14

I Didnt Want to Add on to my 50 open threads and make a new one, so i just edited this, plz help

Creator

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;

SMF spam blocked by CleanTalk