Gauge.setValue doesnt seem to work with variables?

Geyser is an object oriented framework for creating, updating and organizing GUI elements within Mudlet.
Post Reply
branden7
Posts: 16
Joined: Wed Oct 23, 2013 6:27 pm

Gauge.setValue doesnt seem to work with variables?

Post by branden7 » Wed Oct 23, 2013 6:34 pm

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.

User avatar
demonnic
Posts: 570
Joined: Sat Dec 05, 2009 3:19 pm

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

Post by demonnic » Wed Oct 23, 2013 8:57 pm

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.

branden7
Posts: 16
Joined: Wed Oct 23, 2013 6:27 pm

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

Post by branden7 » Wed Oct 23, 2013 9:44 pm

Oh man! Of course..I dont know why I didnt think about that.
That got it...thank you so much.

branden7
Posts: 16
Joined: Wed Oct 23, 2013 6:27 pm

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

Post by branden7 » Thu Oct 24, 2013 12:02 am

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.

User avatar
demonnic
Posts: 570
Joined: Sat Dec 05, 2009 3:19 pm

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

Post by demonnic » Thu Oct 24, 2013 6:43 pm

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

branden7
Posts: 16
Joined: Wed Oct 23, 2013 6:27 pm

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

Post by branden7 » Thu Oct 24, 2013 6:54 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest