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 ➜ Random trigger

Random trigger

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


Posted by Ihavenoname   (7 posts)  Bio
Date Fri 21 Dec 2007 11:18 PM (UTC)
Message
How would you make it so when a trigger activates it has a random number of things it could send and it randomly chooses which of those to send


like for send i would need it to send one of these randomly

craft iron helm
craft iron sword
craft iron chestplate

ect

Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 22 Dec 2007 02:09 AM (UTC)
Message
Assuming you are using Lua scripting, you can "send to script", choosing an item from a list like this:


<triggers>
  <trigger
   enabled="y"
   match="something"
   send_to="12"
   sequence="100"
  >
  <send>

items = {
   "helm",
   "sword",
   "breastplate",
    }

local which_item = items [ math.random (1, #items) ]

Send ("craft iron " .. which_item)

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


- Nick Gammon

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

Posted by Ihavenoname   (7 posts)  Bio
Date Reply #2 on Sat 22 Dec 2007 03:00 AM (UTC)
Message
Ok this is what i get i have lua enabled. I check send to script.

ERROR:

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


Heres my trigger
Trigger: You finish smithing a iron *

Send:

<triggers>
<trigger
enabled="y"
match="You finish smithing a iron *."
send_to="12"
sequence="100"
>
<send>

items = {
"Full plate",
"leggings",
"greaves",
"Crown",
}

local which_item = items [ math.random (1, #items) ]

Send ("smith iron " .. which_item)

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

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 22 Dec 2007 03:50 AM (UTC)
Message
See http://www.mushclient.com/pasting

- Nick Gammon

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

Posted by Ihavenoname   (7 posts)  Bio
Date Reply #4 on Sat 22 Dec 2007 05:12 AM (UTC)
Message
Ok i want to spice this up a lil more and thanks for the help :P. Ok ive also added random materials to it to but what i need for it to do.. if i go to make an item with a type of material i dont have i need it to buy the material. Can i do this in the same trigger? Can you have more the one trigger in a trigger? im new to scripting..

the failed message is

You're not carrying right materials to make that.


<triggers>
<trigger
enabled="y"
match="You finish smithing a *."
send_to="12"
sequence="100"
>
<send>
materials = {
"iron",
"steel",
"copper",
}

items = {
"Full plate",
"leggings",
"greaves",
"Crown",
}
Local which_material = materials [math.random (1, #materials) ]
local which_item = items [ math.random (1, #items) ]

Send ("smith " ..which_material which_item)

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

Posted by Ihavenoname   (7 posts)  Bio
Date Reply #5 on Sat 22 Dec 2007 05:15 AM (UTC)
Message
Also this seems to interfere with some triggers i set up for when i finished creating the item it would sell.

I just made several differnt triggers for this

Trigger: You finish smithing iron hammer

send: sell hammer

Trigger: You finish smithing iron helm

Send: sell helm
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Sat 22 Dec 2007 05:43 AM (UTC)
Message
Well you could check "keep evaluating" on the triggers, so that more than one fires. Or maybe you could have one trigger, once you make something you sell it (whatever it is) and then make something else.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


18,427 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.