Skip to main content

News

Topic: GetPersonDirection?? (Read 240 times) previous topic - next topic

  • Rhuan
  • [*][*][*][*]
Re: GetPersonDirection??
Reply #15
@Rhuan At a quick glance your code uses slice() when it should use substr().  Maybe that's the problem?
I've rechecked and I had done it wrong. slice should do the job but the parameters were wrong, should be:
to_convert.slice(to_convert.length-5)

The ",4" was not needed and would have stopped it working.

Re: GetPersonDirection??
Reply #16
The -5 is also incorrect. ".rss" is only 4 characters and the -5 would never equal .rss. However with those changes edited into the code, the function did make a copy of all the spritesets but none of the directional values were changed to lower case.
"I am to misbehave." - Malcom Renyolds, Captain of Serenity

  • Rhuan
  • [*][*][*][*]
Re: GetPersonDirection??
Reply #17
This is why I should never post code I haven't tested...

Fixed and tested:
Code: [Select]
var to_convert = GetFileList("spritesets");
var temp;

for(var i = 0, j = 0; i < to_convert.length; ++i)
{
  if(to_convert[i].slice(to_convert[i].length-4)==".rss")
  {
    temp = LoadSpriteset(to_convert[i]);
    for (j = 0; j < temp.directions.length; ++j)
    {
      temp.directions[j].name =  temp.directions[j].name.toLowerCase();
    }
    temp.save("../other/" + to_convert[i]);
  }
}

Re: GetPersonDirection??
Reply #18
If anyone else would like to use it. Here it is.

@Rhuan if you look at the settings, I credited you as the author.

"I am to misbehave." - Malcom Renyolds, Captain of Serenity