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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Random trigger
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Random trigger

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


Posted by Ihavenoname   (7 posts)  [Biography] 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

[Go to top] top

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] 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
[Go to top] top

Posted by Ihavenoname   (7 posts)  [Biography] 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>
[Go to top] top

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] 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
[Go to top] top

Posted by Ihavenoname   (7 posts)  [Biography] 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>
[Go to top] top

Posted by Ihavenoname   (7 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,493 posts)  [Biography] 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
[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.


3,282 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 FutureQuest]