string exts and string affects output

string exts and string affects output

Postby DarkArtist » Sat Dec 28, 2013 12:49 pm

EDITED OUT:

DO NOT COPY SPECIAL CHARACTERS INTO YOUR SCRIPTS. THEY CAUSE SAVE/LOAD ISSUES.
Last edited by DarkArtist on Mon Jan 20, 2014 12:09 pm, edited 4 times in total.
DarkArtist
Double 40 Poster
 
Posts: 112
Joined: Tue Dec 10, 2013 6:18 pm
Status: Offline

Re: string exts and string affects output

Postby DarkArtist » Sat Dec 28, 2013 1:24 pm

EDITED OUT, DOESN'T WORK.
Last edited by DarkArtist on Mon Jan 20, 2014 12:06 pm, edited 2 times in total.
DarkArtist
Double 40 Poster
 
Posts: 112
Joined: Tue Dec 10, 2013 6:18 pm
Status: Offline

Re: string exts and string affects output

Postby DarkArtist » Sat Dec 28, 2013 1:41 pm

EDITED OUT, DOESN'T WORK
Last edited by DarkArtist on Mon Jan 20, 2014 12:06 pm, edited 1 time in total.
DarkArtist
Double 40 Poster
 
Posts: 112
Joined: Tue Dec 10, 2013 6:18 pm
Status: Offline

Re: string exts and string affects output

Postby Akaya » Sat Dec 28, 2013 3:56 pm

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.
User avatar
Akaya
40 Prime Poster
 
Posts: 78
Joined: Thu Jan 10, 2013 3:10 am
Status: Offline

Re: string exts and string affects output

Postby DarkArtist » Sat Dec 28, 2013 4:20 pm

EDITED OUT.
Last edited by DarkArtist on Mon Jan 20, 2014 12:10 pm, edited 1 time in total.
DarkArtist
Double 40 Poster
 
Posts: 112
Joined: Tue Dec 10, 2013 6:18 pm
Status: Offline

Re: string exts and string affects output

Postby Akaya » Sat Dec 28, 2013 5:36 pm

Altering a script in any way will always be less ideal than one that requires nothing at all.
User avatar
Akaya
40 Prime Poster
 
Posts: 78
Joined: Thu Jan 10, 2013 3:10 am
Status: Offline

Re: string exts and string affects output

Postby DarkArtist » Sat Dec 28, 2013 8:56 pm

EDITED OUT.
Last edited by DarkArtist on Mon Jan 20, 2014 12:10 pm, edited 1 time in total.
DarkArtist
Double 40 Poster
 
Posts: 112
Joined: Tue Dec 10, 2013 6:18 pm
Status: Offline

Re: string exts and string affects output

Postby Akaya » Sun Dec 29, 2013 1:59 am

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.
User avatar
Akaya
40 Prime Poster
 
Posts: 78
Joined: Thu Jan 10, 2013 3:10 am
Status: Offline

Re: string exts and string affects output

Postby DarkArtist » Mon Jan 20, 2014 11:06 am

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.
DarkArtist
Double 40 Poster
 
Posts: 112
Joined: Tue Dec 10, 2013 6:18 pm
Status: Offline

Re: string exts and string affects output

Postby Akaya » Mon Jan 20, 2014 1:32 pm

Very good to know. Thank you!
User avatar
Akaya
40 Prime Poster
 
Posts: 78
Joined: Thu Jan 10, 2013 3:10 am
Status: Offline


Return to Mudlet - unlimited possibilities

Who is online

Users browsing this forum: No registered users and 5 guests

cron