Table? help. Not sure, really..

Post Reply
Mr.Toodles
Posts: 2
Joined: Sun Mar 08, 2015 8:19 pm

Table? help. Not sure, really..

Post by Mr.Toodles »

The mud output a line with a series of random actions I need to perform before I can advance. Obviously I want to be able to do this automatically but am lost on this part. Every other piece I need to automate this is complete except for this last step. So any help in solving this and helping me to learn to make it work would be greatly appreciated.

The line I receive is like so..

Great Job! Let's Advance. ( waveright sit sneer clenchright stand laugh )

All the commands it gives are random, so is the amount of commands. And there is no divider between them.
I need to take that list and do them in order.

Thanks in advance, forum peeps!

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Table? help. Not sure, really..

Post by Akaya »

Create a new trigger. Insert this as the pattern:
Code: [show] | [select all] lua
^Great Job! Let's Advance\. \((.*)\)$
Select perl regex from the drop down menu.
In the big white space insert:
Code: [show] | [select all] lua
local actions = string.split( matches[2], " ")
for _,v in pairs(actions) do send(v) end
Click Save Item.

This was written from my phone.

Mr.Toodles
Posts: 2
Joined: Sun Mar 08, 2015 8:19 pm

Re: Table? help. Not sure, really..

Post by Mr.Toodles »

Wow.. That was a whole lot easier than I thought it would be. And it works perfectly.. at least as far as I said I needed.

My only issue now is that some of the commands the mud spits at me are things it knows would be an alias and uses that to "mess you up".
I know I need to set variables for certain things, but I have no idea how to make this trigger use those commands instead of what the mud line is.

For instance..

Great work. Let's Advance! ( clenchright 1 focus rest )

When it shows that 1, I want it to spell one and not send 1.

How would I do that?

And thank you so very much for this help! I've been playing this game for YEARS and have been stuck on figuring out how to do this! Such a life saver!

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Table? help. Not sure, really..

Post by Akaya »

Add a table with the numbers and their words as the keys and values.
Code: [show] | [select all] lua
local numbers = {
  ["1"] = "one",
  ["2"] = "two",
  ["3"] = "three",
  -- and so on
}
Then check your action list against this table to see if there's a match.
Code: [show] | [select all] lua
local numbers = {
  ["1"] = "one",
  ["2"] = "two",
  ["3"] = "three",
  -- and so on
}
local actions = string.split( matches[2], " ")
for _,v in pairs(actions) do 
  if table.contains( numbers, v ) then
    v = numbers[v]
  end
  send(v) 
end

Post Reply