Trying to simply life a bit, not geting anywhere

Posted by Jodans on Thu 24 Jul 2008 11:47 PM — 4 posts, 16,434 views.

#0
Ok so I'm trying to clean up my triggers a bit, but have no idea how to script what I am needing (if even possible).
The whole purpose of the triggers/script is to change the variables for a trigger that fires to two messages.
The first trigger fires and sends "research @variable"
I would like the second trigger to change @variable, every time it fires.
The end result is hopefully a 'queue' of variables to be loaded as the new variable fires off.
Here are the triggers I have right now, they might help get a good idea of what I mean:

<triggers>
<trigger
expand_variables="y"
group="eng"
match="You can't learn any more about that from books!"
name="a"
send_to="12"
sequence="100"
>
<send>EnableTrigger("b", true)
SetVariable("study", "@a")
SendImmediate("research @a")
EnableTrigger("a", false)</send>
</trigger>
</triggers>

<triggers>
<trigger
expand_variables="y"
group="eng"
match="You can't learn any more about that from books!"
name="b"
send_to="12"
sequence="100"
>
<send>EnableTrigger("c", true)
SetVariable("study", "@b")
SendImmediate("research @b")
EnableTrigger("b", false)</send>
</trigger>
</triggers>

<triggers>
<trigger
expand_variables="y"
group="eng"
match="You can't learn any more about that from books!"
name="c"
send_to="12"
sequence="100"
>
<send>EnableTrigger("d", true)
SetVariable("study", "@c")
SendImmediate("research @c")
EnableTrigger("c", false)</send>
</trigger>
</triggers>

And so on from here.
I would rather be able to just make a list of things for the variable to switch to when that match fires, rather than having to create 20 different triggers to enable/disable eachother.

There are multiple uses I have planned for this, so I am hoping someone can help me get this scripted.
Australia Forum Administrator #1
You are right to want to do that in a less complicated way. :)

Tables are your friends, using them you can simply step through a sequence of things. I made a single trigger that would handle any number of things you want to research:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   group="eng"
   match="You can't learn any more about that from books!"
   send_to="12"
   sequence="100"
  >
  <send>

-- things we need to research

booklist = booklist or {
  "wine",
  "women",
  "song",
  }

require "var"

-- move onto next one
var.bookitem = (var.bookitem or 0) + 1

-- end of list? all done! phew!
if tonumber (var.bookitem) &gt; #booklist then
  Note ("Done learning!")
  return
end -- if

-- research it
Send ("research " .. booklist [tonumber (var.bookitem)])

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


#2
Thank you very much, this is going to help a lot.

I thought it may be a table of some sort, but didn't know.
I can make the triggers pretty well, but when it comes to an actual script, I'm lost, though once I have what I need in front of me I can make changes to suit my needs.
I.E. this is going to be put in twice, for two different functions.

So for that variable to be used in a trigger is it @booklist we would be expanding?

Error number: 0
Event: Compile error
Description: [string "Script file"]:1: unexpected symbol near '<'
Called by: Immediate execution

I put the script into a notepad and renamed it to whatever.lua and when I close the script window after selecting that file as my script file that error pops up. I'm trying to find where it may be from, but not sure I'll be able to.
Amended on Fri 25 Jul 2008 10:17 AM by Jodans
Australia Forum Administrator #3
Read this: http://mushclient.com/pasting