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 those that are code-stupid

Stat Roller for those that are code-stupid

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


Pages: 1  2 3  

Posted by Mapper   (20 posts)  Bio
Date Reply #15 on Sat 19 Jul 2003 09:29 PM (UTC)
Message
Did so.

Nope. Still getting:

Rejected total stats of 0
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #16 on Sat 19 Jul 2003 10:02 PM (UTC)
Message
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.

- Nick Gammon

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

Posted by Mapper   (20 posts)  Bio
Date Reply #17 on Sat 19 Jul 2003 10:37 PM (UTC)
Message
<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.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #18 on Sat 19 Jul 2003 11:06 PM (UTC)

Amended on Sat 19 Jul 2003 11:07 PM (UTC) by Nick Gammon

Message
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>



- Nick Gammon

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

Posted by Mapper   (20 posts)  Bio
Date Reply #19 on Sun 20 Jul 2003 01:08 AM (UTC)

Amended on Sun 20 Jul 2003 01:21 AM (UTC) by Mapper

Message
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*
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #20 on Sun 20 Jul 2003 04:38 AM (UTC)

Amended on Sun 20 Jul 2003 04:43 AM (UTC) by Nick Gammon

Message
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>

- Nick Gammon

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

Posted by Mapper   (20 posts)  Bio
Date Reply #21 on Sun 20 Jul 2003 04:55 AM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #22 on Sun 20 Jul 2003 06:30 AM (UTC)
Message
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 

- Nick Gammon

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

Posted by Mapper   (20 posts)  Bio
Date Reply #23 on Sun 20 Jul 2003 06:40 AM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #24 on Sun 20 Jul 2003 07:18 AM (UTC)
Message
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.

- Nick Gammon

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

Posted by Dubthach   (47 posts)  Bio
Date Reply #25 on Mon 21 Jul 2003 12:26 PM (UTC)
Message
LOL. It might be easier if Nick could just log into the Mud to test the triggers.
Top

Posted by Mapper   (20 posts)  Bio
Date Reply #26 on Tue 29 Jul 2003 03:31 AM (UTC)

Amended on Tue 29 Jul 2003 03:41 AM (UTC) by Mapper

Message
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.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #27 on Wed 30 Jul 2003 09:54 PM (UTC)
Message
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.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #28 on Wed 30 Jul 2003 09:57 PM (UTC)
Message
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.

- Nick Gammon

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

Posted by Mapper   (20 posts)  Bio
Date Reply #29 on Wed 30 Jul 2003 11:39 PM (UTC)

Amended on Wed 30 Jul 2003 11:47 PM (UTC) by Mapper

Message
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*
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.


102,036 views.

This is page 2, subject is 3 pages long:  [Previous page]  1  2 3  [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.