.OUT v >LUA Files

Fire up your 3D modelling tool and start building some rolling stock, or find out what others are previewing here. If you have questions about how to make the blueprints work or what names mean what in models, here's the place to find out your answers.

Moderator: Moderators

Locked
User avatar
rfletcher72
Very Active Forum Member
Posts: 8643
Joined: Sat Apr 28, 2007 10:59 pm
Location: The Steel City
Contact:

.OUT v >LUA Files

Post by rfletcher72 »

Hello all,

Can I run two separate scripts within one .bin file? I wish to include a .lua file within an item of DLC that has already a .out file. I can open the .out file but I cannot see how to edit it.

The Class 325 update by Kariban suggests that TS looks for .OUT files before .LUA. Does this this mean it will read both formats in succession?

Vague question I know, but I hope someone will pick up on this?

As always, thanks in advance,
Richard
User avatar
DaveDewhurst
Very Active Forum Member
Posts: 1994
Joined: Wed Nov 28, 2007 10:21 am
Location: Birkenhead
Contact:

Re: .OUT v >LUA Files

Post by DaveDewhurst »

You cant edit the .out file without messing about.
If you have 2 files, say
Script.lua & Script.out
the blueprint will look at the .out file and ignore the .lua
if its a reskin you could change the name of the script that is being looked for in the reskin bin file to Script2.lua
that way the original would look for the original Script(.out) and your reskin would look for your new Script2(.lua)

That make sense?

Dave
User avatar
rfletcher72
Very Active Forum Member
Posts: 8643
Joined: Sat Apr 28, 2007 10:59 pm
Location: The Steel City
Contact:

Re: .OUT v >LUA Files

Post by rfletcher72 »

DaveDewhurst wrote:You cant edit the .out file without messing about.
If you have 2 files, say
Script.lua & Script.out
the blueprint will look at the .out file and ignore the .lua
if its a reskin you could change the name of the script that is being looked for in the reskin bin file to Script2.lua
that way the original would look for the original Script(.out) and your reskin would look for your new Script2(.lua)

That make sense?

Dave
Thanks Dave for your advice,

If I alter the .bin file of the reskin to look for my amended script, what about the info contained in the original .out file? Will the reskin not miss it?

As you will know as usual, I cannot see the wood for the trees :-? ,

Cheers,

Rich
Richard
User avatar
DaveDewhurst
Very Active Forum Member
Posts: 1994
Joined: Wed Nov 28, 2007 10:21 am
Location: Birkenhead
Contact:

Re: .OUT v >LUA Files

Post by DaveDewhurst »

Yes it will,
sorry I assumed you'd replicated the original script in a new .lua file and then made amendments

which engine/wagon is it? there may be an alternative way

Dave
User avatar
rfletcher72
Very Active Forum Member
Posts: 8643
Joined: Sat Apr 28, 2007 10:59 pm
Location: The Steel City
Contact:

Re: .OUT v >LUA Files

Post by rfletcher72 »

DaveDewhurst wrote:Yes it will,
sorry I assumed you'd replicated the original script in a new .lua file and then made amendments

which engine/wagon is it? there may be an alternative way

Dave
I've sent you a PM Dave,

Cheers,

Rich
Richard
JasVick
Been on the forums for a while
Posts: 241
Joined: Wed Jun 25, 2008 9:22 am

Re: .OUT v >LUA Files

Post by JasVick »

Is there ANY way to modify an .out file then? This is one thing Ive not been able to do yet - would like to as I can edit the .lua files fine, these .out files however completely fox me! I know they are basically compressed compiled versions but haven't worked anything out yet.
User avatar
Irishrailguy
Very Active Forum Member
Posts: 1338
Joined: Sun Mar 21, 2010 8:58 pm
Location: Dublin, Ireland

Re: .OUT v >LUA Files

Post by Irishrailguy »

JasVick wrote:Is there ANY way to modify an .out file then? This is one thing Ive not been able to do yet - would like to as I can edit the .lua files fine, these .out files however completely fox me! I know they are basically compressed compiled versions but haven't worked anything out yet.
An .out file is a machine-code format file, like an .exe or .dll. These files aren't readable in their original format without a reverse compiler, and since I've never heard of .out files outside of TS then I'd imagine nobody's familiar with the encoding process of the compiler to reverse-engineer one (which is illegal anyway I think). .out files are there for a reason, they protect copyrighted code (or even non-copyrighted code) from being copied and pasted by developers like many did before the format was introduced. As such it's near impossible to read the code 'backwards' unless you use an assembly de-compiler, which are generally unpleasant to use and are frowned upon by most software development communities...

Kev
nschichan
Been on the forums for a while
Posts: 135
Joined: Thu Sep 15, 2011 10:52 pm

Re: .OUT v >LUA Files

Post by nschichan »

rfletcher72 wrote:Hello all,

Can I run two separate scripts within one .bin file? I wish to include a .lua file within an item of DLC that has already a .out file. I can open the .out file but I cannot see how to edit it.

The Class 325 update by Kariban suggests that TS looks for .OUT files before .LUA. Does this this mean it will read both formats in succession?

Vague question I know, but I hope someone will pick up on this?

As always, thanks in advance,
Hi,

.out file are just lua bytecode (that is the result of running luac.exe on the lua file). As such, you can use require() on them.

Therefore if you want to run your code along with the original code, something along the line of the following works relatively well (with some filename/path adaptations of course):

- Assuming the script is named MyEngineScript.out, rename it to __MyEngineScript.out

- Create a new lua file named MyEngineScript.lua with the following content:

Code: Select all

-- -*- lua -*-

-- this is the original renamed .out file
require("Assets/SomeProvider/SomeProduct/RailVehicles/Electric/SomeEngine/__MyEngineScript.out")

-- keep previous functions before we provide our own
-- you can similarily override any other function (OnControlChange, OnConsistMessage, etc...)
__Update = Update
__Initialise = Ininitialise

function Initialise
	__Initialise()
	-- you can add your custom code here
end

function Update(interval)
	__Update(interval)
	-- you can add your custom code here
end
I hope this helps,
--
nschichan
deltic009
Very Active Forum Member
Posts: 4017
Joined: Fri Nov 27, 2009 1:06 am

Re: .OUT v >LUA Files

Post by deltic009 »

nschichan wrote:
rfletcher72 wrote:Hello all,

Can I run two separate scripts within one .bin file? I wish to include a .lua file within an item of DLC that has already a .out file. I can open the .out file but I cannot see how to edit it.

The Class 325 update by Kariban suggests that TS looks for .OUT files before .LUA. Does this this mean it will read both formats in succession?

Vague question I know, but I hope someone will pick up on this?

As always, thanks in advance,
Hi,

.out file are just lua bytecode (that is the result of running luac.exe on the lua file). As such, you can use require() on them.

Therefore if you want to run your code along with the original code, something along the line of the following works relatively well (with some filename/path adaptations of course):

- Assuming the script is named MyEngineScript.out, rename it to __MyEngineScript.out

- Create a new lua file named MyEngineScript.lua with the following content:

Code: Select all

-- -*- lua -*-

-- this is the original renamed .out file
require("Assets/SomeProvider/SomeProduct/RailVehicles/Electric/SomeEngine/__MyEngineScript.out")

-- keep previous functions before we provide our own
-- you can similarily override any other function (OnControlChange, OnConsistMessage, etc...)
__Update = Update
__Initialise = Ininitialise

function Initialise
	__Initialise()
	-- you can add your custom code here
end

function Update(interval)
	__Update(interval)
	-- you can add your custom code here
end
I hope this helps,
Thanks for that, basically you call for the .out script within the new .lua script, rather than the instruction contained in the bin file. If that is the case, l then surely the renaming is superfluous to our needs, as so long as you remove the bin file reference to it, the only call for the .out file will be from within your new .lua file? Or am I missing something obvious here?
Matthew Wilson, development team at Vulcan Productions

http://www.vulcanproductions.co.uk
https://www.facebook.com/VulcanFoundry/
nschichan
Been on the forums for a while
Posts: 135
Joined: Thu Sep 15, 2011 10:52 pm

Re: .OUT v >LUA Files

Post by nschichan »

deltic009 wrote: Thanks for that, basically you call for the .out script within the new .lua script, rather than the instruction contained in the bin file. If that is the case, l then surely the renaming is superfluous to our needs, as so long as you remove the bin file reference to it, the only call for the .out file will be from within your new .lua file? Or am I missing something obvious here?
The rename is needed here so that the game uses the lua file instead of the .out file. If you have MyEngineScript.lua and MyEngineScript.out in the same directory, the game will load the out file instead of the lua file (the script entry in the engine blueprint does not specify the filename extension).
--
nschichan
User avatar
rfletcher72
Very Active Forum Member
Posts: 8643
Joined: Sat Apr 28, 2007 10:59 pm
Location: The Steel City
Contact:

Re: .OUT v >LUA Files

Post by rfletcher72 »

nschichan wrote:Hi,

.out file are just lua bytecode (that is the result of running luac.exe on the lua file). As such, you can use require() on them.

Therefore if you want to run your code along with the original code, something along the line of the following works relatively well (with some filename/path adaptations of course):

- Assuming the script is named MyEngineScript.out, rename it to __MyEngineScript.out

- Create a new lua file named MyEngineScript.lua with the following content:

Code: Select all

-- -*- lua -*-

-- this is the original renamed .out file
require("Assets/SomeProvider/SomeProduct/RailVehicles/Electric/SomeEngine/__MyEngineScript.out")

-- keep previous functions before we provide our own
-- you can similarily override any other function (OnControlChange, OnConsistMessage, etc...)
__Update = Update
__Initialise = Ininitialise

function Initialise
	__Initialise()
	-- you can add your custom code here
end

function Update(interval)
	__Update(interval)
	-- you can add your custom code here
end
I hope this helps,
Thanks for that nschcihan.

I have just given it a go, but it does not appear to activate the functions I have added, but that is probably down to me not doing something right.

So what I need to do is this? :

1. create a new .lua file containing the code you have provided.
2. copy the contents of the .out file into the .lua file at the point you have indicated.
3. add my code below this at the point you have indicated.

As an aside, I have also removed the .out file out of the asset folder and replaced it with my basic .lua file, which contains none of the script from the .out file. The extra functions I require do now work, and a quick test run confirms to me that it appears to be operating correctly overall in the sim, with no ill effects. Byb doing so, am I asking for trouble?

Thanks again,

Richard
Richard
nschichan
Been on the forums for a while
Posts: 135
Joined: Thu Sep 15, 2011 10:52 pm

Re: .OUT v >LUA Files

Post by nschichan »

rfletcher72 wrote: Thanks for that nschcihan.

I have just given it a go, but it does not appear to activate the functions I have added, but that is probably down to me not doing something right.

So what I need to do is this? :

1. create a new .lua file containing the code you have provided.
2. copy the contents of the .out file into the .lua file at the point you have indicated.
3. add my code below this at the point you have indicated.
I'm ok with step 1 and 3. for step 2 you have to keep the require("...") line with the path to the renamed .out file. "require()" is a built-in lua function that loads the content of a lua file (precompiled (.out) or clear text (.lua)) so that you can use the functions it declares.
rfletcher72 wrote: As an aside, I have also removed the .out file out of the asset folder and replaced it with my basic .lua file, which contains none of the script from the .out file. The extra functions I require do now work, and a quick test run confirms to me that it appears to be operating correctly overall in the sim, with no ill effects. Byb doing so, am I asking for trouble?
Maybe the locomotive does not have advanced functions, if the script only reacts to the Headlight control so that it can turn on and off the projected TSX light, it's probably easier to rewrite the whole script :)

On the other hand, if it is an advanced locomotive, you have to be very careful with this method, because as you are executing the Update() method provided by the locomotive builder and your own code, you have the risk that your code will have a side effect on the builder code and vice-versa.
--
nschichan
User avatar
rfletcher72
Very Active Forum Member
Posts: 8643
Joined: Sat Apr 28, 2007 10:59 pm
Location: The Steel City
Contact:

Re: .OUT v >LUA Files

Post by rfletcher72 »

Quick question if I may?

How do I go from .lua to .out format? Do I drop my .lua file onto luac.exe in the same way we do with .bin files and serz? I have tried this and got an .out file out the other end, I just wanted to check this is the correct method.

Regards,

Richard
Richard
User avatar
ChrisBarnes
Very Active Forum Member
Posts: 1494
Joined: Sat Jul 25, 2009 3:45 pm
Location: North Yorkshire

Re: .OUT v >LUA Files

Post by ChrisBarnes »

If the .out has the same name as the .lua you dropped in, you can be pretty sure it's the same script in exported format. I can't believe I never thought of doing that though, all this time I was making dummy engine blueprints with the script field filled in and exporting those - what a plonker... Thank you! :D

Chris
Just Trains BR 4, 5, 6, 7 and LNER K4 & V2 script and simulation author
User avatar
rfletcher72
Very Active Forum Member
Posts: 8643
Joined: Sat Apr 28, 2007 10:59 pm
Location: The Steel City
Contact:

Re: .OUT v >LUA Files

Post by rfletcher72 »

ChrisBarnes wrote:If the .out has the same name as the .lua you dropped in, you can be pretty sure it's the same script in exported format. I can't believe I never thought of doing that though, all this time I was making dummy engine blueprints with the script field filled in and exporting those - what a plonker... Thank you! :D

Chris
The resulting .out file comes out named 'luac', but seems to contain everything that was in the .lua. I have just renamed it to what I want and ran the sim and all seems well,

Regards,

Richard
Richard
Locked

Return to “[TS] Building Rolling Stock”