Page 1 of 1

Gauge.setValue doesnt seem to work with variables?

Posted: Wed Oct 23, 2013 6:34 pm
by branden7
I cant seem to get my gauges to set a value from a variable. If I use hard coded values it works fine, but as soon as i put a variable in nothing works.

this runs on a trigger that looks for my prompt and then splits the values up into vars.
Code: [show] | [select all] lua
health = matches[2]
healthMax = matches[3]
stamina = matches[4]
staminaMax = matches[5]
coins = matches[6]

GUI.Health:setValue(health, healthMax, "working?");
I have confirmed that the vars do work (I can echo them out).
I can manually set something up..for example this works:
GUI.Health:setValue(50, 200);

anyone have any ideas of what I am doing wrong? I'm using the Geyser GUI template thing.

**Update**
I can actually display the variables as text on the gauge, but they still wont format the gauge.

Re: Gauge.setValue doesnt seem to work with variables?

Posted: Wed Oct 23, 2013 8:57 pm
by demonnic
The matches tables holds an array of strings. The gauges make use of numbers. You'll want to change it to
Code: [show] | [select all] lua
health = tonumber(matches[2])
healthMax = tonumber(matches[3])
--etc
And that should sort it out.

Re: Gauge.setValue doesnt seem to work with variables?

Posted: Wed Oct 23, 2013 9:44 pm
by branden7
Oh man! Of course..I dont know why I didnt think about that.
That got it...thank you so much.

Re: Gauge.setValue doesnt seem to work with variables?

Posted: Thu Oct 24, 2013 12:02 am
by branden7
Do you know how I check to see if one of those strings (that is an actual string) is not set?
Ive tried to compare it ( with == )to a specific string and that doesnt seem to work even when I know it contains the exact string.
Ive tried to see if it either is == or ~= nil
It seems to be never nil, so when it breaks apart my prompt it seems to be storing something there.

basically i'm trying to set up an if statement that sets the string to either the value of the match, or my own string if the value of the match is not what i want it to be.

Re: Gauge.setValue doesnt seem to work with variables?

Posted: Thu Oct 24, 2013 6:43 pm
by demonnic
branden,

== should work just fine. The following snippet should print "true" to the screen
Code: [show] | [select all] lua
testString = "hi"
testString2 = "hi"
if testString == testString2 then echo("true\n") end
I've just tested it myself

Re: Gauge.setValue doesnt seem to work with variables?

Posted: Thu Oct 24, 2013 6:54 pm
by branden7
Hm..it must be something funny with the way the prompt outputs.
I was trying to set a hidden or visible var, which is supposed to come through in my prompt (although only hidden comes through).

I was running an if statement to check if the value of matches[11] == "Hidden"
if it was it set matches[11] to Hidden, if not to visible. but it never seemed to match to Hidden, even though when I outputted that var it outputted as Hidden.

I've decided its not really worth my time at this point..I'm going to finish setting the GUI up and then come back to it when I've had a little more experience.