Absolutely confused now...

Post Reply
Whisper31
Posts: 3
Joined: Tue Aug 26, 2014 6:38 am

Absolutely confused now...

Post by Whisper31 »

Hi there. I'm not new to mudding and not a complete noob to mudlet, but I was away for a while and now I am getting back into mudding. I'm trying to dump my prompt into variables and I have gotten myself so confused now looking through the boards.

I have the basic initialization of the vars.
i.e.:
if hpcur == nil then
hpcur = 0
end

etc...

My prompt takes this form:

<405/405 HP 151/163 Mn 157/157 Mv -5.6 918852 XP 931 GP>

and I have a trigger set to go off on this regex formula:

<(\d+)\/(\d+) HP (\d+)\/(\d+) Mn (\d+)\/(\d+) Mv -?(\d+).(\d+) (\d+) XP (\d+) GP>

with the following script in the trigger:
hpcur = tonumber(matches[2])
hpmax = tonumber(matches[3])
mncur = tonumber(matches[4])
mnmax = tonumber(matches[5])
mvcur = tonumber(matches[6])
mvmax = tonumber(matches[7])
acint = tonumber(matches[8])
acdec = tonumber(matches[9])
xpcur = tonumber(matches[10])
gpcur = tonumber(matches[11])

accur = acint + (acdec/10)

I also ran the regex and prompt through an online regex tester and it said everything was fine.

For some reason I am getting nil answers or improper values into the vars. I am about to pull my hair out over this. I am wanting to make 8 simple gauges to tell me stats, xp needed for each of the four classes, and an AC gauge which goes from -10.0 to 10.0. I will be able to figure out how to make the gauges when I can figure out what the heck I am doing wrong in getting the values into the variables.

Thanks much for helping in advance.

Whisper31
Posts: 3
Joined: Tue Aug 26, 2014 6:38 am

Re: Absolutely confused now...

Post by Whisper31 »

Sorry about the post that I deleted. Chalk it up to being frustrated and more than a little ticked off at myself for not being able to understand something that should be absolutely simple. :oops:

I really could use someone to see what I am doing wrong. I know I am overlooking something very simple, but I cannot find it.

Thanks again for your patience, folks.

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Absolutely confused now...

Post by icesteruk »

Im unsure what this is suppose to do
Code: [show] | [select all] lua
I have the basic initialization of the vars.
i.e.:
if hpcur == nil then
hpcur = 0
end
but if you click highlight on the trigger, you can see if its firing right, have you also set the trigger to perl regex?


for the trigger input part I would do something like

prompt = prompt or {}

prompt.hpcur = tonumber(matches[2])
prompt.hpmax = tonumber(matches[3])
prompt.mncur = tonumber(matches[4])
prompt.mnmax = tonumber(matches[5])
prompt.mvcur = tonumber(matches[6])
prompt.mvmax = tonumber(matches[7])
prompt.acint = tonumber(matches[8])
prompt.acdec = tonumber(matches[9])
prompt.xpcur = tonumber(matches[10])
prompt.gpcur = tonumber(matches[11])

prompt.accur = prompt.acint + (prompt.acdec/10)


---

then you can do something like this into the command bar to see which is and isn't capturing right IF the trigger is firing right.

lua display(prompt) - that should show you something like

prompt.hpcur = 34343
prompt.hpmax = 121222
prompt.mncur = 12122

etc ..

User avatar
SlySven
Posts: 1023
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Absolutely confused now...

Post by SlySven »

icesteruk wrote:Im unsure what this is suppose to do
Code: [show] | [select all] lua
I have the basic initialization of the vars.
i.e.:
if hpcur == nil then
hpcur = 0
end
..
Simply put, if the lua interpreter has not previously used hpcur then it will automatically have the nil value which is not a number or a string or a table or a boolean. That being the case, and only then, hpcur is assigned the value zero, otherwise it isn't touched. So yes, it initialises the variable if it hasn't been previously initialised but leaves any value from previous use alone.

Whisper31
Posts: 3
Joined: Tue Aug 26, 2014 6:38 am

Re: Absolutely confused now...

Post by Whisper31 »

Thanks for the help folks. I'll try it when I get the next chance to log on and play. I can figure out what to do when I get the values into the variables, just for some reason they aren't going into them, but I will try your suggestions.

Update:

Tried the highlight trigger and got that to work and the prompt.XXXX works just fine!!! Thanks a whole lot there!!

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Absolutely confused now...

Post by icesteruk »

Your welcome! also if you do post an help, give it a few days for people to reply. or check out the mudlet IRC as people normally log into that and not notice a post on forums dude :P

User avatar
SlySven
Posts: 1023
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Absolutely confused now...

Post by SlySven »

@icesteruk: It's swings and roundabouts - I don't use the IRC channel myself, what with: the forums, developers' repository stuff on Github, related chat on Gitter, Email, and bug-tracking on Lauchpad I find I have enough input channels already. ;)

@Whisper31 - seeking replies, seek patience you also must padawan.

Post Reply