Dave Dewhurst light fix mods?

Discussion of rolling-stock creation & re-painting.

Dave Dewhurst light fix mods?

Unread postby _o_OOOO_oo-Kanawha » Mon Oct 20, 2014 4:29 am

I found more engines which have all light emitters on when starting a scenario.
This is due to improper initialisation of emitters by the engine script.
Emitters that aren't controlled by the game core should be initalised to Off by the engine script. But since most older engines are effectively abandoned by DTG ...

Dave Dewhurst has provided two packages for the RWA filestore to correct a few engines.
It uses a lua wrapper around the original script.

With the engine scripts now mostly in .out format, there is no access to the plain text lua anymore.

However, Havner's recent joystick/overlay patch gave me the idea one can patch locos ourselves.

Can somebody provide the basic lua wrapper in cleartext? One can get the names of the emitters from the engine.bin.
Can CobraOne's lua patcher be used to patch further locomotives using that basic lua script? Where can one find this tool?
Edwin "Kanawha"
Image
The Chessie, the train that never was ... (6000 hp Baldwin-Westinghouse steam turbine electric)
User avatar
_o_OOOO_oo-Kanawha
 
Posts: 3231
Joined: Mon Nov 14, 2011 2:12 pm

Re: Dave Dewhurst light fix mods?

Unread postby Kali » Mon Oct 20, 2014 10:22 am

Code: Select all
LUA_PATH=LUA_PATH;.."path/to/engine/?.out"

require(original_script_without_extension)

local oldInitialise = Initialise
local oldUpdate = Update

function Initialise()
 <own stuff>
 oldInitialise()
end

function Update(p_frame)
   <own stuff>
   oldUpdate( p_frame )
  <more own stuff>
end



Rename the original .out to whatever you like as long as you get it right in your script. Name your new .lua the same as the original .out, and that's it.
Kali
 
Posts: 1600
Joined: Mon Mar 14, 2011 1:00 am
Location: England-by-Sea

Re: Dave Dewhurst light fix mods?

Unread postby _o_OOOO_oo-Kanawha » Mon Oct 20, 2014 10:34 am

Kali wrote:
Code: Select all
LUA_PATH=LUA_PATH;.."path/to/engine/?.out"

require(original_script_without_extension)

local oldInitialise = Initialise
local oldUpdate = Update

function Initialise()
 <own stuff>
 oldInitialise()
end

function Update(p_frame)
   <own stuff>
   oldUpdate( p_frame )
  <more own stuff>
end



Rename the original .out to whatever you like as long as you get it right in your script. Name your new .lua the same as the original .out, and that's it.


Thanks, Kali.

Havner wrote that .out files take precedence over .lua files, but don't have to be necessarily in compiled format. So a cleartext lua file in .out extension wraps around the original .out file without harm.

This way, I also can combine Havner's overlay code with a few lines of my own to switch off the emitters DTG forgot.
Edwin "Kanawha"
Image
The Chessie, the train that never was ... (6000 hp Baldwin-Westinghouse steam turbine electric)
User avatar
_o_OOOO_oo-Kanawha
 
Posts: 3231
Joined: Mon Nov 14, 2011 2:12 pm

Re: Dave Dewhurst light fix mods?

Unread postby Kali » Fri Oct 24, 2014 11:37 am

Yeah, you can rename the .out file to whatever you like anyway and the blueprint doesn't care if the extension is .out or .lua, so your wrapper can still be cleartext with a .lua extension. It's only if there's two files with the same name but one is .out & one is .lua that the .out file will take precedence ( which is an annoying gotcha for devs too ... ). Lua will try and load whatever extensions you tell it to ( check the manual sections about require() and remember it's lua 5.0 we're using ) so you really can rename it to whatever you like.

Tweaked version that's a bit more useful for your case:

Code: Select all
LUA_PATH=LUA_PATH;.."path/to/engine/?.out"

require(original_script_without_extension)

local oldInitialise = Initialise
local oldUpdate = Update

function Initialise()
 <own stuff>
 oldInitialise()
end

local FirstRun = true

function Update(p_frame)
    if FirstRun then
       FirstRun = false
       <do own stuff that only happens at scenario load, like say, turning excess emitters off>
   end

   <own stuff>
   oldUpdate( p_frame )
  <more own stuff>
end

Kali
 
Posts: 1600
Joined: Mon Mar 14, 2011 1:00 am
Location: England-by-Sea


Return to Rolling-Stock Design

Who is online

Users browsing this forum: No registered users and 1 guest