I ended up talking jor'mox in discord and the key part I wasn't understanding was how tables worked. I had already found this code in the mapper script i use and thought I could use its method
Code: Select all
---if current MUD line contains roomname, let trigger chain fire another line
if line == wotmudmapper.roomname or string.find(line, "HP:") then
setTriggerStayOpen("Catch Name", 1)
else
---if not exit line, add line to room desc, let trigger chain fire another line
if not string.find(line, "obvious exits:") then
if wotmudmapper.brief then
wotmudmapper.brief = false
end
wotmudmapper.roomdesc = wotmudmapper.roomdesc .. "\n" .. line
setTriggerStayOpen("Catch Name", 1)
end
end
After jor'mox explaining to me how tables worked I used this as my parent trigger
Code: Select all
Players in your Zone
--------------------
--(these are the trigger lines and they are both set to substring)
--(checked mutltline/and trigger box and set value to 2)
--(checked fire length box and set value to 1)
zonewhere {}
--(this creates an empty table and resets the table value to empty every time the parent trigger condition is met)
Now I used (.+) - (.+) as my trigger for my child trigger changed to pearl regx and left all boxes unchecked and used this code based off of the mapper script code (naming the trigger Zone Where of course)
Code: Select all
local name = matches[2]
local room = matches[3]
table.insert (zonewhere,{name,room})
if string.find (line, "Players in your Zone") or string.find (line, "--------------------") then
setTriggerStayOpen("Zone Where", 1) else
if not string.find ("HP:") then
setTriggerStayOpen("Zone Where", 1)
end
end
cecho (" <green>"..table.size(zonewhere))
I used table.size to get my number in after looking at different options from the wiki. My original choice was table.index_of but for some reason I couldn't get this to echo or print. After failing with table.index_of I just used table.size to make sure that the original trigger did in fact clear my table. I realized of course since it did clear the table the table size grows by 1 each additional line and got me the result I wanted.
Part of the mapper script i use has a find room alias that looks like this
Code: Select all
local roomname = matches[2]
local foundrooms = searchRoom(roomname, true, true)
if table.is_empty(foundrooms) then
cecho("<red>No matches found!\n")
elseif table.size(foundrooms) == 1 then
cecho("<green>One matching room found! Map has been centered on this room.\n")
for k, v in pairs(foundrooms) do
centerview(k)
end
else
cecho("<red>Multiple matches found!\n")
end
All I had to do was change "local roomname = matches[2]" to "local roomname = (zonewhere[2][2])" {this example finds the second room}
I made the proper aliases (i.e. fr1, fr2, fr3, .......) and it worked beautifully.