Page 1 of 1

string exts and string affects output

PostPosted: Sat Dec 28, 2013 12:49 pm
by DarkArtist
EDITED OUT:

DO NOT COPY SPECIAL CHARACTERS INTO YOUR SCRIPTS. THEY CAUSE SAVE/LOAD ISSUES.

Re: string exts and string affects output

PostPosted: Sat Dec 28, 2013 1:24 pm
by DarkArtist
EDITED OUT, DOESN'T WORK.

Re: string exts and string affects output

PostPosted: Sat Dec 28, 2013 1:41 pm
by DarkArtist
EDITED OUT, DOESN'T WORK

Re: string exts and string affects output

PostPosted: Sat Dec 28, 2013 3:56 pm
by Akaya
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.

Re: string exts and string affects output

PostPosted: Sat Dec 28, 2013 4:20 pm
by DarkArtist
EDITED OUT.

Re: string exts and string affects output

PostPosted: Sat Dec 28, 2013 5:36 pm
by Akaya
Altering a script in any way will always be less ideal than one that requires nothing at all.

Re: string exts and string affects output

PostPosted: Sat Dec 28, 2013 8:56 pm
by DarkArtist
EDITED OUT.

Re: string exts and string affects output

PostPosted: Sun Dec 29, 2013 1:59 am
by Akaya
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.

Re: string exts and string affects output

PostPosted: Mon Jan 20, 2014 11:06 am
by DarkArtist
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.

Re: string exts and string affects output

PostPosted: Mon Jan 20, 2014 1:32 pm
by Akaya
Very good to know. Thank you!