Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Plug-in not capturing values properly

Plug-in not capturing values properly

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Aidyn.Hartfire   USA  (15 posts)  Bio
Date Wed 27 May 2009 03:42 PM (UTC)
Message
As the title implies, I am having a bit of trouble getting a plug-in capturing numerical values like it should. All of the triggers seem to be working perfectly, and when tested offline each mechanism seems to work. However, in-game there seems to be some sort of each. The code below is the specific portion which should capture the numerical values, but doesn't. I'll explain what each is suppose to do in further detail if necessary.




  <trigger
   expand_variables="y"
   group="Forging"
   ignore_case="y"
   match="Damage: *  Precision: *  Speed: *"
   send_to="12"
   sequence="100"
  >
  <send>if %1 &lt; @min_damage then
   SetVariable ("reforge", "on")
   SetVariable ("next", "on")
   Execute ("reforge")
elseif %2 &lt; @min_precision then
   SetVariable ("reforge", "on")
   SetVariable ("next", "on")
   Execute ("reforge")
elseif %3 &lt; @min_speed then
   SetVariable ("reforge", "on")
   SetVariable ("next", "on")
   Execute ("reforge")
end -- if</send>
  </trigger>
  <trigger
   expand_variables="y"
   group="Forging"
   ignore_case="y"
   match="Physical blunt:          *"
   send_to="12"
   sequence="100"
  >
  <send>if @stat_cut &lt; @min_cut then
   SetVariable ("reforge", "on")
   SetVariable ("next", "on")
   Execute ("reforge")
elseif @reforge == on then
   SetVariable ("reforge", "off")
   SetVariable ("next", "on")
elseif %1 &lt; @min_blunt then
   SetVariable ("reforge", "on")
   SetVAriable ("next", "on")
   Execute ("reforge")
end -- if</send>
  </trigger>
  <trigger
   expand_variables="y"
   group="Forging"
   ignore_case="y"
   match="Physical cutting:          *"
   send_to="12"
   sequence="100"
  >
  <send>SetVariable ("stat_cut", "%1")</send>
  </trigger>
</triggers>

if me = "confused" then
SetVariable ("idiot", "yes")
Send ("choke")
DoAfter (3, "curse")
else Send ("fist pumpage")
end -- if
Top

Posted by Aidyn.Hartfire   USA  (15 posts)  Bio
Date Reply #1 on Wed 27 May 2009 03:45 PM (UTC)
Message
Additional quick question, could it be that the plug-in needs the "to number" function coded in? I apologize if this seems silly, but I haven't coded in forever, so if someone could be patient enough to answer that would be great.

if me = "confused" then
SetVariable ("idiot", "yes")
Send ("choke")
DoAfter (3, "curse")
else Send ("fist pumpage")
end -- if
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #2 on Wed 27 May 2009 04:32 PM (UTC)
Message
Anytime you have a string which is supposed to be a number, you probably want to call "tonumber" on it to do the conversion.

Also, when reporting a problem with a plugin, it's generally useful to give an example of what doesn't work: show what you expected to happen, and then show what actually happens. This helps us get information needed to figure out what's going on.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 27 May 2009 09:09 PM (UTC)
Message
As David says, it helps to state what sort of "trouble" you are having. Is there an error message? If so, what is it? Something like "attempting to perform arithmetic on a nil value" would tend to narrow it down a bit.

Also some test cases. If the plugin works some of the time, a comparison of the conditions which work, and those that don't, would help.

One idea springs to mind is that the numbers you are extracting may have commas in them. So for example, if the plugin works if the damage is 987, but not when it is 1,012 then the comma after the "1" is probably the cause.

You can use string.gsub to remove commas.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Aidyn.Hartfire   USA  (15 posts)  Bio
Date Reply #4 on Wed 27 May 2009 10:45 PM (UTC)
Message
Right, sorry for being so vague. I was a bit rushed earlier. Anyhow, the plug-in is forging things in the game Lusternia. Essentially, there should not be any number which has more than three digits, as armor with a rating of 90 or above is ideal with anything in the 100s perfect. I've never heard of anyone having something greater than 110 or so. Weapons are slightly different, but I don't think they would exceed 300. If that.

The two primary triggers would be:


  <trigger
   expand_variables="y"
   group="Forging"
   ignore_case="y"
   match="Damage: *  Precision: *  Speed: *"
   send_to="12"
   sequence="100"
  >



Which should activate on a line such as:


Damage: 150  Precision: 170  Speed: 200



Then do the following:


<send>if %1 &lt; @min_damage then
   SetVariable ("reforge", "on")
   SetVariable ("next", "on")
   Execute ("reforge")
elseif %2 &lt; @min_precision then
   SetVariable ("reforge", "on")
   SetVariable ("next", "on")
   Execute ("reforge")
elseif %3 &lt; @min_speed then
   SetVariable ("reforge", "on")
   SetVariable ("next", "on")
   Execute ("reforge")
end -- if



Where if the first number is less than the number specified in the variable min_damage then it should break the item down into it's key components and remake the item. The same goes for all three numbers. All three have to meet or exceed the minimum set for it.

Now, every other component of the plug-in works flawlessly, except for capturing the numbers properly. Instead it always reforges, which is a pain because then I cannot leave it unattended. I think I'll give a shot to converting the strings to numbers and see if that works.

if me = "confused" then
SetVariable ("idiot", "yes")
Send ("choke")
DoAfter (3, "curse")
else Send ("fist pumpage")
end -- if
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Wed 27 May 2009 11:35 PM (UTC)
Message
In this particular case, using tonumber should not be necessary. I would put in debugging displays to see what is happening. For example, maybe something else is reforging. ;)

Something like this:


if %1 &lt; @min_damage then
   SetVariable ("reforge", "on")
   SetVariable ("next", "on")
   Execute ("reforge")
   print ("reforging because damage (%1) less than minimum (@min_damage)")
elseif %2 &lt; @min_precision then
   SetVariable ("reforge", "on")
   SetVariable ("next", "on")
   Execute ("reforge")
   print ("reforging because precision (%2) less than minimum (@min_precision)")
elseif %3 &lt; @min_speed then
   SetVariable ("reforge", "on")
   SetVariable ("next", "on")
   Execute ("reforge")
   print ("reforging because speed (%3) less than minimum (@min_speed)")
end -- if


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Aidyn.Hartfire   USA  (15 posts)  Bio
Date Reply #6 on Thu 28 May 2009 01:58 AM (UTC)
Message
It seems to be working properly after having used tonumber. Who knows. If I go over the log file in the morning and find that it wasn't executing properly then I'll make the change you suggested, Nick.

if me = "confused" then
SetVariable ("idiot", "yes")
Send ("choke")
DoAfter (3, "curse")
else Send ("fist pumpage")
end -- if
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.


21,249 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.