How can I add lua modules in engine scripts?

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

Postby TrabantDeLuxe » Mon Sep 03, 2018 8:46 am

Still no luck unfortunately. I need someone with patience here.

@VictoryWorks: A reputable source showed me the same over discord the other day. I haven't experimented with this method, but it really seems to suit my needs just fine. I'm a bit busy with work lately, but I'll try it one day.

@AndiS: When using require, do you store the table of functions in a local or global variable (more precise, a pointer), or do you have another way of doing it. Including the full path did not work by the way.
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 » Mon Sep 03, 2018 10:02 am

All I did was replace --Initialise by require. Thus, my "required" files contain global functions as in
Code: Select all
function DistantInitialise()

and global variables (actually mostly constants that are defined as variables as in
Code: Select all
version = "1.0.2"

I call the functions the very ordinary way like
Code: Select all

and I reference the variables just as simple, no prefix or hash or table or anything.

This is bad programming style, but it worked. :lol:

I compile the pieces and then use the path starting with Assets in the require statement, as shown above. Trial and error led me there. Studying Lua documentation did not. But maybe I was too impatient in the old days and I never tried again.
Top Link Driver!
Posts: 629
Joined: Wed Apr 09, 2014 5:48 pm
Has thanked: 260 times
Been thanked: 301 times


Return to Rolling Stock General

Who is online

Users browsing this forum: No registered users and 1 guest