[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Health and Experience and Bars, oh my!
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Health and Experience and Bars, oh my!
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  3  4  

Posted by Caelen   (81 posts)  [Biography] bio
Date Tue 01 Mar 2011 09:27 AM (UTC)  quote  ]
Message
Definitely helped. Also took a bit more testing to find the problem... I was only testing the EP, which was the problem!

Now... to work on my other project! http://www.gammon.com.au/forum/?id=10962
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Tue 01 Mar 2011 07:39 AM (UTC)  quote  ]
Message
D'oh! :D

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (19,631 posts)  [Biography] bio   Forum Administrator
Date Tue 01 Mar 2011 07:34 AM (UTC)  quote  ]
Message
So the debugging prints helped, huh?

That's what usually happens to me. I'm not trying to be smart, I make lots of mistakes. But debugging techniques help find them.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Caelen   (81 posts)  [Biography] bio
Date Tue 01 Mar 2011 07:06 AM (UTC)  quote  ]
Message
Caelen said:

function do_prompt_percent (name, line, wildcards)

  hpp = tonumber (wildcards [1])
  spp = tonumber (wildcards [2])
  epp = tonumber (wildcards [3])
  hp = max_hp * ( hpp / 100 )
  sp = max_sp * ( spp / 100 )
  ep = max_ep * ( spp / 100 )
  print ("HP:" .. hp .. "/" .. max_hp .. "%" .. hpp)
  print ("SP:" .. sp .. "/" .. max_sp .. "%" .. spp)
  print ("EP:" .. ep .. "/" .. max_ep .. "%" .. epp)

  draw_the_bars ()
      
end -- do_prompt_percent



...

I found the problem XD

ep = max_ep * ( spp / 100 )

spp, not epp... fixed!
[Go to top] top

Posted by Caelen   (81 posts)  [Biography] bio
Date Tue 01 Mar 2011 07:04 AM (UTC)  quote  ]
Message
hp
HP:246/306  SP:33/238  EP:113/155
> 
hpp
HP:80%  SP:13%  EP:72%
HP:244/306%80 -- printed
SP:30/238%13 -- printed
EP:20/155%72 -- printed
> 


printing all from the do_prompt_percent...

the HP one looks right, and the SP one too...

but the EP? O_o
[Go to top] top

Posted by Caelen   (81 posts)  [Biography] bio
Date Tue 01 Mar 2011 06:50 AM (UTC)  quote  ]
Message
Twisol said:

Oh, heh. I must be more tired than I thought.

I broke it down for ya in an edit :x
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Tue 01 Mar 2011 06:44 AM (UTC)  quote  ]
Message
Caelen said:
I'm not sure what you're asking for... what I pasted above included the command (hp and hpp respectively), the output from the game (the line with HP quantity and HP %), and then what was printed by the debugg scripts.

Oh, heh. I must be more tired than I thought.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Caelen   (81 posts)  [Biography] bio
Date Tue 01 Mar 2011 06:32 AM (UTC)  quote  ]

Amended on Tue 01 Mar 2011 06:41 AM (UTC) by Caelen

Message
I'm not sure what you're asking for... what I pasted above included the command (hp and hpp respectively), the output from the game (the line with HP quantity and HP %), and then what was printed by the debugg scripts.

What you've simulated there is actually the match for the one trigger that -does- work. I've tested the three triggers, and all three return the proper wildcard values. The third trigger catches the command "hpall", and the mud gives the "Verren Reports: %%%" line (the match I'm using the variable for now).

It's the % ones that are returning incorrect values for current, but the max values are always correct.


hp -- command
HP:306/306  SP:238/238  EP:111/155 -- mud output
HP: 306/306 current/max -- printed by DoGauge called by do_prompt_max
SP: 238/238 current/max -- printed by DoGauge called by do_prompt_max
EP: 111/155 current/max -- printed by DoGauge called by do_prompt_max

hpp -- command
HP:100%  SP:100%  EP:71% -- mud output
HP:306/306%100 -- printed by do_prompt_percent
SP:238/238%100 -- printed by do_prompt_percent
EP:155/155%71 -- printed by do_prompt_percent
HP: 306/306 current/max -- printed by DoGauge called by do_prompt_percent
SP: 238/238 current/max -- printed by DoGauge called by do_prompt_percent
EP: 155/155 current/max -- printed by DoGauge called by do_prompt_percent


Note that EP is the only one that was not at max.
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Tue 01 Mar 2011 06:23 AM (UTC)  quote  ]
Message
Well, I just installed the plugin and ran this small script:
Simulate("HP:100/500  SP:100/400  EP:100/300\r\n")

The gauges seem to work just fine. Can you paste a few actual examples of that hp/sp/ep line? My hunch is that, for some reason, the max_* variables are always less than the current values, so you're always drawing the gauges at 100%. It all works for me, so the only thing left is the data coming in via the trigger.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Caelen   (81 posts)  [Biography] bio
Date Tue 01 Mar 2011 02:49 AM (UTC)  quote  ]

Amended on Tue 01 Mar 2011 03:23 AM (UTC) by Caelen

Message
Nick Gammon said:

I always find it helps to put in debugging print statements. Perhaps the values are 100 times what you expect, or one is missing, or something?


Results of the printing: (printed added before what was printed)
hp
HP:306/306  SP:238/238  EP:111/155
printed HP: 306/306 current/max
printed SP: 238/238 current/max
printed EP: 111/155 current/max
> 
hpp
HP:100%  SP:100%  EP:71%
printed HP:306/306%100
printed SP:238/238%100
printed EP:155/155%71
printed HP: 306/306 current/max
printed SP: 238/238 current/max
printed EP: 155/155 current/max


Modifications to DoGauge:
  print (sPrompt .. current .. "/" .. max .. " current/max")


Modifications to do_prompt_percent:
  print ("HP:" .. hp .. "/" .. max_hp .. "%" .. hpp)
  print ("SP:" .. sp .. "/" .. max_sp .. "%" .. spp)
  print ("EP:" .. ep .. "/" .. max_ep .. "%" .. epp)


So, do_prompt_percent is the problem... it's catching the right value for the percentage (71), but it's not doing the math right.

function do_prompt_percent (name, line, wildcards)

  hpp = tonumber (wildcards [1])
  spp = tonumber (wildcards [2])
  epp = tonumber (wildcards [3])
  hp = max_hp * ( hpp / 100 )
  sp = max_sp * ( spp / 100 )
  ep = max_ep * ( spp / 100 )
  print ("HP:" .. hp .. "/" .. max_hp .. "%" .. hpp)
  print ("SP:" .. sp .. "/" .. max_sp .. "%" .. spp)
  print ("EP:" .. ep .. "/" .. max_ep .. "%" .. epp)

  draw_the_bars ()
      
end -- do_prompt_percent


Ideas?

EDIT: changed that middle part to
  hp = math.floor(max_hp * (hpp / 100))
  sp = math.floor(max_sp * (spp / 100))
  ep = math.floor(max_ep * (spp / 100))


Doesn't change the results, but I don't want any decimal values gumming it up.

EDIT2: I have decided to, for now, scrap the idea of making the background transparent. It would be nice, but without the background it would get quite messy as text appeared beneath the gauges. Plus, I can't do the blend thing, which seems to be what people were wanting actually XD
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Tue 01 Mar 2011 01:30 AM (UTC)  quote  ]
Message
Caelen said:

What I'm trying to do is get do_prompt_percent to send the current and max values so that the mouseover hotspot will display the correct (or at least somewhat close) information when only supplied with the percentage. The math looks fine to me... but I just don't see why it isn't sending the correct info.

Oh, I see. I must've skipped over that part.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (19,631 posts)  [Biography] bio   Forum Administrator
Date Tue 01 Mar 2011 12:49 AM (UTC)  quote  ]
Message
I always find it helps to put in debugging print statements. Perhaps the values are 100 times what you expect, or one is missing, or something?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Caelen   (81 posts)  [Biography] bio
Date Tue 01 Mar 2011 12:30 AM (UTC)  quote  ]
Message
Twisol said:

local Fraction = math.min (math.max (current / max, 0), 1)



Cleaned up :D Thanks.

Twisol said:

Secondly, you're passing 'current' and 'max' in to DoGauge so it can figure out how much of the gauge should be filled, but you already -have- that in the percentage. Just (hpp / 100) gives you the fraction of the gauge that needs filling.


What I'm trying to do is get do_prompt_percent to send the current and max values so that the mouseover hotspot will display the correct (or at least somewhat close) information when only supplied with the percentage. The math looks fine to me... but I just don't see why it isn't sending the correct info.
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Mon 28 Feb 2011 11:48 PM (UTC)  quote  ]
Message
Nitpick, but this is unnecessary:
  if current > max then
     current = max
  end -- cannot have more than max

  if current < 0 then
     current = 0
  end -- cannot have less than zero
  
  -- fraction in range 0 to 1
  local Fraction = math.min (math.max (current / max, 0), 1) 

By locking current between 0 and max, you're already ensuring that Fraction is between 0 and 1 (as 0/max is 0 and max//max is 1). I'd prefer just to forgo the if-checks because the math.min and math.max do it neatly in one line.
local Fraction = math.min (math.max (current / max, 0), 1)


Secondly, you're passing 'current' and 'max' in to DoGauge so it can figure out how much of the gauge should be filled, but you already -have- that in the percentage. Just (hpp / 100) gives you the fraction of the gauge that needs filling.


I can't actually run the plugin currently, but I don't see any actual bugs, so I'm probably missing something.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Caelen   (81 posts)  [Biography] bio
Date Mon 28 Feb 2011 06:50 PM (UTC)  quote  ]
Message
Ah, sorry. I mean the "function DoGauge" always draws the bars at 100% full when the two triggers in question match. I tested the triggers using "print", and they are grabbing the correct numbers in both cases. The problem is either in function DoGauge or function do_prompt_percent.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


13,169 views.

This is page 1, subject is 4 pages long: 1 2  3  4  [Next page]

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]