Scripting dynamic numbers

Discuss anything related to Train Simulator from DoveTail that does not fit in one of the more specific categories.

Re: Scripting dynamic numbers

Postby rfletcher72 » Mon Jan 11, 2016 10:14 pm

So with a helluva lot of assistance from Matthew, I have resurrected my on-off quest to construct a dynamic number along similar lines to apply to reskins.

I have constructed a decal in 3DC and then exported into game - E&G Class 37 in this instance:

43211.jpg


Don't let the 43211 put you off btw, I deliberately faulted the texture naming to check the decal was looking in the right place for the textures (which it seems to be doing so).

So going on advice from Matt and the excellent postings in this thread, I set about amending the script for the Class 37 to include the decal. I have chosen to add the following into the function update (time) section of the script:

Code: Select all
--  number scripting

rv_number = Call("GetRVNumber")

   Call("number1:SetText", rv_number, 0)
   Call("number2:SetText", rv_number, 0)

end


The child objects are named 'number1' and 'number2', and I have entered 'rv_number' into the Call instruction as in this instance the number range in the sim is the full loco number (no headcode, decal option etc).

But the desired number has still to appear on the decal on the loco in game ?.

Any advice and/or pointers would be most appreciated :oops:
Richard
User avatar
rfletcher72
Full Time Fireman
 
Posts: 61
Joined: Tue Apr 01, 2014 10:58 pm
Location: The Steel City
Has thanked: 73 times
Been thanked: 27 times

Re: Scripting dynamic numbers

Postby deltic009 » Mon Jan 11, 2016 10:54 pm

Right, we weren't finished with what we needed to make sadly. You need to make a primary named texture set, which should be referenced in the config of your object blueprint for the child objects you have made like below

Code: Select all
               <PrimaryNamedTextureSet>
                  <iBlueprintLibrary-cAbsoluteBlueprintID>
                     <BlueprintSetID>
                        <iBlueprintLibrary-cBlueprintSetID>
                           <Provider d:type="cDeltaString">Kuju</Provider>
                           <Product d:type="cDeltaString">Railsimulator</Product>
                        </iBlueprintLibrary-cBlueprintSetID>
                     </BlueprintSetID>
                     <BlueprintID d:type="cDeltaString">RailVehicles\Diesel\Class55\MDP\Deltic_headcodes.xml</BlueprintID>
                  </iBlueprintLibrary-cAbsoluteBlueprintID>
               </PrimaryNamedTextureSet>


And that config file referenced, the one which above is Deltic_headcodes.xml, should list links to all of your texture files for the auto-numbering, in your case from digits from 0 to 9 like so

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<cBlueprintLoader xmlns:d="http://www.kuju.com/TnT/2003/Delta" d:version="1.0">
   <Blueprint>
      <cNamedTextureSetBlueprint>
         <Name d:type="cDeltaString">Deltic_headcodes</Name>
         <TextureEntry>
            <cNamedTextureSetBlueprint-sTextureEntry d:id="143">
               <TextureName d:type="cDeltaString">0</TextureName>
               <TextureID d:type="cDeltaString">MDP\Deltic\Headcode\Textures\[00]decal_primarynumber_0</TextureID>
            </cNamedTextureSetBlueprint-sTextureEntry>


With subsequent entries duplicated below for each digit.

Now on to the scripting. Your script should contain the following to make it work with the auto numbering

Code: Select all
function Update ( time )

--Headcode and dynamic numbering/naming script.

   fullNumber = Call("GetRVNumber")
   engineNumber = string.sub(fullNumber, 1, 5)
         Call("Number1:SetText", engineNumber, 0)
   Call("Number2:SetText", engineNumber, 0)


Give that all a try or let me know on Facebook if you need any clarification. And DON'T thank me for my help, I am riding on the shoulders of giants, regurgitating the knowledge they have gratefully passed down to me, but not all my original thinking.

Best of luck.
Last edited by deltic009 on Mon Jan 11, 2016 11:41 pm, edited 1 time in total.
deltic009
Full Time Fireman
 
Posts: 62
Joined: Mon Apr 14, 2014 12:52 pm
Has thanked: 16 times
Been thanked: 34 times

Re: Scripting dynamic numbers

Postby AndiS » Mon Jan 11, 2016 11:33 pm

In Lua, character locations are counted from 1, not 0. So the first 5 letters (digits) would be:
engineNumber = string.sub(fullNumber, 1, 5)

Not that I know much of the rest of what you are doing here. Just putting a pea under the giant's shoe so he looks a bit taller. :lol:
AndiS
Top Link Driver!
 
Posts: 736
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 268 times
Been thanked: 308 times

Re: Scripting dynamic numbers

Postby deltic009 » Mon Jan 11, 2016 11:39 pm

AndiS wrote:In Lua, character locations are counted from 1, not 0. So the first 5 letters (digits) would be:
engineNumber = string.sub(fullNumber, 1, 5)

Not that I know much of the rest of what you are doing here. Just putting a pea under the giant's shoe so he looks a bit taller. :lol:

Yes, you are absolutely correct and I shall amend the above.
deltic009
Full Time Fireman
 
Posts: 62
Joined: Mon Apr 14, 2014 12:52 pm
Has thanked: 16 times
Been thanked: 34 times

Re: Scripting dynamic numbers

Postby rfletcher72 » Tue Jan 12, 2016 1:14 pm

Thanks for all the replies and assistance guys, it is really appreciated.

I have amended the script as suggested above, and here is where I am currently at:

10.jpg


Now for some reason, the decal is now only showing the first two primary digits. The other three are definitely there, just they refuse to show. This also does not appear to be an issue with the scripting, as making changes to (or even deleting) it has no effect on the decal showing '10' :?: .

I suspect then that the fault here lies in how I have constructed the decal in 3DC.

My head hurts :(
Richard
User avatar
rfletcher72
Full Time Fireman
 
Posts: 61
Joined: Tue Apr 01, 2014 10:58 pm
Location: The Steel City
Has thanked: 73 times
Been thanked: 27 times

Previous

Return to Train Simulator Mess Room

Who is online

Users browsing this forum: No registered users and 1 guest