Page 1 of 7

Some handy scripts

Posted: Mon Apr 21, 2008 4:48 am
by jlv
I just uploaded a couple of python scripts you might find useful. You can get python at http://www.python.org. They are for the command line, so if you aren't familiar with it this might help.

http://mxsimulator.com/scripts/saf.py

This one is a .saf bundler. You invoke it like this:
  • saf.py mynewtrack mynewtrack.saf
That would bundle all the files in the folder "mynewtrack" into "mynewtrack.saf".

Edit: The demo splicer is obsolete. It won't work with the new demo format.
http://mxsimulator.com/scripts/demosplice.py

The second script is a demo splicer. This lets you combine .mxdemo files. You use it like this:
  • demosplice.py demo1.mxdemo demo2.mxdemo combined.mxdemo
You can also specify which bikes you want by putting a comma separated list of bike indexes (zero based) after the filename. So if you only wanted the first bike out of demo1.mxdemo, do this:
  • demosplice.py demo1.mxdemo,0 demo2.mxdemo combined.mxdemo
Btw, for some reason the word "python" is triggering something that prevents the post from going through. So if you get an error posting and used the word "python" that is probably the reason why. Edit: I think this is fixed now

Re: Some handy scripts

Posted: Mon Apr 21, 2008 5:01 am
by DJ99X
Ah, cheers, I was looking all over the place to find out how to make the saf files.

And in regards to the forum not letting you post stuff, I had that trouble once. Didn't like one particular word

Re: Some handy scripts

Posted: Wed Apr 23, 2008 10:34 pm
by DJ99X
Hmmm, this thing just won't run for me, but then no other scripts will run either. Has anyone else tried this yet and succeeded? If so, you must teach me your way....

Re: Some handy scripts

Posted: Wed Apr 23, 2008 10:56 pm
by jlv
Does anything happen when you type "python"?

Re: Some handy scripts

Posted: Wed Apr 23, 2008 11:07 pm
by DJ99X
No, it comes up with that ''python' is not recognized as an internal or external command,
operable program or batch file", in both command prompts. But I know it should be working, because it has >>>.
Is there some place i should be putting the files?

EDIT- Hmmm, might have to edit that autoexec.bat when i get home, that could be the problem

Re: Some handy scripts

Posted: Thu Apr 24, 2008 12:16 am
by jlv
You mean it says unrecognized command but still gives you the python prompt?

Re: Some handy scripts

Posted: Thu Apr 24, 2008 12:27 am
by DJ99X
As I said, I might have to change that bat file, because the python command won't work, except when i enter where it is located, which is C:/Python25/Python. Editing that bat file should make the command work. I'll see how it goes later. I'm such a noob at this script and programming stuff.

Re: Some handy scripts

Posted: Thu Apr 24, 2008 12:56 am
by jlv
This video might help.

Re: Some handy scripts

Posted: Thu Apr 24, 2008 2:18 am
by DJ99X
Success! I've got them working!But boy its effort typing stuff out. For those who want to use these scripts, and know jack all about python, watch that video jlv posted, making the script folder in the python folder, and open up a command prompt, and put in this-
For SAF-
python c:\python25\scripts\saf.py c:\python25\scripts\trackname c:\python25\scripts\trackname.saf

For Splicing-
python c:\python25\scripts\demosplice.py c:\python25\scripts\demo1.mxdemo c:\python25\scripts\demo2.mxdemo c:\python25\scripts\demo.mxdemo

demo,demo1,demo2 is whatever you've named it

Am I doing things the hard way here JLV? Or is there a simpler way?

Re: Some handy scripts

Posted: Thu Apr 24, 2008 3:09 am
by jlv
You can use CD to change the current directory.

So instead of this:
python c:\python25\scripts\saf.py c:\python25\scripts\trackname c:\python25\scripts\trackname.saf

You could use:
cd c:\python25\scripts
python saf.py trackname trackname.saf

If you're lucky your command line supports tab completion, so you can type just enough to make the filename unambiguous then hit tab and it will finish it for you.

Re: Some handy scripts

Posted: Thu Apr 24, 2008 3:51 am
by DJ99X
Yeah, that makes things simpler

Re: Some handy scripts

Posted: Sun Jul 13, 2008 6:46 pm
by Voutare
This isn't working for me.
:/

I've got python running, I've had it running for a good 2 years now, but whenever I type out the script for demosplicing, it says invalid syntax.

Usually that means I just made an error writing it, correct?

(I've always used IDLE)

Oh, and it says File "<stdin>", line 1.

Not sure what that means.

Re: Some handy scripts

Posted: Sun Jul 13, 2008 6:49 pm
by ddmx
Read the first post, watch that video, and follow it. I had the same thing happening.

Re: Some handy scripts

Posted: Sun Jul 13, 2008 6:50 pm
by Voutare
I did. :/

I've got the python command recognized.

(Well, not entirely. But I'm not sure if that's how it is supposed to work.)

It works when I do c:\documents and settings\kyle's>python

It says python 2.5.2 <r252:60911, Feb 21 2008, 13:11:45> [MSC v.1310 21 bit, and so on.

That's proving that the python is working correctly, right?

But when I do just python (Or, >>> python) it says:

Traceback <most recent call last>:
File "<stdin>", line 1, in <module>
NameError: name 'python' is not defined

Re: Some handy scripts

Posted: Sun Jul 13, 2008 6:52 pm
by ddmx
cd C:\Users\Davey\Desktop\thor
python saf.py rider-coreBlackTan.png rider-coreBlackWhite.png rider-coreBurgandy.png rider-coreNavy.png rider-coreRed.png rider-coreRedBlack.png rider-coreSpearmint.png thorcore08.saf

That was the command for my thorcore skinpack.
Make sure that all of your files are correctly named, and all in the same folder along with saf.py.