I want to send a group of directions that are the opposite of the exit directions shown.
The exit directions look like this:
You see a single exit leading north.
...and for that one, I would want to send the remaining directions:
northeast
east
southeast
south
southwest
west
northwest
up
down
in
out
Another example:
You see exits leading north, northeast, east (closed door), southeast, south, and southwest.
I would want to send:
west
northwest
up
down
in
out
The exit line changes depending on the number of exits and if there are any doors.
You see a single exit leading northwest.
You see a single exit leading northwest (open door).
You see a single exit leading northwest (closed door).
You see exits leading north and northeast.
You see exits leading north (open door), northeast (open door), and east.
You see exits leading north, northeast, east, and southeast.
You see exits leading north, northeast, east (closed door), southeast, south, and southwest.
Looks like the exits are always in the same order (what is that order?).
Should be simple enough to make an array with each direction, then loop through it and send what doesn't match (subtract the trigger match from the array of all of them, basically).
And, can each direction have a door (that's either open or closed)?
At first I tried to create one trigger for each possible combination of directions, but after three days I was only up to north, southeast, south and southwest.
Then I tried to do some kind of scripting, but the best I could do was:
<trigger
enabled="y"
ignore_case="y"
match="*You see exits leading *, *, and *.*"
send_to="12"
sequence="401"
>
<send>if %2 or %3 or %4 = north then
SendImmediate "south"
end if
if %2 or %3 or %4 = northeast then
SendImmediate "southwest"
end if
if %2 or %3 or %4 = east then
SendImmediate "west"
end if
if %2 or %3 or %4 = southeast then
SendImmediate "northwest"
end if
if %2 or %3 or %4 = south then
SendImmediate "north"
end if
if %2 or %3 or %4 = southwest then
SendImmediate "northeast"
end if
if %2 or %3 or %4 = west then
SendImmediate "east"
end if
if %2 or %3 or %4 = northwest then
SendImmediate "southeast"
end if
if %2 or %3 or %4 = up then
SendImmediate "down"
end if
if %2 or %3 or %4 = down then
SendImmediate "up"
end if
if %2 or %3 or %4 = out then
SendImmediate "in"
end if
</send>
</trigger>
One problem is that if the exits were north, east, and south. This thing sends south, west and north, not just west.
Another problem is the in direction. I had to remove it because it kept making error messages.
For scripting, I'd probably go with a boolean value for each direction set to true, a check for exits in each direction to turn the value for that directions variable false and a return on the true values after the exits are checked. This avoids your issue of "north south west" returning "north south east", which is *logically* true based on the checks you are having performed.
Your version won't work (well, for a number of reasons) but you also need to include quotes around your strings (and your wildcards).
Anyway, here's a quick and dirty little hack (it really is rather ugly) that works:
<triggers>
<trigger
enabled="y"
ignore_case="y"
match="^You see (?:a single )?exits? leading (.*)\.$"
regexp="y"
send_to="12"
sequence="100"
>
<send>dim i,j
dim yesDirs, noDirs
dim noArr, yesArr
noArr = array("north","northeast","east","southeast","south","southwest","west","northwest","up","down","in","out")
yesDirs = "%1"
yesDirs = Replace(yesDirs," (open door)","")
yesDirs = Replace(yesDirs," (closed door)","")
yesDirs = Replace(yesDirs," and",",")
yesDirs = Replace(yesDirs," ","")
yesDirs = Replace(yesDirs,",,",",")
yesArr = split(yesDirs,",")
for i = 0 to UBound(yesArr)
for j = 0 to UBound(noArr)
if yesArr(i) = noArr(j) then
noArr(j) = ""
exit for
end if
next
next
noDirs = ""
for i = 0 to UBound(noArr)
if noArr(i) <> "" then
if noDirs <> "" then
noDirs = noDirs & ","
end if
noDirs = noDirs & noArr(i)
end if
next
note noDirs</send>
</trigger>
</triggers>
You'll almost certainly want to keep it as an array (although I suppose you could just split it again afterwards) but you'll need to keep that last bit of logic in whatever you use it with (provided you don't convert it from an array) because you need to screen out the empty strings.
You can even just replace the whole appending thing and just send from there (provided you do just want to send a bunch of directions), like this:
for i = 0 to UBound(noArr)
if noArr(i) <> "" then
send noArr(i)
end if
next