This won't work for everyone unfortunately. Because the 'special characters' aren't $ ] and [ on all operating systems.
Try this function out. It will work on ALL operating systems. It cuts the end off the string (the 'special character'), reverses the string and cuts off the end again (the other 'special character'). That cleans up the string to be parsed, and returns a table named MSDP. So you can refer to exits and their status' by checking MSDP.North or w/e:
- Code: Select all
function parseExits(event,msdp)
MSDP = {}
msdp = string.cut(msdp,msdp:len()-2)
msdp = string.reverse(msdp)
msdp = string.cut(msdp,msdp:len()-2)
msdp = string.reverse(msdp)
msdp = string.split(msdp,", ")
for k,v in pairs(msdp) do
msdp[k] = string.split(msdp[k],": ")
end
for k,v in pairs(msdp) do
MSDP[v[1]] = v[2]
end
return MSDP
end
I'm using this for a nice looking compass I'll post later on by calling this function in an event handler.