Run LOCOTOOL simultaneously on blocks of DAT OR XML FILES

The "spiritual sequel" to Transport Tycoon Deluxe: Chris Sawyer's Locomotion is the latest game from him - general discussion about it here please!

Moderator: Locomotion Moderators

Post Reply
User avatar
gibboloco
Transport Coordinator
Transport Coordinator
Posts: 314
Joined: 30 Nov 2006 01:10

Run LOCOTOOL simultaneously on blocks of DAT OR XML FILES

Post by gibboloco »


Hi All

I wanted to run Josef Drexler Locotool on several DAT file at one go using the *.DAT format - unfortunately it would only deal with the first DAT file it encountered so to overcome this I carried out the the following:-

1 I wrote the DOS BATCH files (see below) .
2 Placed them both in a test directory
2 I then copied over 1800 DAT files held in the Objdata Directory to a test directory. (To test the idea)
3 I then copied a copy of Locotool.exe to the same directory
4 Finally copied the essential (JD's) Locotool.dll file( JD's Link library file) to the same directory.
5 I ran the Batch file and Locotool dealt with every one of the dat files
that it encountered (It dealt will all 1800 files in under 17 minutes)
6 The directory was full of the XML files and PNG files as expected.
7 The Batch file is easily changed to accomodate parameters that the locotool program permits i.e. -s -d etc
8 I use ACDSee to quickl view the PNG graphics
(using the slide show facility - a very quick way of looking over the
PNG/XML files efectively and quickly.)
9 I Hope the 2 examples of syntax helps those of you who would like
do likewise....

Write one Batch file containing the following script (EXCLUDE THE QUOTES)
"for %%a in (*.dat) do locotool -s *.dat next %%a"
This will run Locotool on all DAT files encountered in the immediate directory and produce XML files and a single PNG containing PICS

Write the other Batch file containing the following script (EXCLUDE THE QUOTES)
"for %%a in (*.xml) do locotool -d *.xml next %%a"
This will run Locotool on all XML files encountered in the immediate directory and produce DAT files and a backup

Regards to all

:lol: :lol: :lol:
Last edited by gibboloco on 08 Dec 2006 16:08, edited 3 times in total.
gibboloco

This OLD GIT just won't stay in the box.....he's got more go than most. He's having great fun.....and so should you....!!!!
fd1sk
Engineer
Engineer
Posts: 6
Joined: 08 Dec 2006 12:45

Post by fd1sk »

Taking this a little further you can use this little Perl command (Perl needed, google is your friend) to change reliability in all XML's to 0 (100%) as I was getting fed up with the breaking down and having to chase all trains for manual replacement.

for %i in (*.xml) do @perl -pi.bak -e s/reliability\"\x20size=\"1\">.+</reliability\"\x20size=\"1\"^>0^</ %i

If you put it in a batch script use %%i instead of %i (both instances), I generally type one line commands in the shell, but making a batch file could be good for reusing on other files.

Cheers!
User avatar
gibboloco
Transport Coordinator
Transport Coordinator
Posts: 314
Joined: 30 Nov 2006 01:10

Post by gibboloco »

Hi There fd1sk

Thanks for info - does this little gem go through all xml's , changing the reliabilty value? If it does, then I would like to point to the attached program specifically written for locomotion, called 'wrapper for locotool'.

Herewith a copy of the program for doing what you advise (but for both xml and dat files). The file name you see is mine - to enable me to see and understand it's content, the contents belong to its originator who I beleive is Josef Drexler - but I'm not 100% certain.

It's a nice little piece of software and has never failed me.

Kindest Regards

PS On behalf of all of us - welcome to tt-forums - Your first birthday 8th Dec 2006 :oops: :oops:
Attachments
lt_wrapper__to_modify_dat_files1.15.zip
(1.95 MiB) Downloaded 217 times
Last edited by gibboloco on 08 Dec 2006 17:09, edited 1 time in total.
gibboloco

This OLD GIT just won't stay in the box.....he's got more go than most. He's having great fun.....and so should you....!!!!
fd1sk
Engineer
Engineer
Posts: 6
Joined: 08 Dec 2006 12:45

Post by fd1sk »

Thanks gibboloco, that is what the script does indeed, It can be easily adapted to do other stuff as well, that is, if there are things to be changed within the files that can be found and changed through some logic.

I will have a look at the program you posted, it sounds it could do some interesting stuff. I am used to program my own stuff and sometimes one does not see what is out there :-)
User avatar
gibboloco
Transport Coordinator
Transport Coordinator
Posts: 314
Joined: 30 Nov 2006 01:10

Post by gibboloco »

fd1sk wrote:Thanks gibboloco, that is what the script does indeed, It can be easily adapted to do other stuff as well, that is, if there are things to be changed within the files that can be found and changed through some logic.

I will have a look at the program you posted, it sounds it could do some interesting stuff. I am used to program my own stuff and sometimes one does not see what is out there :-)
Hi fd1sk (Birthday boy :oops: :oops: )

Could you be so kind as to do this in this posting?:- Write the singleline batch instruction to open the xml file read in to a specified string/chr manipulate str/character and then re-write it back to to the xml?

That would be fantastic

kindest Regards
gibboloco

This OLD GIT just won't stay in the box.....he's got more go than most. He's having great fun.....and so should you....!!!!
fd1sk
Engineer
Engineer
Posts: 6
Joined: 08 Dec 2006 12:45

Post by fd1sk »

That would be possible, that is exactly what my previous posting does. It searches for the line that says reliability (among other things) and changes that whole part to set it to inlude the 0 (100%) value for the reliability. The replacement is in place and using it with the for loop makes it go through all xml files in the current directory.

I use perl to search and replace using regular expressions.

Do you have anything specific in mind you could use this technique for? I might be able to help out rewriting the line to something else.
User avatar
gibboloco
Transport Coordinator
Transport Coordinator
Posts: 314
Joined: 30 Nov 2006 01:10

Post by gibboloco »

fd1sk wrote:Do you have anything specific in mind you could use this technique for? I might be able to help out rewriting the line to something else.
Hi there fd1sk

With your knowledge of this particular software, are you able to write a short piece of script to pipe(redirect) output to another Directory? If you can, It would be a nice idea to read in the data from the DAT(s) AND pipe (redirect) the reads and ammenments/changes to the same DAT(s) file name to another directory.

If you could show me how this needs to be written up, then I can place my changed DAT(s) into another folder - all in one operation, assuming say, I was using the locomotion objdata folder as my source of DAT(s)

fd1sk, I did issue a quick reply since your last post but removed it, after re-reading it. If you saw it - forget it.

Kindest Regards
gibboloco

This OLD GIT just won't stay in the box.....he's got more go than most. He's having great fun.....and so should you....!!!!
fd1sk
Engineer
Engineer
Posts: 6
Joined: 08 Dec 2006 12:45

Post by fd1sk »

The files processed are the XML files that locotool creates, you'd need a way to tell locotool to output to another directory and work from there. Alternatively you could start out by copying the dats to the new directory before processing them with locotool. That is what I do in general. My script to change the xml files will create a backup of any file changed. In order to use them ingame they should still be processed with locotool. Of course this can be automated, but it would also depend on what goal is being pursued in order to know what the best way would be.

In my example I changed all xml files which contained a reliability value (this would get all vehicles) to have a fixed value for said value. In that case I just processed all xml's.

Often only a subset is needed or some finer selection algorithm should be used to achieve your goal. Like, maybe one would want to change the release dates of all the vehicles released in 1960 to 1967 (can't imagine why), then you would write a script to only include 1960 released vehicles in the selection to be processed.

There is something in another topic going where you suggest to include dat filenames in the description field of a vehicle. This is something that is probably easy to achieve by using smart find and replace commands on the xml files.
User avatar
gibboloco
Transport Coordinator
Transport Coordinator
Posts: 314
Joined: 30 Nov 2006 01:10

Post by gibboloco »

Hi There fd1dsk

Thank you for the last posting.

I think I will write my own executable that will act upon single and multiple XML files. It will be a seperate program, describing in a most simlple way, the contained data (variable types, sizes and parameters ) and give the user a simple input/output routine with tight error checking for variable values (ie the variable or string will be tested against what is needed as locotool does). Such editing of an XML file using notepad++ or any other similer editor does not do the checking. It gets checked of course by locotool which is good and tight checking. But I want that all done in my executable.

With my executable the user would be able to check the changes he/she propose and at the same time have the changes checked by dummy running on single or multiple XML files (memory allocated). When the executable is happy with resuts, the user is prompted to write the XML(s).

Having done that the user will then resurrect locotool and run the XML(s) multiple or otherwise as we discussed, to re-produce the DAT(s) and PNGs and WAVs.

Hope I've made sense. When the executable is finished the Ideas I have can then be introduced. To save me a lot of time reading through the XMLs to determing object types etc - do you know where I can obtain such data information from? J drexler has done so much for everyone and I really do not wish to impose on him, if necessary I will have to do it myself. It's a deductive process and Ive done it before. But I do not wish to though - so if you can help great - if you cannot I won't mindl.

Kindest Regards
gibboloco

This OLD GIT just won't stay in the box.....he's got more go than most. He's having great fun.....and so should you....!!!!
User avatar
gibboloco
Transport Coordinator
Transport Coordinator
Posts: 314
Joined: 30 Nov 2006 01:10

Post by gibboloco »

This is a lovely peacfull site fd1sk.

We've not heard a dickie bird from the other fledgelings in the flock! perhaps this ditty is the bird scarer that makes them fly in to have a peck or two?. Got my Purdy 12b and spannish U/o's ready.

By the way, I like the choice of your name. be carefull how you spell it when in command.exe or cmd.com mode though.

Kindest Regards
gibboloco

This OLD GIT just won't stay in the box.....he's got more go than most. He's having great fun.....and so should you....!!!!
fd1sk
Engineer
Engineer
Posts: 6
Joined: 08 Dec 2006 12:45

Post by fd1sk »

:-) don't worry fdisk has long gone from windows. Altho I am mostly on OSX and linux systems nowadays, but I think I should be fine with it. I know what I am doing, most of the time anyway..
User avatar
gibboloco
Transport Coordinator
Transport Coordinator
Posts: 314
Joined: 30 Nov 2006 01:10

Post by gibboloco »

gibboloco wrote::-) Hope I've made sense. When the executable is finished the Ideas I have can then be introduced. To save me a lot of time reading through the XMLs to determing object types etc - do you know where I can obtain such data information from? J drexler has done so much for everyone and I really do not wish to impose on him, if necessary I will have to do it myself. It's a deductive process and Ive done it before. But I do not wish to though - so if you can help great - if you cannot I won't mindl
Hi fd1sk - Good evening
Are you able to help on the above?

Kindest Regards
PS Just thought you might still be running windows v3.1/DOS 6.2 ....
gibboloco

This OLD GIT just won't stay in the box.....he's got more go than most. He's having great fun.....and so should you....!!!!
fd1sk
Engineer
Engineer
Posts: 6
Joined: 08 Dec 2006 12:45

Post by fd1sk »

You might want to check out the following topic: http://www.tt-forums.net/viewtopic.php?t=11329

There is a reference to the Locomotion wiki which hold a lot of information on objects and their variables.
User avatar
gibboloco
Transport Coordinator
Transport Coordinator
Posts: 314
Joined: 30 Nov 2006 01:10

Post by gibboloco »

fd1sk wrote:You might want to check out the following topic: http://www.tt-forums.net/viewtopic.php?t=11329

There is a reference to the Locomotion wiki which hold a lot of information on objects and their variables.
Hi fd1sk
Thanks so much, for info - seen steves name - Will plough through it later tonight - not sure if that is the right thing to say, but will asume it could well be volumes of info.

Thanks very much
gibboloco

This OLD GIT just won't stay in the box.....he's got more go than most. He's having great fun.....and so should you....!!!!
Post Reply

Return to “General Locomotion”

Who is online

Users browsing this forum: No registered users and 3 guests