For awhile now i've been trying to built a plugin that changes a block of written text over to an ascii in a miniwindow or an ascii map in the output, so i can have both the written text to see who is in what direction, and to be able to see a map of where everything is for ease on the eyes. I'm fairly sure i can do most of it, but it's taking the string and storing it as useful data i'm finding hard, and think string.gmatch is the way to do it, but can't seem to make it work.
Example text it would trigger off:
A door west of here, an exit west of here, Kilstrin Mortificer is one east, a door south of one east, an exit south of one east, an exit southwest of one east, an exit west of one east and the limit of your vision is one east from here.
i'd like it to make tables of where the doors, exits and people are, but can't seem to make it work. not really much script to show as i've mostly been fiddling and not getting anywhere, but what i have is:
function test (name, line, wildcards)
exits = {}
exits.here = {string.match(line, "exit (.*) of here")}
for k, v in pairs (exits.here) do
print("key: ", k, " value: ", v)
end -- for
end -- test
output:
key: 1 value: west
which works for when "an exit (.*) of here" occurs once in a line, but doesn't fire at all if it has a second match in the line or store them to the table, then i found the stuff about string.gmatch working to do pretty much that (http://www.gammon.com.au/forum/?id=6034), but can't seem to make it work. any suggestions or hints as to what i'm doing wrong? I'm fairly new to all this stuff.
Thanks, K
Example text it would trigger off:
A door west of here, an exit west of here, Kilstrin Mortificer is one east, a door south of one east, an exit south of one east, an exit southwest of one east, an exit west of one east and the limit of your vision is one east from here.
i'd like it to make tables of where the doors, exits and people are, but can't seem to make it work. not really much script to show as i've mostly been fiddling and not getting anywhere, but what i have is:
function test (name, line, wildcards)
exits = {}
exits.here = {string.match(line, "exit (.*) of here")}
for k, v in pairs (exits.here) do
print("key: ", k, " value: ", v)
end -- for
end -- test
output:
key: 1 value: west
which works for when "an exit (.*) of here" occurs once in a line, but doesn't fire at all if it has a second match in the line or store them to the table, then i found the stuff about string.gmatch working to do pretty much that (http://www.gammon.com.au/forum/?id=6034), but can't seem to make it work. any suggestions or hints as to what i'm doing wrong? I'm fairly new to all this stuff.
Thanks, K