EDITED OUT:
DO NOT COPY SPECIAL CHARACTERS INTO YOUR SCRIPTS. THEY CAUSE SAVE/LOAD ISSUES.
EDITED OUT, DOESN’T WORK.
EDITED OUT, DOESN’T WORK
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:
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
endI’m using this for a nice looking compass I’ll post later on by calling this function in an event handler.
EDITED OUT.
Altering a script in any way will always be less ideal than one that requires nothing at all.
EDITED OUT.
Nothing wrong with your script. In fact, you’re doing a great job figuring things out! I only point out that there is a more optimal way of parsing the string that doesn’t require a copy/paste.
It turns out there is a very important reason to do it your way…
If you use illegal characters in your scripts, they will cause your scripts to not save. Any scripts under the illegal characters will just vanish from existence.
I just wanted to note that here in case anyone should try to copy and paste them from the msdp output and destroy their scripts.
Very good to know. Thank you!