Help with Python please?

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Amen Brick
Deadly
Deadly
Posts: 187
Joined: Sat May 10, 2008 5:22 pm
Location: Bolton!

Help with Python please?

Post by Amen Brick »

I can do the models, I can understand the game scripting just (thanks to copy and paste lol), but Python always defeats me (as does *mumble sputter yafray, but that's another story).

Could some give me a really, really basic (ie, aimed at chimps) step by step guide to converting obj to dat via python or (god, let there be) some other way.

I have python, i have the model utility files. I'm using a PC.

I tried to follow the guide in 'how to make models', but when I entered the line beginning with $ in python it gave me a syntax error and I know too little to know where I have gone wrong. I don't know if its because I put the script in the wrong folder or what ( i put it in scripts, but that may be just too damned easy).

Thanx in advanx!
User avatar
CaptKev
---- E L I T E ----
---- E L I T E ----
Posts: 519
Joined: Fri Jan 26, 2007 3:21 pm
Location: Shropshire, UK

Post by CaptKev »

with Obj2DatTex.py and <model name>.obj and <model name>.mtl in the C: directory

Start/Run/cmd to go to a command prompt

then type

cd\ [ENTER]

Obj2DatTex.py <model name>.obj [ENTER]

exit [ENTER]

You should end up with <model name>.dat in the C: directory
Download Fighter HUD, Stingray and System Redux from the EliteWiki
User avatar
Amen Brick
Deadly
Deadly
Posts: 187
Joined: Sat May 10, 2008 5:22 pm
Location: Bolton!

Post by Amen Brick »

God I hope that works, I'm biting the table top!

Thanks! :D

C: being optional? I could change the above to Desktop?
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2479
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

yes, after captKev writes:
cd\ [ENTER]
you'd have to add an extra command line, something like:
cd C:\Documents and Settings\[your_username]\Desktop

then continue as captKev says.

what i usually do is just a slight variation of CaptKev's advice, i usually make a new folder on the C: drive, called 'newship' or something, put my new models .obj and .mtl fles and the obj2dattex.py script file in it, then
open a command prompt and type
cd \
cd c:\newship
obj2dattex.py my_cool_model.obj [where 'my_cool_model' is replaced by your models name]

when i navigate back to c:\newship using windows there should be a new file in it called my_cool_model.dat

if you're getting errors or no dat file appears, make sure the original model is all triangles (no quads or n-gons) and that it's within Oolite's limits on vertices & polygons, which are:
Oolite v1.69 (and higher) - 500 vertices, 800 polygons (all must be triangles), 8 materials.

Oolite 1.65 - 320 vertices, 512 polygons (all must be triangles), 7 materials
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

when i first used the python script i got an Error

can´t recall the exact words but it was something like

"error in line 73 empty float"

if you encounter this, look here for solution

https://bb.oolite.space/viewtopic.ph ... ght=python

Cheers Frame.
Bounty Scanner
Number 935
User avatar
Selezen
---- E L I T E ----
---- E L I T E ----
Posts: 2530
Joined: Tue Mar 29, 2005 9:14 am
Location: Tionisla
Contact:

Post by Selezen »

Before you do that make sure that Python is listed in your PATH statement in Windows. It's usually not.

To make this as simple as possible, I usually put everything in the Python installation folder.

So, to summarise my method:

Install Python. Note the installation folder, i.e. C:\PYTHON25.
Copy the Obj2DatTex.py file into that installation folder.
When you've created your ship model, export it to OBJ format and make sure the OBJ and MTL files are saved (or copied) to the Python installation folder.
Open a command box and change directory to the installation folder, i.e. CD\PYTHON25.
Type the command to run the converter as listed above.

It works for me. ;-)
User avatar
Amen Brick
Deadly
Deadly
Posts: 187
Joined: Sat May 10, 2008 5:22 pm
Location: Bolton!

Post by Amen Brick »

Ok, I'll try that. I was getting syntax error at the end of my model name (which wouldn't have worked anyway, too many faces!).

I hates the python. :?

Seriously, I'll sell my soul and the souls of my family to anyone who makes a simple gui or program that does this with a click.
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

Amen Brick wrote:
Ok, I'll try that. I was getting syntax error at the end of my model name (which wouldn't have worked anyway, too many faces!).

I hates the python. :?

Seriously, I'll sell my soul and the souls of my family to anyone who makes a simple gui or program that does this with a click.
Tempting... can you cook ?,weld & (MAG), and paint with an Electro static paint gun, that way you can goto work for me, and i can stay at home making o.. GUI Programs ^^
Bounty Scanner
Number 935
User avatar
Amen Brick
Deadly
Deadly
Posts: 187
Joined: Sat May 10, 2008 5:22 pm
Location: Bolton!

Post by Amen Brick »

Aaargh.

I did this as suggested

Image

and this still happens

Image

Maybe the path is still out, but I can't path either. (always worried I'll screw something important up). I had python in d: (my main drive), but copied it over to c: (trying to keep as close to instructions as possible). When it first misfired, I deleted the D: copy and restarted my comp. Still nada.

Note: Yeah, I see the python script isn't showing the Python snake either, but it didnt work while it did and I don't know why its lost it's icon either (tho probably deleting the d: drive copy did it?)
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Grrr. submit dammit

Post by Frame »

you cant just COPY it from D to C...

you need to run it from the location you have it installed allthough i figure if you ran it from C it would still get the important stuff it needs from D, that is if you still have it on D:

and it seems you do... anyway.

you need to type

Code: Select all

cd python
Not

Code: Select all

cd/python
cd is a command, it means Change Directory, Windows or DOS will read it as "CD/python" and not know of that command...

Invalid syntax means really "unknown command" when in a dos prompt..
a dos promt is the black window you see, it is a leftover from the days we did not have windows but DOS... but has been kept in windows for various reasons but one of them is so you can run command line programs as python is..
Bounty Scanner
Number 935
User avatar
Amen Brick
Deadly
Deadly
Posts: 187
Joined: Sat May 10, 2008 5:22 pm
Location: Bolton!

Post by Amen Brick »

kk, i'll try it without the slash, and then I'll try redownloading it to c and then I'll try going crazy in a clocktower.
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

gree submit dammit

Post by Frame »

Amen Brick wrote:
kk, i'll try it without the slash, and then I'll try redownloading it to c and then I'll try going crazy in a clocktower.
I hope you refer to python,, not oolite.. just double checking :-)

Anyway its not really your fault.. past days, and present days programmers sometimes come up with eloborate word combinations for really simple errors.. while they are warrented for the more serious ones..

Invalid syntax, or syntax error, does not give the unexperienced computer user 1 hint of a clue. when navigating through directories one should not presume the user is familiar with programming "smart talk".

An error like this should be "cd/python is an unknown or unvalid command syntax"
Bounty Scanner
Number 935
User avatar
CaptKev
---- E L I T E ----
---- E L I T E ----
Posts: 519
Joined: Fri Jan 26, 2007 3:21 pm
Location: Shropshire, UK

Post by CaptKev »

@Amen Brick, you need to run the commands in a DOS box.

Pick Start/Run... then type cmd and click the OK button.

http://download.marlinsoftware.co.uk/Oolite/obj2dat.png
Last edited by CaptKev on Fri Jun 06, 2008 9:40 am, edited 1 time in total.
Download Fighter HUD, Stingray and System Redux from the EliteWiki
User avatar
Amen Brick
Deadly
Deadly
Posts: 187
Joined: Sat May 10, 2008 5:22 pm
Location: Bolton!

Post by Amen Brick »

Doh!

Ok, will do!
User avatar
Amen Brick
Deadly
Deadly
Posts: 187
Joined: Sat May 10, 2008 5:22 pm
Location: Bolton!

Post by Amen Brick »

It worked, thank god, it worked.

*puts away rifle and mad glint in eye.
Post Reply