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 ➜ Multi-Line Auto Roller

Multi-Line Auto Roller

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


Pages: 1 2  

Posted by Nobble The Coding Newbie   (15 posts)  Bio
Date Wed 07 Jul 2004 03:47 AM (UTC)
Message
MUSHclient Version: 3.5
MUD: brokenseals.net

Syntax:

Strength : 14
Intelligence : 21
Wisdom : 11
Dexterity : 12
Constitution : 12

Do you wish keep these stats (y/n)?

I'm trying to figure out how to create an autoroller for a mud called brokenseals. I've been messing with some code from previous posts, but I haven't figured out how to do it yet! Argh! Thanks for any help anyone can give.

PS: [I've been working with triggers, but would a script be better? I'm a noob though so please don't flame me =)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 07 Jul 2004 03:54 AM (UTC)

Amended on Wed 07 Jul 2004 03:55 AM (UTC) by Nick Gammon

Message
Nowadays you can make a single multi-line trigger. They are a bit fiddly to look at, but pretty straightforward. You basically match on what you are expecting to see, replacing line breaks with \n and the variable numbers with (\d+) - things in brackets are saved as wildcards.

\d+ means "one or more digits"

The ?P<blah> syntax gives the wildcards a name, which you can then test in the send box.

Something like this, although I haven't tested it:


Match: 

Strength : (?P<str>\d+)\n
Intelligence : (?P<int>\d+)\n
Wisdom : (?P<wis>\d+)\n
Dexterity : (?P<dex>\d+)\n
Constitution : (?P<con>\d+)\n\z

Regular expression: checked
Multi-line: checked
Lines to match: 6

Send: (something like)

total = %<str> + %<int> + %<wis> + %<dex> + %<con>

if total < 40 then
  send "no"
else
  send "yes"
end if


- Nick Gammon

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

Posted by Nobble The Coding Newbie   (15 posts)  Bio
Date Reply #2 on Wed 07 Jul 2004 04:26 AM (UTC)
Message
Ok, I havent tested it yet, but could you guys take a look at it to make sure it's ok?

Syntax:

Strength : 14
Intelligence : 21
Wisdom : 11
Dexterity : 12
Constitution : 12

Do you wish keep these stats (y/n)?


My Test Code:

<triggers>
<trigger
enabled="y"
lines_to_match="6"
match="(?x)
^\s*Strength\:\s*(?P<str>\d+)\n
\s*Intelligence\:\s*(?P<int>\d+)\n
\s*Wisdom\:\s*(?P<wis>\d+)\n
\s*Dexterity\:\s*(?P<dex>\d+)\n
\s*Constitution\:\s*(?P<con>\d+)\n
\s*Charisma\:\s*(?P&lt;cha&gt;\d+)*$"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>

if %<str>; 20 or _
%<int>; 20 or _
%<wis>; 20 or _
%<dex>; 20 or _
%<con>; 20 then
ColourNote "white", "blue", "stats too low"
Send "N"
else
ColourNote "white", "blue", "accepted stats"
Send "Y"
end if

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


PS: Used some of your code on a previous post ^^
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 07 Jul 2004 06:40 AM (UTC)
Message
From your initial posting you need a space after "Strength" and before the colon.

To test this sort of thing, add the trigger, and then press Shift+Ctrl+F12 to bring up the "Debug simulated world input" screen.

Then paste in an example (like from your first post here) and see if the trigger fires, and if the calculations are correct.

If not, look carefully at the trigger to see why. You probably want a blank line before and after the text to make sure the trigger fires properly.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 07 Jul 2004 06:42 AM (UTC)
Message
Also, this looks wrong:


if %<str>; 20 or _
%<int>; 20 or _
%<wis>; 20 or _
%<dex>; 20 or _
%<con>; 20 then
ColourNote "white", "blue", "stats too low"
Send "N"
else
ColourNote "white", "blue", "accepted stats"
Send "Y"
end if


I think you mean:


if %<str> < 20 or _
%<int> < 20 or _
%<wis> < 20 or _
%<dex> < 20 or _
%<con> < 20 then
ColourNote "white", "blue", "stats too low"
Send "N"
else
ColourNote "white", "blue", "accepted stats"
Send "Y"
end if


- Nick Gammon

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

Posted by Nobble The Coding Newbie   (15 posts)  Bio
Date Reply #5 on Wed 07 Jul 2004 06:56 AM (UTC)
Message
Thanks for help =) I was working on it after I posted and fixed a few bugs. I'll post the whole thing when I get it working.
Top

Posted by Nobble The Coding Newbie   (15 posts)  Bio
Date Reply #6 on Wed 07 Jul 2004 07:09 AM (UTC)

Amended on Wed 07 Jul 2004 07:33 AM (UTC) by Nobble The Coding Newbie

Message
Argh, got stuck with a stupid error that I can't see.

ERROR: Line 13: Element name must start with a letter or an underscore, but starts with a " " (problem in this line)

CODE:

<triggers>
<trigger
enabled="y"
lines_to_match="5"
match="^\s*Strength\s*\:\s*(?P<str>\d+)\n\s*Intelligence\s*\:\s*(?P<int>\d+)\n\s*Wisdom\s*\:\s*(?P<wis>\d+)\n\s*Dexterity\s*\:\s*(?P<dex>\d+)\n\s*Constitution\s*\:\s*(?P<con>\d+)"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>

if %<str> < 20 or _
%<int> < 20 or _
%<wis> < 20 or _
%<dex> < 20 or _
%<con> < 20 then
ColourNote "white", "blue", "stats too low"
Send "N"
else
ColourNote "white", "blue", "accepted stats"
Send "Y"
end if

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

PS: I noticed someone stated that I should add a small pause before each reroll so as not to become a bandwith eating monster =)... How would I do this?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #7 on Wed 07 Jul 2004 07:27 AM (UTC)
Message
If you are trying to paste that in, you need to change the < to &lt; and > to &gt;.

eg.

<str> becomes &lt;str&gt;

Alternatively, manually add a trigger (in the GUI) and then paste the text from the appropriate parts into the box in the dialog.

- Nick Gammon

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

Posted by Nobble The Coding Newbie   (15 posts)  Bio
Date Reply #8 on Wed 07 Jul 2004 07:40 AM (UTC)
Message
[EDIT]MUSHclient -> File -> Import -> Clipboard is how I'm trying to add it.[/EDIT]

Ok, I'm getting the same error (same line also), but here is the updated code. Also, how would I add a wait to the reroll so it does not attack the server?
I was thinking it would need to go

ColourNote "white", "blue", "stats too low"
Send "N"
HERE

but I'm not sure how to add a wait. Anyway, here is the full code.

(Thanks for all the help. Especially since it's 2:40am CST)

CODE:

<triggers>
<trigger
enabled="y"
lines_to_match="5"
match="^\s*Strength\s*\:\s*(?P&lt;str&gt;\d+)\n\s*Intelligence\s*\:\s*(?P&lt;int&gt;\d+)\n\s*Wisdom\s*\:\s*(?P&lt;wis&gt;\d+)\n\s*Dexterity\s*\:\s*(?P&lt;dex&gt;\d+)\n\s*Constitution\s*\:\s*(?P&lt;con&gt;\d+)"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>

if %&lt;str&gt; < 20 or _
%&lt;int&gt; < 20 or _
%&lt;wis&gt; < 20 or _
%&lt;dex&gt; < 20 or _
%&lt;con&gt; < 20 then
ColourNote "white", "blue", "stats too low"
Send "N"
else
ColourNote "white", "blue", "accepted stats"
Send "Y"
end if

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

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #9 on Wed 07 Jul 2004 08:16 AM (UTC)

Amended on Wed 07 Jul 2004 08:17 AM (UTC) by Flannel

Message
Change the sends, to doafters.

world.doafter 1, "Y"
world.doafter 1, "N"

The number is time in seconds. So you can change it to suit your needs.

You wouldnt need to really wait with the note, although you could do that as well.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #10 on Wed 07 Jul 2004 10:34 AM (UTC)
Message
Quote:

if %&lt;str&gt; < 20 or _


You missed one there. That is:

if %&lt;str&gt; &lt; 20 or _


- Nick Gammon

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

Posted by Nobble The Coding Newbie   (15 posts)  Bio
Date Reply #11 on Wed 07 Jul 2004 04:25 PM (UTC)
Message
Ok thanks for all the help guys. It works like a charm. Here is the following code. (note: I had to enabel scripts on the scripts to run it)

"Note for other Newbies: the match=" is all one line. Use the symbols to make it look like they syntax you need, then make it all one line. Also, I think you would need to change the lines_to_match="#" if you want to change it to suit your needs."

CODE:

<triggers>
<trigger
enabled="y"
lines_to_match="5"
match="^\s*Strength\s*\:\s*(?P&lt;str&gt;\d+)\n\s*Intelligence\s*\:\s*(?P&lt;int&gt;\d+)\n\s*Wisdom\s*\:\s*(?P&lt;wis&gt;\d+)\n\s*Dexterity\s*\:\s*(?P&lt;dex&gt;\d+)\n\s*Constitution\s*\:\s*(?P&lt;con&gt;\d+)"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>

if %&lt;str&gt; &lt; 20 or _
%&lt;int&gt; &lt; 20 or _
%&lt;wis&gt; &lt; 20 or _
%&lt;dex&gt; &lt; 20 or _
%&lt;con&gt; &lt; 20 then
ColourNote "white", "blue", "stats too low"
world.doafter 1, "N"
else
ColourNote "white", "blue", "accepted stats"
world.doafter 1, "Y"
end if

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

Posted by Verdammt   (4 posts)  Bio
Date Reply #12 on Fri 21 Jan 2005 07:40 PM (UTC)

Amended on Fri 21 Jan 2005 07:45 PM (UTC) by Verdammt

Message
alrighty, I play on a mud called Dark-Legacy, im working on one very similar, and ive just developed mine from yours.

Firstly an example of what im matching to:


You may now roll for your character's stats.
You may roll as often as you like.


    Strength: 10 (Average)
   Dexterity: 22 (Extremely nimble)
Constitution: 11 (Average)
Intelligence: 16 (Very smart)
      Wisdom: 11 (Average)
    Charisma: 21 (Exquisite)
        Luck: 11 (Average)

Keep? (Y/N)

    Strength: 10 (Average)
   Dexterity: 18 (Very nimble)
Constitution: 12 (Average)
Intelligence: 11 (Average)
      Wisdom: 16 (Wise)
    Charisma: 19 (Attractive)
        Luck: 15 (Lucky)

Keep? (Y/N)

    Strength: 13 (Hardy)
   Dexterity: 19 (Very nimble)
Constitution: 10 (Average)
Intelligence: 12 (Average)
      Wisdom: 12 (Average)
    Charisma: 19 (Attractive)
        Luck: 17 (Very lucky)

Keep? (Y/N)


And, this is what I've got as a trigger as a development
from his, I have scripting enabled, it sends to script,
matches the correct number of lines, I dont know what kind
of script this is... Also, I wanted it to calculate the
total of what it gets for stats, and post it on the screen.
My Reasoning for having a total AND the stats is so that I can setup a baseline for what I want, and then set up a target stat setting.

<triggers>
  <trigger
   enabled="y"
   lines_to_match="7"
   match="^\s*Strength:\s*(?P&lt;str&gt;\d+)\s*(?P&lt;avstr&gt;\d+)\n\s*Dexterity:\s*(?P&lt;dex&gt;\d+)\s*(?P&lt;avdex&gt;\d+)\nConstitution:\s*(?P&lt;con&gt;\d+)\s*(?P&lt;avcon&gt;\d+)\nIntelligence\:\s*(?P&lt;int&gt;\d+)\s*(?P&lt;avint&gt;\d+)\n\s*Wisdom\:\s*(?P&lt;wis&gt;\d+)\s*(?P&lt;avwis&gt;\d+)\n\s*Charisma\:\s*(?P&lt;cha&gt;\d+)\s*(?P&lt;avcha&gt;\d+)\n\s*Luck\:\s*(?P&lt;lck&gt;\d+)\s*(?P&lt;avlck&gt;\d+)"
   multi_line="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>

if %&lt;str&gt; &lt; 13 or _
%&lt;int&gt; &lt; 15 or _
%&lt;wis&gt; &lt; 15 or _
%&lt;dex&gt; &lt; 15 or _
%&lt;con&gt; &lt; 15 or _
%&lt;cha&gt; &lt; 5 or _
%&lt;lck&gt; &lt; 10 then
ColourNote "white", "blue", "stats too low"
world.doafter 1, "N"
else
ColourNote "white", "red", "accepted stats"
world.doafter 1, "Y"
end if

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



Now, to get it to add the total (i also want the total
to be part of the deciding factor, then would it be this(?)) And curious to find out how to get it to post the total:


<send>

total = %&lt;str&gt; + %&lt;int&gt; + %&lt;dex&gt; + %&lt;con&gt; + %&lt;cha&gt; + %&lt;lck&gt;

if %&lt;str&gt; &lt; 13 or _
%&lt;int&gt; &lt; 15 or _
%&lt;wis&gt; &lt; 15 or _
%&lt;dex&gt; &lt; 15 or _
%&lt;con&gt; &lt; 15 or _
%&lt;cha&gt; &lt; 5 or _
%&lt;lck&gt; &lt; 10 also
total < 107
ColourNote "white", "blue", "stats too low"
world.doafter 1, "N"
else
ColourNote "white", "red", "accepted stats"
world.doafter 1, "Y"
end if

</send>
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #13 on Tue 25 Jan 2005 02:42 AM (UTC)
Message
I would use the word "and" instead of "also", and assuming you are using VBscript I think you need a "then" after the if test.

What do you mean by "post" the total? Display it?

- Nick Gammon

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

Posted by Verdammt   (4 posts)  Bio
Date Reply #14 on Tue 25 Jan 2005 09:11 PM (UTC)
Message
as in to post it like the debug mode would I suppose that'd be display haha... yeah :/
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.


52,198 views.

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

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.