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 ➜ General ➜ Stat Roller for a non-coder

Stat Roller for a non-coder

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


Posted by LadyIsis   (6 posts)  Bio
Date Fri 14 Aug 2009 07:14 PM (UTC)

Amended on Fri 14 Aug 2009 07:15 PM (UTC) by LadyIsis

Message
I realize stat rollers are requested/asked for quite often, and I've searched through the various other posts and read them. However, I'm not a coder and it really just doesn't make sense to me... Would anyone mind explaining how to go about making an automated stat roller? Please be very, very basic, since I don't even really understand how to set up scripts.

The setup of the stats I'm looking for is:
Strength (St):  77( 93)   Constitution   (Co):  85( 98)
Quickness(Qu):  51( 73)   Agility        (Ag):  68( 94)
Presence (Pr):  32( 80)   Self-Discipline(Sd):  65( 93)
Empathy  (Em):  90( 95)   Memory         (Me):  43( 99)
Intuition(In):  71( 86)   Reasoning      (Re):  31( 85)
Accept these stats? (Y/N)



Any help would be appreciated!
Top

Posted by Blainer   (191 posts)  Bio
Date Reply #1 on Sat 15 Aug 2009 03:30 AM (UTC)
Message
That would require triggers to capture the numbers when the MUD sends them. Then a script in the trigger to process the
numbers. Say if Strength is 100 then accept this roll.

I would start with reading http://mushclient.com/scripts/doc.php?general=triggers.
This explains triggers. Get a trigger to capture numbers (probably have to be multi line trigger).

If you have trouble with getting the trigger to work use the instructions at the link below to paste what you have so far.
http://www.gammon.com.au/forum/?id=4777

Let me know how you go.
Top

Posted by LadyIsis   (6 posts)  Bio
Date Reply #2 on Sat 15 Aug 2009 09:07 PM (UTC)
Message
I think I've got a working trigger; I set it up to output look when it goes off, and it's doing so. I used a bit from an older thread to set the numbers as wildcards using (\d+). At least I think that's what it does.

What should I do next?
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 15 Aug 2009 09:31 PM (UTC)
Message
Say you have a trigger that matches on:


Strength (St):  *(*)   Constitution   (Co):  *(*)


That would be a start, as I replaced the numbers that change by an asterisk. And if it fires you have 4 wildcards. So I would do something like:


st = tonumber (%1)
max_st = tonumber (%2)
co = tonumber (%3)
max_co = tonumber (%4)


You need to change the "send" box to "send to script".

Now that has remembered those 4 stats.

Then do something similar for the other stats.

Finally make a trigger for "Accept these stats? (Y/N)".

Now you just compare and see what you want.

eg.


if st > 80 and
   co > 90 and
--- etc. etc.
   qu > 40 then

  Send ("Y")
else
  Send ("N")
end -- if


If you have problems please copy and paste here what you have actually done. See http://mushclient.com/copying.


- Nick Gammon

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

Posted by LadyIsis   (6 posts)  Bio
Date Reply #4 on Sat 15 Aug 2009 10:29 PM (UTC)
Message
Which scripting language is your example in?
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #5 on Sat 15 Aug 2009 10:35 PM (UTC)
Message
Lua.

- Nick Gammon

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

Posted by LadyIsis   (6 posts)  Bio
Date Reply #6 on Sat 15 Aug 2009 10:57 PM (UTC)
Message
Ok, so the script has the "if st > 80", right? I made a lua script with my version of all that... What goes under the trigger for "Accept these stats? Y/N"?
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #7 on Sat 15 Aug 2009 11:08 PM (UTC)
Message
Please copy and paste here what you have actually done. See http://mushclient.com/copying.

What I showed above (with the "if") is what you put in that trigger.

- Nick Gammon

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

Posted by LadyIsis   (6 posts)  Bio
Date Reply #8 on Sat 15 Aug 2009 11:25 PM (UTC)

Amended on Sat 15 Aug 2009 11:26 PM (UTC) by LadyIsis

Message
My initial trigger (so far) is:

<triggers>
  <trigger
   enabled="y"
   group="Multi Line"
   ignore_case="y"
   lines_to_match="5"
   keep_evaluating="y"
   match="Strength \(St\)\:\s*(\d+)\(\s*(\d+)\)   Constitution   \(Co\)\:\s*(\d+)\(\s*(\d+)\)\nQuickness\(Qu\)\:\s*(\d+)\(\s*(\d+)\)   Agility        \(Ag\)\:\s*(\d+)\(\s*(\d+)\)\nPresence \(Pr\)\:\s*(\d+)\(\s*(\d+)\)   Self\-Discipline\(Sd\)\:\s*(\d+)\(\s*(\d+)\)\nEmpathy  \(Em\)\:\s*(\d+)\(\s*(\d+)\)   Memory         \(Me\)\:\s*(\d+)\(\s*(\d+)\)\nIntuition\(In\)\:\s*(\d+)\(\s*(\d+)\)   Reasoning      \(Re\)\:\s*(\d+)\(\s*(\d+)\)\Z"
   multi_line="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>st = tonumber (%1)
max_st = tonumber (%2)
co = tonumber (%3)
max_co = tonumber (%4)
qu = tonumber (%5)
max_qu = tonumber (%6)
ag = tonumber (%7)
max_ag = tonumber (%8)
pr = tonumber (%9)
max_pr = tonumber (%10)
sd = tonumber (%11)
max_sd = tonumber (%12)
em = tonumber (%13)
max_em = tonumber (%14)
me = tonumber (%15)
max_me = tonumber (%16)
in = tonumber (%17)
max_in = tonumber (%18)
re = tonumber (%19)
max_re = tonumber (%20)</send>
  </trigger>
</triggers>


Right now, I've got nothing under the "Accept these stats" trigger:
<triggers>
  <trigger
   enabled="y"
   match="Accept these stats? (Y/N)"
   sequence="100"
  >
  </trigger>
</triggers>


I deleted the script, so what's above is all I have.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #9 on Sat 15 Aug 2009 11:46 PM (UTC)
Message
Ah I see you did a multi-line trigger. Very good, that saves a bit of effort.

A couple of problems ... The word "in" is a Lua keyword, so I changed that to "int". Also wildcards above 9 need to be put into <brackets> otherwise it would think, for example, %10 is wildcard 1 with a zero after it.

Since you have a multi-line trigger, we may as well do the test in this trigger and not use a second one. Below shows what I had in mind:


<triggers>
  <trigger
   enabled="y"
   group="Multi Line"
   ignore_case="y"
   lines_to_match="5"
   keep_evaluating="y"
  


match="Strength \(St\)\:\s*(\d+)\(\s*(\d+)\) Constitution \(Co\)\:\s*(\d+)\(\s*(\d+)\)\nQuickness\(Qu\)\:\s*(\d+)\(\s*(\d+)\) Agility \(Ag\)\:\s*(\d+)\(\s*(\d+)\)\nPresence \(Pr\)\:\s*(\d+)\(\s*(\d+)\) Self\-Discipline\(Sd\)\:\s*(\d+)\(\s*(\d+)\)\nEmpathy \(Em\)\:\s*(\d+)\(\s*(\d+)\) Memory \(Me\)\:\s*(\d+)\(\s*(\d+)\)\nIntuition\(In\)\:\s*(\d+)\(\s*(\d+)\) Reasoning \(Re\)\:\s*(\d+)\(\s*(\d+)\)\Z"


   multi_line="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

st = tonumber (%1)
max_st = tonumber (%2)
co = tonumber (%3)
max_co = tonumber (%4)
qu = tonumber (%5)
max_qu = tonumber (%6)
ag = tonumber (%7)
max_ag = tonumber (%8)
pr = tonumber (%9)
max_pr = tonumber (%<10>)
sd = tonumber (%<11>)
max_sd = tonumber (%<12>)
em = tonumber (%<13>)
max_em = tonumber (%<14>)
me = tonumber (%<15>)
max_me = tonumber (%<16>)
int = tonumber (%<17>)
max_int = tonumber (%<18>)
re = tonumber (%<19>)
max_re = tonumber (%<20>)

if st > 70 and
   co > 80 and
   qu > 50 and
   ag > 14 and
   pr > 17 and
   sd > 10 and
   me > 11 and
   int > 5 and
   re > 15 then
  Send ("Y")
else
  Send ("N")
end -- if

</send>
  </trigger>
</triggers>


- Nick Gammon

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

Posted by LadyIsis   (6 posts)  Bio
Date Reply #10 on Sun 16 Aug 2009 12:10 AM (UTC)

Amended on Sun 16 Aug 2009 12:31 AM (UTC) by LadyIsis

Message
That appears to have worked perfectly! For my own reference, can I can also switch the code up to denied if lower than stats, as in:


if max_st < 90 and
   max_co < 90 then
   Send ("N")
else
   Send ("Y")
end -- if
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #11 on Sun 16 Aug 2009 01:35 AM (UTC)
Message
Yes that should work.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


35,191 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.