Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Deladan
(40 posts) bio
|
| Date |
Tue 24 May 2011 08:41 PM (UTC) [ quote
] |
| Message |
Here goes, I'm trying to make a table that will track every person that I happen to enemy and then remove them when I unenemy them. The triggers would be
^(\w+) is now one of your enemies\.$
to add to the table
and
^You declare that (\w+) will no longer be one of your enemies\.$
^In a moment of forgiveness, you declare that you have no enemies\.$
to remove from the table
now what I'd like done with the table is to turn it into a varibable so that I can modify the trigger that Nick helped me with (see did for me basically) to look like this
<trigger
custom_colour="17"
enabled="y"
expand_variables="y"
group="Highlights"
ignore_case="y"
match="^With a sudden convulsion, (\w+) collapses helplessly to the ground\.$"
regexp="y"
send_to="12"
sequence="100"
other_text_colour="lime"
>
<send>if "@enemies" == "%1" or if "@target" == "%1" then
ColourNote("white", "green", "%1 is prone!!!")
end
</send>
</trigger> | top |
|
| Posted by |
Deladan
(40 posts) bio
|
| Date |
Reply #1 on Tue 24 May 2011 10:10 PM (UTC) [ quote
] |
| Message |
So after talking with some people the trigger can be done like this
<trigger
custom_colour="17"
enabled="y"
expand_variables="y"
group="Highlights"
ignore_case="y"
match="^With a sudden convulsion, (\w+) collapses helplessly to the ground\.$"
regexp="y"
send_to="12"
sequence="100"
other_text_colour="lime"
>
<send>if "@enemies" == "%1" or "@target" == "%1" then
ColourNote("white", "green", "%1 is prone!!!")
end
</send>
</trigger>
now I just wish I knew how to do a simple enough table to do what I want | top |
|
| Posted by |
Deladan
(40 posts) bio
|
| Date |
Reply #2 on Tue 24 May 2011 11:01 PM (UTC) [ quote
] |
| Message |
^(\w+) is now one of your enemies\.$
would you do
enemies = {} -- To create the table
but I don't know how to add to the table from a trigger | top |
|
| Posted by |
Deladan
(40 posts) bio
|
| Date |
Reply #3 on Wed 25 May 2011 12:19 AM (UTC) [ quote
] |
| Message |
^(\w+) is now one of your enemies\.$
would you do
enemies = {} -- To create the table
enemies ["%1"] = 0 -- puts the person in the table?
and from there I'm lost completely | top |
|
| Posted by |
Deladan
(40 posts) bio
|
| Date |
Reply #4 on Wed 25 May 2011 05:32 AM (UTC) [ quote
] |
| Message |
^(\w+) is now one of your enemies\.$
would you do
enemies = {} -- To create the table
enemies ["%1"] = 0 -- puts the person in the table?
-- sort enemies into alphabetic order
sorted_enemies = {}
for name in pairs (enemies) do table.insert (sorted_enemies, name) end
table.sort (sorted_enemies)
am I right so far? | top |
|
| Posted by |
Deladan
(40 posts) bio
|
| Date |
Reply #5 on Wed 25 May 2011 05:40 AM (UTC) [ quote
] |
| Message |
^(\w+) is now one of your enemies\.$
would you do
enemies = {} -- To create the table
enemies ["%1"] = 0 -- puts the person in the table?
-- sort enemies into alphabetic order
sorted_enemies = {}
for name in pairs (enemies) do table.insert (sorted_enemies, name) end
table.sort (sorted_enemies)
-- show enemies
if next (enemies) then
ColourNote ("red", "", "enemies now consists of " ..
table.concat (sorted_enemies, ", "))
end
I hope that's right | top |
|
| Posted by |
Nick Gammon
Australia (18,772 posts) bio
Forum Administrator |
| Date |
Reply #6 on Wed 25 May 2011 06:16 AM (UTC) [ quote
] |
| Message |
Quote:
enemies = {} -- To create the table
enemies ["%1"] = 0 -- puts the person in the table?
You don't want to keep recreating the table, or it will only ever have one person in it. So do this instead:
enemies = enemies or {} -- To create the table
Or to have much the same effect:
-- if table does not exist, create it
if not enemies then
enemies = {} -- To create the table
end -- if
Then:
enemies ["%1"] = true -- puts the person in the table
To remove that person:
enemies ["%1"] = nil -- removes the person in the table
You can print them in sorted order like this:
require "pairsbykeys"
for who in pairsByKeys (enemies) do
print (who)
end -- for
|
- 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.
830 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )