Some handy scripts

All about making tracks for MX Simulator
Post Reply
jlv
Site Admin
Posts: 14928
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Some handy scripts

Post 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
Last edited by jlv on Thu Apr 02, 2015 2:18 am, edited 1 time in total.
Reason: Demo splicer is obsolete
DJ99X
Posts: 15523
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Post 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
DJ99X
Posts: 15523
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Post 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....
jlv
Site Admin
Posts: 14928
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Some handy scripts

Post by jlv »

Does anything happen when you type "python"?
DJ99X
Posts: 15523
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Post 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
jlv
Site Admin
Posts: 14928
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Some handy scripts

Post by jlv »

You mean it says unrecognized command but still gives you the python prompt?
DJ99X
Posts: 15523
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Post 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.
jlv
Site Admin
Posts: 14928
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Some handy scripts

Post by jlv »

This video might help.
DJ99X
Posts: 15523
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Post 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?
jlv
Site Admin
Posts: 14928
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Some handy scripts

Post 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.
DJ99X
Posts: 15523
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Post by DJ99X »

Yeah, that makes things simpler
Voutare
Posts: 4891
Joined: Sun Jan 13, 2008 5:22 am
Team: Privateer
Location: Southern Vermont
Contact:

Re: Some handy scripts

Post 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.
Image
ddmx
Posts: 5374
Joined: Sun Apr 20, 2008 3:36 pm
Location: Midland MI

Re: Some handy scripts

Post by ddmx »

Read the first post, watch that video, and follow it. I had the same thing happening.
Voutare
Posts: 4891
Joined: Sun Jan 13, 2008 5:22 am
Team: Privateer
Location: Southern Vermont
Contact:

Re: Some handy scripts

Post 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
Last edited by Voutare on Sun Jul 13, 2008 7:04 pm, edited 1 time in total.
Image
ddmx
Posts: 5374
Joined: Sun Apr 20, 2008 3:36 pm
Location: Midland MI

Re: Some handy scripts

Post 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.
Post Reply