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 ➜ Adding wildcards together

Adding wildcards together

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


Posted by Brothfeder   (16 posts)  Bio
Date Sun 26 Jul 2015 11:22 AM (UTC)

Amended on Sun 26 Jul 2015 11:24 AM (UTC) by Brothfeder

Message
I'm trying to create a trigger that will SAY the solution to simple word problems.


The MUD says:
If 2 foxes got together with 74 foxes and 46 came later, how many foxes?

You say: 122

How might I approach this? As the title suggests I've been trying to use wildcards.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 26 Jul 2015 08:17 PM (UTC)
Message
Take a stab at it and post your attempt.

I suggest you would use a small script, and add them together. Make sure you do tonumber () on them so you add the numbers together, not add two strings.

- Nick Gammon

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

Posted by Brothfeder   (16 posts)  Bio
Date Reply #2 on Mon 27 Jul 2015 11:29 AM (UTC)

Amended on Mon 27 Jul 2015 07:44 PM (UTC) by Nick Gammon

Message
If you insist, Nick! I found a section on math in your FAQ, so this is basically a script you wrote. I haven't had a chance to test this yet...



<triggers>
  <trigger
   enabled="y"
   match="If * cows jumped into Runaway River and * drowned, how many cows would be left?"
   send_to="12"
   sequence="100"
  >
  <send>
x = tonumber (GetVariable ("x")) or 0

x = %1-%2  <---It could be %1*%2, or %1/%2, whatever you      need.

SetVariable ("x", x)

say ", </send>
  </trigger>
</triggers>


You had PRINT () where I simply have 'say ",', I assume that since I'm under <send> it will 'send' a say to the mud, but I don't know if it works that way. I supose I could have a second trigger that is enabled by this one. That will then SEND (say "variable") to the world.

Also, I'm guessing send_to="12" is like checking 'send to script' in Mush.

Appreciate your video/guide on scripting in Mushclient, and FAQ. Very helpful stuff. Any other LUA for the ignorant resources anyone is aware of?
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #3 on Mon 27 Jul 2015 07:48 PM (UTC)

Amended on Mon 27 Jul 2015 09:54 PM (UTC) by Nick Gammon

Message
It's a bit simpler than that. Assuming the question always has numbers in it, then this will do:


<triggers>
  <trigger
   enabled="y"
   match="If * cows jumped into Runaway River and * drowned, how many cows would be left?"
   send_to="12"
   sequence="100"
  >
  <send>

Send ("say " .. (%1 - %2))

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



Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.

- Nick Gammon

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

Posted by Brothfeder   (16 posts)  Bio
Date Reply #4 on Mon 27 Jul 2015 09:15 PM (UTC)
Message
I keep getting a compile error.

[string "Trigger: "]:1: unexpected symbol near '<'

I've created the trigger in MUSH, hit send to script, and put

<send>

Send (%1 - %2)

</send>

in the Send box.

Either way, even if it worked, It wouldn't say the answer, right? Wouldn't I have to create a variable so I could then

<send>
say @varname
</send>
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #5 on Mon 27 Jul 2015 09:51 PM (UTC)
Message
I left off my boilerplate:

Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


Quote:

Either way, even if it worked, It wouldn't say the answer, right? Wouldn't I have to create a variable so I could then ...


No, and that wouldn't work anyway. @Variables are converted at the start of the script, not during it.

What I had works.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #6 on Mon 27 Jul 2015 09:52 PM (UTC)

Amended on Mon 27 Jul 2015 09:54 PM (UTC) by Nick Gammon

Message
Just put:


  Send ("say " .. (%1 - %2))


in the Send box.

- Nick Gammon

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

Posted by Brothfeder   (16 posts)  Bio
Date Reply #7 on Mon 27 Jul 2015 10:16 PM (UTC)
Message
Ah okay, that works perfectly. Thanks for your patience and GENEROUS assistance. Seriously.
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.


21,229 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.