Stat Roller for those that are code-stupid

Posted by Mapper on Fri 18 Jul 2003 09:06 PM — 38 posts, 135,412 views.

#0
K, I play a MUD where stat rolling is important. You can miss out on a lot if you don't get a good roll.

I have seen your huge, code intensive roller someone else asked about.

The thing is, I'm an idiot when it comes to code. I can make simple triggers and aliases, but I'm not a coder and I can't do anything special with MUSHclient.

Is there any way I can get or make a stat roller that's not horribly difficult for your code-moronic people to understand?

Is there something I can plug in to MUSHclient, or am I going to have to struggle with coding in order to get a character with a good roll?

Frankly if code is what I have to work with, I'll have to stick with a pen, paper, calculator and 5 hours of my time to spare.


I'm hoping and praying there's a simpler, easier-to-understand way to do this.
Amended on Fri 18 Jul 2003 09:08 PM by Mapper
Australia Forum Administrator #1
The problem is, a lot of MUDs send the stats in a different way, so it is hard to do a general one.

However if you post your exact output, someone may do an example for you. :)
#2
Alrighty. You go in, pick your class and have to roll. For instance, I created a character, a human mage.

The numbers I start with are:

[Str: 42 Int: 55 Wis: 49 Dex: 39 Con: 39]
Keep these stats? (Y/N)

Now, I need to be able to have it roll until it reaches a specific total number, obviously. Each race and class has it's own "good" rolls, so the number of the total stats has to be veriable.

I should be able to specify that I'd like it to continue rolling until it reaches 230 total, for example, and until it gets to that number, adding up the stats, it continues to input "N" into the client for no.

When it hits my specified number, it should select "yes" automatically.

I've only played this one mud, so I have no idea if it works the same on all of them. Pardon me if I'm giving you information you're already aware of.
Australia Forum Administrator #3
OK, that looks easy enough. You need a couple of triggers (one for each line) and an alias to set up the total you want ...



<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="[Str: * Int: * Wis: * Dex: * Con: *]"
   send_to="12"
   sequence="100"
  >
  <send>
SetVariable "str", "%1"
SetVariable "int", "%2"
SetVariable "wis", "%3"
SetVariable "dex", "%4"
SetVariable "con", "%5"
</send>
  </trigger>
  <trigger
   custom_colour="3"
   enabled="y"
   match="Keep these stats? (Y/N)*"
   send_to="12"
   sequence="100"
  >
  <send>dim total

total = CInt (GetVariable ("str")) _
      + CInt (GetVariable ("int")) _
      + CInt (GetVariable ("wis")) _
      + CInt (GetVariable ("dex")) _
      + CInt (GetVariable ("con"))

if total &gt;= CInt (GetVariable ("total_wanted")) then
  Send "Y"
  Note "** Accepted total stats of " &amp; total
else
  Send "N"
  Note "Rejected total stats of " &amp; total
end if

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

<aliases>
  <alias
   match="stats *"
   enabled="y"
   variable="total_wanted"
   send_to="9"
   sequence="100"
  >
  <send>%1</send>
  </alias>
</aliases>





Copy between the lines and go into MUSHclient File menu, select Import and click on Clipboard. That should install it all.

Then type:

stats 230

(or whatever figure) and that will set up a variable to remember the total you are aiming for. Don't make it too high or you will spam the MUD as the total will never be reached.

Then when you connect the first trigger will match and remember the settings for each entry (str, dex, wis and so on) into variables.

Then the second trigger (Keep these stats? (Y/N)) adds them together and compares to your limit, and sends Y or N.
Amended on Fri 18 Jul 2003 11:20 PM by Nick Gammon
#4
I did as you instructed and got:

Line 6: Value '12' too large in numeric attribute named 'send_to'. Range is 0 to 9. (trigger not loaded)
Line 21: Value '12' too large in numeric attribute named 'send_to'. Range is 0 to 9. (trigger not loaded)
Line 49: Attribute not used: send_to="9" (alias)
Line 50: Attribute not used: sequence="100" (alias)
Australia Forum Administrator #5
Sounds like you have an earlier version of MUSHclient. These fancy "send to script" things are supported in the latest version.
#6
K, let's totally start over here instead of editing to death.

I downloaded 3.42 and it accepted the stuff. Now, it keeps telling me:


Keep these stats? (Y/N) [Str: 20 Int: 69 Wis: 46 Dex: 48 Con: 29]
N
rejected total stats of 223
Keep these stats? (Y/N) [Str: 25 Int: 75 Wis: 58 Dex: 51 Con: 25]
N
Rejected total stats of 223


Even thought the numbers are changing and some are NOT adding up to 223.
Amended on Sat 19 Jul 2003 03:43 AM by Mapper
Australia Forum Administrator #7
You can see it is merging together the lines about keeping the stats, and the next line of stats.

Change the match string to have an extra wildcard, like this:


match="*[Str: * Int: * Wis: * Dex: * Con: *]"

That first asterisk will match the other stuff.

Then change each wildcard to add 1 to it (to skip the first one), like this:


SetVariable "str", "%2"
SetVariable "int", "%3"
SetVariable "wis", "%4"
SetVariable "dex", "%5"
SetVariable "con", "%6"
#8
Well, now instead of saying "rejected stat of 223", it's saying "rejected stat of 0"

I tried tweaking and got:

[Str: 42 Int: 54 Wis: 45 Dex: 43 Con: 36]
Keep these stats? (Y/N) [Str: 42 Int: 50 Wis: 49 Dex: 43 Con: 45]
Keep these stats? (Y/N) Keep these stats? (Y/N)

It's making me manually enter No, now.

Ugh. I hate code, I hate code...
Amended on Sat 19 Jul 2003 04:24 AM by Mapper
USA #9
Change the total calculation slightly to recalc as it receives and sets each variable, kinda like:

SetVariable "str", "%2"
total = CInt (GetVariable ("str"))
SetVariable "int", "%3"
total = CInt (total + ("int"))
SetVariable "wis", "%4"
total = CInt (total + ("wis"))
SetVariable "dex", "%5"
total = CInt (total + ("dex"))
SetVariable "con", "%6"
total = CInt (total + ("con"))


You'll probly also want to set total to 0 at the beginning of each iteration of the loop if you do this otherwise it will guarantee an acceptance of the 2nd roll.
#10
"You'll probly also want to set total to 0 at the beginning of each iteration of the loop if you do this otherwise it will guarantee an acceptance of the 2nd roll."


Hahahah. That makes no sense. I don't even know what an iteration is.

I'm a code moron, remember? :)

Anyway, now I'm getting:

Type mismatch: 'CInt'
Line in error:



I'm afraid I've screwed somethign up horribly.
Amended on Sat 19 Jul 2003 04:27 AM by Mapper
Australia Forum Administrator #11
Meerclar, you left out a "getvariable" in your post.

Anyway, my method should have worked, and not needed tweaking. Can you copy and post the two triggers as you have amended them?
USA #12
Eh, guess thats why I shouldna be coding on 8 hours of sleep in the past week. Though in my defense, I did say "kinda like" the example I gave. As for why yours didnt work, I dunno either, it *should* have the way it was written but such is the world of microsoft. I also lied when I said it would need to be set to 0 at the beginning of each roll, the first stat would automatically clear the old total. (DUH!) Bad coder, no cookies for me. (Oh, wait, I don't have any anyway... )
#13
Sure:

"*[Str: * Int: * Wis: * Dex: * Con: *]"

SetVariable "str", "%2"
SetVariable "int", "%3"
SetVariable "wis", "%4"
SetVariable "dex", "%5"
SetVariable "con", "%6"





Keep these stats? (Y/N)*

total = CInt (GetVariable ("str")) _
+ CInt (GetVariable ("int")) _
+ CInt (GetVariable ("wis")) _
+ CInt (GetVariable ("dex")) _
+ CInt (GetVariable ("con"))

if total >= CInt (GetVariable ("total_wanted")) then
Send "Y"
Note "** Accepted total stats of " & total
else
Send "N"
Note "Rejected total stats of " & total
end if






I'm still getting:


keep these stats? (Y/N) [Str: 36 Int: 56 Wis: 51 Dex: 35 Con: 37]
N
Rejected total stats of 0
Australia Forum Administrator #14
Oh, OK, I see. The second trigger is firing to take precedence over the first one.

Edit the "*[Str: * Int: * Wis: * Dex: * Con: *]" trigger and change its sequence number to 90, so it fires first.
#15
Did so.

Nope. Still getting:

Rejected total stats of 0
Australia Forum Administrator #16
OK, let me see the whole thing, not just the lines I changed. In the trigger configuration window (where they are all listed) shift-click to select both triggers, then click "copy" and then paste the results into a message here.
#17
<triggers>
<trigger
custom_colour="2"
enabled="y"
match="&quot;*[Str: * Int: * Wis: * Dex: * Con: *]&quot;"
send_to="12"
sequence="90"
other_text_colour="black"
other_back_colour="black"
>
<send>SetVariable &quot;str&quot;, &quot;%2&quot;
SetVariable &quot;int&quot;, &quot;%3&quot;
SetVariable &quot;wis&quot;, &quot;%4&quot;
SetVariable &quot;dex&quot;, &quot;%5&quot;
SetVariable &quot;con&quot;, &quot;%6&quot;</send>
</trigger>
<trigger
custom_colour="3"
enabled="y"
match="Keep these stats? (Y/N)*"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
<send>dim total

total = CInt (GetVariable (&quot;str&quot;)) _
+ CInt (GetVariable (&quot;int&quot;)) _
+ CInt (GetVariable (&quot;wis&quot;)) _
+ CInt (GetVariable (&quot;dex&quot;)) _
+ CInt (GetVariable (&quot;con&quot;))

if total &gt;= CInt (GetVariable (&quot;total_wanted&quot;)) then
Send &quot;Y&quot;
Note &quot;** Accepted total stats of &quot; &amp; total
else
Send &quot;N&quot;
Note &quot;Rejected total stats of &quot; &amp; total
end if

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


Obviously the &quot; and &amp; stuff is " and & in the actual trigger, I'm sure I don't need to tell you that.
Australia Forum Administrator #18
You have double-quoted the trigger match string.

If you look carefully you will see the line:

match="&quot;*[Str: * Int: * Wis: * Dex: * Con: *]&quot;"

So, it is trying to match on "[Str ...

This won't match (the quotes won't be there) so it will get zero.

Either just edit the trigger to remove the quote at the start and end, or copy the triggers from below and replace them ...


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="*[Str: * Int: * Wis: * Dex: * Con: *]"
   send_to="12"
   sequence="90"
  >
  <send>SetVariable "str", "%2"
SetVariable "int", "%3"
SetVariable "wis", "%4"
SetVariable "dex", "%5"
SetVariable "con", "%6"</send>
  </trigger>
  <trigger
   custom_colour="3"
   enabled="y"
   match="Keep these stats? (Y/N)*"
   send_to="12"
   sequence="100"
  >
  <send>dim total

total = CInt (GetVariable ("str")) _
      + CInt (GetVariable ("int")) _
      + CInt (GetVariable ("wis")) _
      + CInt (GetVariable ("dex")) _
      + CInt (GetVariable ("con"))

if total &gt;= CInt (GetVariable ("total_wanted")) then
  Send "Y"
  Note "** Accepted total stats of " &amp; total
else
  Send "N"
  Note "Rejected total stats of " &amp; total
end if

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


Amended on Sat 19 Jul 2003 11:07 PM by Nick Gammon
#19
It's not double quoted when you actually go into the trigger and look at the match. I don't know why it copied that way when I did the highlight and clicked the copy button.

I entered the last code stuff you gave me, however, it's making me manually insert no or yes.

When I do type "N", it gives me:

[Str: 46 Int: 46 Wis: 46 Dex: 34 Con: 36]
Keep these stats? (Y/N) [Str: 38 Int: 52 Wis: 50 Dex: 38 Con: 43]
Keep these stats? (Y/N)

Which makes no sense.

*scratches her head*
Amended on Sun 20 Jul 2003 01:21 AM by Mapper
Australia Forum Administrator #20
Hmm - I am assuming now that the line that says: "Keep these stats? (Y/N)" does not have a newline at the end.

That is why the trigger isn't matching - it doesn't match until the newline arrives.

I have done it a different way below - remove the two triggers and replace with this (one trigger and one timer) - you can import them through the File menu -> Import -> Clipboard.

What this does is use a technique documented elsewhere:


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


This uses a 1-second timer to check to see if the line "Keep these stats? (Y/N)" has arrived, and if so, sends Y or N.

You may need to edit the script in the timer slightly to add a trailing space (eg. "Keep these stats? (Y/N) ") - note the space at the end - it isn't obvious from your post whether it is there or not.


<timers>
  <timer enabled="y" second="1"    send_to="12"
>
  <send>Dim iNumber

'
'  Find line number of last line in buffer
'
  iNumber = world.GetLinesInBufferCount
 
'
' Process if it:
'  a) does not have a newline at the end
'  b) is not a world.note line
'  c) is not player input
'

  if world.GetLineInfo (iNumber, 3) = 0 and _
     world.GetLineInfo (iNumber, 4) = 0 and _
     world.GetLineInfo (iNumber, 5) = 0 then
 
    sLine = world.GetLineInfo (iNumber, 1)

    if world.GetLineInfo (iNumber, 1) = _
       "Keep these stats? (Y/N)" then 
    
      if CInt (GetVariable ("total")) &gt;= _
         CInt (GetVariable ("total_wanted")) then
        Send "Y"
        Note "** Accepted total stats of " &amp; total
      else
       Send "N"
        Note "Rejected total stats of " &amp; total
      end if  ' end total not OK

    end if  ' end of "Keep these stats" line

  end if  ' end of output from MUD with no newline
</send>

  </timer>
</timers>

<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="*[Str: * Int: * Wis: * Dex: * Con: *]"
   send_to="12"
   sequence="100"
   >
  <send>SetVariable "total", %2 + %3 + %3 + %5 + %6</send>
  </trigger>
</triggers>
Amended on Sun 20 Jul 2003 04:43 AM by Nick Gammon
#21
I followed your directions exactly, but I must be doing something wrong.

This method does nothing but color the stats yellow. It sits there and does absolutely nothing.
Australia Forum Administrator #22
So, the timer isn't matching. Did you try adding a space? ie. change the lines:


if world.GetLineInfo (iNumber, 1) = _
       "Keep these stats? (Y/N)" then 


to


if world.GetLineInfo (iNumber, 1) = _
       "Keep these stats? (Y/N) " then 
#23
Actually, it was an error on my part. I only copied part of the code. I apologize for wasting your time in that way.

Anyway, with the code in properly, it outputs:

Rejected total stats of
[Str: 47 Int: 56 Wis: 47 Dex: 39 Con: 41]
Keep these stats? (Y/N)
N

It's not showing me the numbers, so I have no idea if it's passing up numbers lower than the "stats XXX" I input before I start.

Goodness.
Australia Forum Administrator #24
Does the line with the stats on it get coloured (ie. does the trigger fire?), and what, if anything, is the value of the variable "total"? You can check that from the variables configuration window.
#25
LOL. It might be easier if Nick could just log into the Mud to test the triggers.
#26
If Nick has the time and the inclination, I think it's an excellent idea.

Connect to dsl-mud.org on port 4000


There's a bit of character creation (physical traits and then pulling the rope for name approval) before the actual rolling process, so it can get tedious to go through after the millionth time.

Just a quick note that this MUD doesn't allow multi-playing (more than one character connected to them at the same time), even in creation mode, and doing it is immediate grounds for site banning. It's not a good idea to open more than one window for sake of time, unfortunately.
Amended on Tue 29 Jul 2003 03:41 AM by Mapper
Australia Forum Administrator #27
OK, this is the finished result. It worked for me. You hadn't added the extra space on the end of the question.


<aliases>
  <alias
   match="stats *"
   enabled="y"
   variable="total_wanted"
   send_to="9"
   sequence="100"
  >
  <send>%1</send>
  </alias>
</aliases>

<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="*[Str: * Int: * Wis: * Dex: * Con: *]"
   send_to="12"
   sequence="100"
   other_text_colour="black"
   other_back_colour="black"
  >
  <send>SetVariable "total", %2 + %3 + %3 + %5 + %6
Note "Calculated total stats of " &amp; GetVariable ("total")</send>
  </trigger>
</triggers>


<timers>
  <timer enabled="y" second="2"    send_to="12"
>
  <send>Dim iNumber

'
'  Find line number of last line in buffer
'
  iNumber = world.GetLinesInBufferCount
 
'
' Process if it:
'  a) does not have a newline at the end
'  b) is not a world.note line
'  c) is not player input
'

  if world.GetLineInfo (iNumber, 3) = 0 and _
     world.GetLineInfo (iNumber, 4) = 0 and _
     world.GetLineInfo (iNumber, 5) = 0 then

    sLine = world.GetLineInfo (iNumber, 1)

    if world.GetLineInfo (iNumber, 1) = _
       "Keep these stats? (Y/N) " then 
    
      if isempty (GetVariable ("total_wanted")) or _
         GetVariable ("total_wanted") &lt;= 0 then
         Note "Wanted stats not defined - type: stats &lt;number&gt;"
      else  

        if CInt (GetVariable ("total")) &gt;= _
           CInt (GetVariable ("total_wanted")) then
          Send "Y"
          Note "** Accepted total stats of " &amp; GetVariable ("total")
        else
         Send "N"
          Note "Rejected total stats of " &amp; GetVariable ("total")
          Note "Wanted " &amp; GetVariable ("total_wanted")

        end if  ' end total not OK

      end if   ' wanted stats defined

    end if  ' end of "Keep these stats" line

  end if  ' end of output from MUD with no newline</send>

  </timer>
</timers>




Just go to the File menu -> Import -> Clipboard. Before doing that, remove the existing one if it is still there.
Australia Forum Administrator #28
Here is some example output produced while I was sitting watching it ...


[Str: 43  Int: 55  Wis: 49  Dex: 41  Con: 41]
Calculated total stats of 235
Keep these stats? (Y/N) 
N
Rejected total stats of 235
Wanted 240
[Str: 42  Int: 50  Wis: 44  Dex: 35  Con: 39]
Calculated total stats of 216
Keep these stats? (Y/N) 
N
Rejected total stats of 216
Wanted 240
[Str: 44  Int: 50  Wis: 52  Dex: 45  Con: 43]
Calculated total stats of 232
Keep these stats? (Y/N) 
N
Rejected total stats of 232
Wanted 240
[Str: 47  Int: 58  Wis: 46  Dex: 36  Con: 41]
Calculated total stats of 240
Keep these stats? (Y/N) 
Y
** Accepted total stats of 240

Do you wish to customize this character?
Customization takes time, but allows a wider range of skills and abilities.
Customize (Y/N)? 
n


I added a couple of extra lines to show what it had calculated, and what the limit you set was.
#29
Works like a charm, now. *lol*

Thank you very much, I'm in your debt.

Edit: Or...it did, rather. I wasn't aware that in creation mode you see when people leave or join the game.

Wanted 235
[Str: 65 Int: 35 Wis: 53 Dex: 31 Con: 59]
Calculated total stats of 225
Keep these stats? (Y/N)
Eetba has left the game.


And it stops. It's no big deal because I can enter "N" myself and it will keep going, but I thought I'd mention it.


Edit 2: Also, scripting while away from the keyboard is also illegal in this game. I tried to go AFK and disabled the scripts, and recieved:

Send-to-script cannot execute because scripting is not enabled.

over and over and over. *L*
Amended on Wed 30 Jul 2003 11:47 PM by Mapper
Australia Forum Administrator #30
For the first problem, you could put back the original trigger I did - that will match on lines which *do* have a newline, which would apply in this case. Just check it matches the right thing (eg. the space on the end).

For the second problem, disable the *timer* which is what is responding to the message from the MUD.
#31
I don't know how to use triggers all that well with MUSHClient or anything else for that matter though, my stats show up in this format:

Attributes:
Str Int Wis Dex Con Cha Lck
16 17 16 17 16 14 16.

Please Select: (A)ccept, (R)eroll, or (H)elp stats

Those are the stats I am wanting to get if that helps at all.

There are 3 spaces between the different numbers up there as well.
Amended on Tue 22 Aug 2006 02:33 AM by Kazimir
USA #32
I'm having kind of the same problem, coding moron here as well, been trying these different forms of code here, just changing some of the strings to fit my mud. here is the stat rolling lines;

Rolling...
Strength: * Intelligence: * Wisdom: * Dexterity: * Constitution: *

Do these reflect your training (Y/N)?


As for the coding itself, I've changed very little, but still going to paste it here for extra help.

<triggers>
<trigger
custom_colour="2"
enabled="y"
match="*[Strength: * Intelligence: * Wisdom: * Dexterity: * Constitution: *]"
send_to="12"
sequence="90"
>
<send>
SetVariable "str", "%2"
SetVariable "int", "%3"
SetVariable "wis", "%4"
SetVariable "dex", "%5"
SetVariable "con", "%6"
</send>
</trigger>
<trigger
custom_colour="3"
enabled="y"
match="Do these reflect your training (Y/N)?"
send_to="12"
sequence="100"
>
<send>dim total

total = CInt (GetVariable ("str")) _
+ CInt (GetVariable ("int")) _
+ CInt (GetVariable ("wis")) _
+ CInt (GetVariable ("dex")) _
+ CInt (GetVariable ("con"))

if total &gt;= CInt (GetVariable ("total_wanted")) then
Send "Y"
Note "** Accepted total stats of " &amp; total
else
Send "N"
Note "Rejected total stats of " &amp; total
end if

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

<aliases>
<alias
match="stats *"
enabled="y"
variable="total_wanted"
send_to="9"
sequence="100"
>
<send>%1</send>
</alias>
</aliases>


hope that helps, if need be, the mud I'm trying to connect to is darkmist, connection info is;

darkmists.net 2222


I also tried the timer code and it didn't work either, but its closer to what I'm wanting, I'd love to see the total of the stats and what not so I know what I could get if by chance something happens and I put in to high of a number.

Thanks for the help in advance.
Amended on Mon 22 Aug 2011 05:35 PM by Shichiroji
USA #33
I was looking through the forum some more and ran across this trigger, it looks like it should work, but I'm getting an error. I know there is a lot of info on the forums, and I am looking, just trying different things and seeing if I can find one that works, but I'm not having much luck.

<triggers>
<trigger
custom_colour="2"
enabled="y"
match="Strength: * Intelligence: * Wisdom: * Dexterity: * Constitution: *"
send_to="12"
sequence="100"
>
<send>if (%1 + %2 + %3 + %4 + %5) &gt; 95 then
Send "Y"
else
Send "N"
end if</send>
</trigger>
</triggers>


error I'm getting is;

Compile error
World: Darkmist
Immediate execution
[string "Trigger: "]:5: unexpected symbol near '<eof>'
USA #34
Ok, got something going so far, was able to use the mushclient trigger system to get it working, this is the code I have so far, any help fixing it to show me a total for the stats would be great, going to continue to look through the forums too.

<triggers>
<trigger
enabled="y"
match="Strength: * Intelligence: * Wisdom: * Dexterity: * Constitution: *"
send_to="12"
sequence="100"
>
<send>if (%1 + %2 + %3 + %4 + %5) &gt; 95 then
Send "Y"
else
Send "N"
end</send>
</trigger>
</triggers>
USA #35
Ok, still working on it, haven't been able to get it, but still looking as well. Anybody have any suggestions to help?
Australia Forum Administrator #36
You already know the total because you are comparing it, right? So just print it:


print ("Total was:", %1 + %2 + %3 + %4 + %5)

USA #37
Thanks Nick, for some reason I just couldn't get it to work right. I think I was forgetting the comma.

Thanks again