[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Simpleton's Instructions on a trigger function

Simpleton's Instructions on a trigger function

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


Posted by Arnumor   (11 posts)  [Biography] bio
Date Wed 13 Aug 2008 05:03 AM (UTC)
Message
I am crafting items in the mud I'm playing, and I want to make a trigger, with the simplest possible method, that will recognize a variable number in the trigger phrase, and have it return the number that comes after that number.

For instance:

I see, in my inventory:

An ivory band marked 1

The trigger phrase is 'An ivory band marked *

I want the trigger to return 'makejewelry finger An ivory band marked (In this case, 2, because when counting, 2 comes after 1.)'

I want the trigger to work no matter what the number represented by the asterisk is. If the variable number that I see from the mud is 5, I want my next crafted item to be marked with a 6.

I know ABOSULUTELY NOTHING about scripting, coding, etc. I'd like it if someone could tell me, in detail, how I can acheive this.

I'm sure that's a tall order.. you'll likely have to resort to very, very simple terms for me to get what you're telling me.

Overall, please answer in a way that a casual user can understand.
[Go to top] top

Posted by Bottomfeeder   (42 posts)  [Biography] bio
Date Reply #1 on Wed 13 Aug 2008 08:33 PM (UTC)

Amended on Wed 13 Aug 2008 08:40 PM (UTC) by Bottomfeeder

Message
Well I'm still learning this crap, so hopefully someone who's a scripting genius can make this happen a lot cleaner but here's one way to do it...

Right click anywhere on the main mud window and select World Configuration.

Go to the Variable section, create a new variable to hold the count of your crafted items...lets say: craftCount

Go to the Aliases section, create an alias called: craftRings and put this in it:
SetVariable("craftCount", @craftCount + 1)
Send("makejewelry finger An ivory band marked @craftCount")

Finally, go to the Triggers section, create a new trigger that looks for:
An ivory band marked *

In the send box put:
SetVariable("craftCount", %1)
Execute("craftRings")

Make sure the checkbox on the side is selected to Expand Variables.

So if you look into your inventory the trigger will see the ring marked 1, set the variable to 1, call the alias that will add 1 to the variable and send the command to create the next ring using that count.

Once again I'm still pretty green but this should do what I think you're wanting.
[Go to top] top

Posted by Nick Gammon   Australia  (22,985 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Wed 13 Aug 2008 09:28 PM (UTC)

Amended on Wed 13 Aug 2008 09:29 PM (UTC) by Nick Gammon

Message
One approach is like this. First I decided to separate them into a trigger and an alias, because you don't necessarily want to make jewelry every time you check your inventory.

The trigger detects the number you have in your inventory and uses "send to variable" to update the variable ivory_band_number.

The alias "mj" adds 1 to that variable, saves it back, and then starts making the band.


<triggers>
  <trigger
   enabled="y"
   match="An ivory band marked *"
   send_to="9"
   sequence="100"
   variable="ivory_band_number"
  >
  <send>%1</send>
  </trigger>
</triggers>

<aliases>
  <alias
   match="mj"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
require "var"

var.ivory_band_number = var.ivory_band_number + 1

Send ("makejewelry finger An ivory band marked " .. var.ivory_band_number)

</send>
  </alias>
</aliases>




See http://mushclient.com/pasting for how to copy that into the client.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Arnumor   (11 posts)  [Biography] bio
Date Reply #3 on Thu 14 Aug 2008 03:06 AM (UTC)
Message
Okay well, neither of those posts helped much, because neither method worked.

For one, what script language did each of you post for?

Bottomfeeder, I think it'd be nice if I knew what the alias and the trigger should be set to 'send to'.

Third, I figured out how to make of use of the VBscript setvariable command. What I need to know now is how to(using VBscript preferrably, since I like it's form) make say, an alias that will take the numerical content of a veriable and add a number to it, so that the contents can then be changed to the original contents, plus said number.

For instance, the BandCount variable contains 1.

I want to know the command I can use via VBscript to make the variable's contents change to 2, by adding 1 to the current.

I apologize if I seem like a stickler for simple terms, but it's about the best I can manage. I'm having a hard time wrapping my mind around the functions.
[Go to top] top

Posted by Nick Gammon   Australia  (22,985 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Thu 14 Aug 2008 04:26 AM (UTC)

Amended on Thu 14 Aug 2008 04:27 AM (UTC) by Nick Gammon

Message
I posted for Lua as that is the recommended scripting language these days.

I was using the "var" module. A rewrite without that looks like this:


SetVariable ("ivory_band_number",  GetVariable ("ivory_band_number") + 1)

Send ("makejewelry finger An ivory band marked " .. GetVariable ("ivory_band_number"))


Lua automatically converts to numbers when it sees addition, but to be explicit you could do this:


SetVariable ("ivory_band_number",  tonumber (GetVariable ("ivory_band_number")) + 1)

Send ("makejewelry finger An ivory band marked " .. GetVariable ("ivory_band_number"))


That would look very similar in VBscript, except you use CInt (Convert to Integer), like this:


SetVariable ("ivory_band_number",  CInt (GetVariable ("ivory_band_number")) + 1)

Send "makejewelry finger An ivory band marked "  & GetVariable ("ivory_band_number")




- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Bottomfeeder   (42 posts)  [Biography] bio
Date Reply #5 on Thu 14 Aug 2008 02:12 PM (UTC)
Message
Worked on my end. As far as the send to setting...experiment and learn.
[Go to top] top

Posted by Arnumor   (11 posts)  [Biography] bio
Date Reply #6 on Thu 14 Aug 2008 06:59 PM (UTC)
Message
Thanks a ton, that is exactly the sort of watered-down version I was looking for. Maybe eventually I'll understand the faster method.
[Go to top] top

Posted by Arnumor   (11 posts)  [Biography] bio
Date Reply #7 on Thu 14 Aug 2008 07:37 PM (UTC)
Message
I switched to using Lua, which was apparently the best course of action. It seems a lot smoother, from what I can tell, and easier to understand. After getting that trigger/alias/variable combo to work, I was able to grasp scripting surprisingly more. I really appreciate the help.
[Go to top] 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.


20,354 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]