Trying to do some Math

Posted by Trinity on Fri 03 Mar 2006 06:42 PM — 5 posts, 19,461 views.

#0
I will straight from the beginning. I have no idea what I'm doing. I have part of a script written for an alias but I can't get the alias to work and I'm not sure how I'm suppose to add it to MUSH.

This is what I have so far.

sub nap (thename, theoutput, thewildcards)
world.SetVariable "napb", %2 - %1
world.SetVariable "napc", CInt (GetVariable ("napb")) / 6
world.SetVariable "naptime", CInt (GetVariable ("napc")) * 20
world.note "Wait" & world.getvariable ("naptime") & "seconds"
world.doafter world.getvariable("naptime")
world.note "Wake time"
end sub

Pretty much, I want an alias that I can hit just before I hit a command in the game that is used to speed up healing. So I can hit the alias "nap" plus two numbers. The first being how much hp I have now and the second being how much my max hp is. So I would type "nap * *" Where "*" is two different numbers. Any and all help would be most appreciated.
Australia Forum Administrator #1
Your script seems to be doing more than what you described. It also seems more complex than is required. You can do the whole thing in "send to script", like this:


<aliases>
  <alias
   match="nap * *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
Note "HP to go: " &amp; %2 - %1
</send>
  </alias>
</aliases>


See this posting for how to directly paste the above into MUSHclient:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4777

#2
The reason it looks so complex is that in order to know how long I need to rest in the game, I have to find out the amount of hp I need to heal, divide that number but how much I heal in a tick (which is 6) and then times it by 20 seconds (20 seconds = 1 tick). I was trying to make a note pop up after the amount of seconds I need to wait so I can just hit enter after that to "wake up".
Australia Forum Administrator #3
Sure, you just have to do the maths. Your original use of DoAfter isn't quite right, read the help file for examples. Say you want to note after 10 seconds then just do this:


DoAfterNote 10, "Wake time"


In your case you do a bit of arithmetic to replace the number 10 with your calculation.
#4
Thanks for your help! I was able to get it to work exactly like I wanted to from there! Thanks a ton!