Some handy scripts

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

Some handy scripts

Postby jlv » Mon Apr 21, 2008 4:48 am

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

User avatar
DJ99X
Posts: 15468
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Postby DJ99X » Mon Apr 21, 2008 5:01 am

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

User avatar
DJ99X
Posts: 15468
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Postby DJ99X » Wed Apr 23, 2008 10:34 pm

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: 12912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Some handy scripts

Postby jlv » Wed Apr 23, 2008 10:56 pm

Does anything happen when you type "python"?

User avatar
DJ99X
Posts: 15468
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Postby DJ99X » Wed Apr 23, 2008 11:07 pm

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: 12912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Some handy scripts

Postby jlv » Thu Apr 24, 2008 12:16 am

You mean it says unrecognized command but still gives you the python prompt?

User avatar
DJ99X
Posts: 15468
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Postby DJ99X » Thu Apr 24, 2008 12:27 am

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: 12912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Some handy scripts

Postby jlv » Thu Apr 24, 2008 12:56 am

This video might help.

User avatar
DJ99X
Posts: 15468
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Postby DJ99X » Thu Apr 24, 2008 2:18 am

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: 12912
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Some handy scripts

Postby jlv » Thu Apr 24, 2008 3:09 am

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.

User avatar
DJ99X
Posts: 15468
Joined: Tue Jan 15, 2008 11:36 am
Location: Land Down Under

Re: Some handy scripts

Postby DJ99X » Thu Apr 24, 2008 3:51 am

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

Postby Voutare » Sun Jul 13, 2008 6:46 pm

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: 5267
Joined: Sun Apr 20, 2008 3:36 pm
Team: Epikmx.com
Location: Midland MI
Contact:

Re: Some handy scripts

Postby ddmx » Sun Jul 13, 2008 6:49 pm

Read the first post, watch that video, and follow it. I had the same thing happening.
The MXS 1%

Voutare
Posts: 4891
Joined: Sun Jan 13, 2008 5:22 am
Team: Privateer
Location: Southern Vermont
Contact:

Re: Some handy scripts

Postby Voutare » Sun Jul 13, 2008 6:50 pm

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: 5267
Joined: Sun Apr 20, 2008 3:36 pm
Team: Epikmx.com
Location: Midland MI
Contact:

Re: Some handy scripts

Postby ddmx » Sun Jul 13, 2008 6:52 pm

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.
The MXS 1%


Return to “Track Editing”

Who is online

Users browsing this forum: No registered users and 2 guests