[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4921: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3896)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4923: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3896)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4924: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3896)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4925: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3896)
TrainSimDev.com • View topic - How can I add lua modules in engine scripts?

How can I add lua modules in engine scripts?

How can I add lua modules in engine scripts?

Postby TrabantDeLuxe » Wed Aug 22, 2018 9:54 am

TrabantDeLuxe
Passed Fireman
 
Posts: 246
Images: 7
Joined: Mon Mar 21, 2016 10:10 pm
Location: Delft, NL
Has thanked: 176 times
Been thanked: 263 times

Re: How can I add lua modules in engine scripts?

Postby JamesLit » Wed Aug 22, 2018 7:06 pm

I can't say I know anywhere near enough about LUA to help you - other than that I can assure you that there are already a large number of advanced locos and units etc out there that use a modular system for their LUA with great success, even with a very large number of LUA scripts doing different jobs, some at least 10 I think! So it should definitely be possible to do this successfully, so do persevere!
The Forge | Like us on Facebook!
Manager | Content built with care, not compromises.
User avatar
JamesLit
Driver
 
Posts: 366
Images: 26
Joined: Mon Apr 07, 2014 3:26 pm
Location: Kent
Has thanked: 433 times
Been thanked: 141 times

Re: How can I add lua modules in engine scripts?

Postby TrabantDeLuxe » Wed Aug 22, 2018 8:56 pm

Thanks James. I'm fairly confident this is 1) not impossible, and 2) just me not doing proper syntax.
TrabantDeLuxe
Passed Fireman
 
Posts: 246
Images: 7
Joined: Mon Mar 21, 2016 10:10 pm
Location: Delft, NL
Has thanked: 176 times
Been thanked: 263 times

Re: How can I add lua modules in engine scripts?

Postby AndiS » Thu Aug 23, 2018 8:36 am

AndiS
Top Link Driver!
 
Posts: 640
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 261 times
Been thanked: 302 times

Re: How can I add lua modules in engine scripts?

Postby TrabantDeLuxe » Thu Aug 23, 2018 11:10 am

TrabantDeLuxe
Passed Fireman
 
Posts: 246
Images: 7
Joined: Mon Mar 21, 2016 10:10 pm
Location: Delft, NL
Has thanked: 176 times
Been thanked: 263 times

Re: How can I add lua modules in engine scripts?

Postby AndiS » Thu Aug 23, 2018 11:49 am

You see, I never learnt Lua properly. Life is too short for all the syntax creativity of a zillion language designers.
That is why I dearly hope that I will never be so short of money that I would have to unearth my distant memories of COBOL. SQL is bad enough and slightly younger and hard to avoid.
AndiS
Top Link Driver!
 
Posts: 640
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 261 times
Been thanked: 302 times

Re: How can I add lua modules in engine scripts?

Postby VictoryWorks » Tue Aug 28, 2018 9:11 am

I'm pretty sure "Require" doesn't work, DTG disabled it a while back.

Instead they implemented their own version as follows:

--include=..\BaseScripts\Generic Variables.lua
--include=..\BaseScripts\Control Manager.lua
etc.

It basically works by just bolting the "included" scripts onto the calling script making the functions available throughout.
It means you can re-use code easily and have different physical files to keep things in some kind of order and swap out easily. You can also do a basic function override by calling a function name in your main script and then having different mocde with that function depending on which script you choose to "include".
User avatar
VictoryWorks
Driver
 
Posts: 331
Joined: Mon Apr 07, 2014 1:22 pm
Has thanked: 37 times
Been thanked: 223 times

Re: How can I add lua modules in engine scripts?

Postby AndiS » Tue Aug 28, 2018 12:11 pm

I use require all the time, as in

require "Assets/AndiS/FPSignals/scripts/Shared by All.out"

but without messing with modules.

Note 1: Note the path starting in the railworks folder - could this be the reason why the original example did not work? I assumed the file to be in all possible places.

Note 2: I compile my files one by one because then I get reasonable messages from the compiler with line numbers that refer to the real file.


When I still used --include, line numbers always referred to the amalgamated temporary file that is created when the Blueprint Editor reads these lines.
AndiS
Top Link Driver!
 
Posts: 640
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 261 times
Been thanked: 302 times

Re: How can I add lua modules in engine scripts?

Postby VictoryWorks » Tue Aug 28, 2018 12:32 pm

Yeah I'm an idiot, of course Require works.. it's how you can add the Autocoach stuff we do to any loco! :oops:
I'm going to put that brain fart down to 2 weeks on holiday and just STFU :oops:
User avatar
VictoryWorks
Driver
 
Posts: 331
Joined: Mon Apr 07, 2014 1:22 pm
Has thanked: 37 times
Been thanked: 223 times

Re: How can I add lua modules in engine scripts?

Postby AndiS » Tue Aug 28, 2018 2:13 pm

Let's rename the thread "ageing scripters need breaks".
I hope that Trabant really just forgot the full path, then the club will be complete. :lol:
AndiS
Top Link Driver!
 
Posts: 640
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 261 times
Been thanked: 302 times

Next

Return to Rolling Stock General

Who is online

Users browsing this forum: No registered users and 0 guests