PDA

View Full Version : 0 is a no show.


Angel_Light
03-05-2007, 11:21 PM
I cant get a single digit0 to display in my gui, it's a mud var I'm using,
this.clientr.mud.stats.curexp = 0;
I know 0 is null but why doesnt the gui still show 0?

EDIT :
Think I found a solution :
if (clientr.mud.stats.curexp == NUL) Master_Gui_Text_Exp.setText("EXP : 0/ " @ clientr.mud.stats.maxexp);

Still want 0 to show by itself.

Skyld
03-05-2007, 11:57 PM
In GScript2, 0 (NULL) is technically the variable not existing. When you set something to 0, it becomes unset, and unset variables automatically read 0.

it's the way the new engine works.

napo_p2p
03-06-2007, 12:05 AM
You can also use float(str). If you put a null string in there, it'll show up as 0.

Chompy
03-06-2007, 12:07 AM
I cant get a single digit0 to display in my gui, it's a mud var I'm using,
this.clientr.mud.stats.curexp = 0;
I know 0 is null but why doesnt the gui still show 0?

EDIT :
Think I found a solution :
if (clientr.mud.stats.curexp == NUL) Master_Gui_Text_Exp.setText("EXP : 0/ " @ clientr.mud.stats.maxexp);

Still want 0 to show by itself.


Master_Gui_Text_Exp.setText("EXP : " @ (currentexp > 0 ? currentexp : "0") @ " / " @ clientr.mud.stats.maxexp);

Angel_Light
03-06-2007, 12:25 AM
thanks guys, still want it to show 0 without anything extra, oh well... maybe in GS3 lol :o

zokemon
03-06-2007, 09:36 PM
thanks guys, still want it to show 0 without anything extra, oh well... maybe in GS3 lol :o


Master_Gui_Text_Exp.setText(max(0, currentexp));

Skyld
03-06-2007, 09:40 PM
Or even perhaps:
Master_Gui_Text.setText(int(currentexp));

zokemon
03-06-2007, 09:46 PM
Or even perhaps:
Master_Gui_Text.setText(int(currentexp));

If you wanted a integer, yes. But his exp may (though I doubt it) include decimals.

I still like max() though. One of my favorite functions for math related things :)
I always see people doing all these integrated equations (the whole # > # ? # : # method) when they could simply use a combination of min(), max(), abs(), int() and the % symbol (not every case, obviously).

Angel_Light
03-06-2007, 10:55 PM
yes it includes decimals by increments of 0.2

Kristi
03-07-2007, 12:14 AM
if varname = 0 just use @varname...

Admins
03-07-2007, 10:59 AM
Then
Master_Gui_Text.text = float(clientr.mud.stats.curexp);

napo_p2p
03-07-2007, 11:05 AM
Then
Master_Gui_Text.text = float(clientr.mud.stats.curexp);

I knew it ;).