EEP 12

EEP 12

hambiUK Dec 28, 2016 @ 4:18am
Lua programming!!
I'm new to EEP and struggled for a few days until yesterday when I realised you could control things using Lua. HOWEVER!!!

I went to the help and there is a Lua manual. However, it doesn't contain a full list of EEP built in functions!!! Where is the full list of EEP functions?

When a contact allows a Lua function to be called I understand you can put the Lua function in the edit box and it will be called (for example on a vehicle contact). In one tutorial (48) in the code there is a function

function TurnOnEffects(name)

The sound contact on the track just has "TurnOnEffect" in the Lua function (no parameter). What is the value "name" that is passed to the actual function and where does this come from???

I think answers to the above will answer my other questions. However, one thing I want to do is have a vehicle contact and to get the route information for the train that has triggered the contact. So if the train triggers a vehicle contact that calls "vehicle_contact" how does that function know what route the train is on? If I have 3 vehicle contacts on my layout can they all call the "vehicle_contact" function and how does the function then know which contact called it?

I have to say that with EEP it feels like a brilliant program but you have to use it with both hand tied behind your back and one eye blindfolded.
< >
Showing 1-5 of 5 comments
Goetz Dec 28, 2016 @ 7:27am 
Yes, the current Lua manual for EEP still needs translating.
The German edition comes with a table of all available EEP-related Lua functions.

You can download the latest German edition here, if you wish -> EEP forum - Lua manual[www.eepforum.de]

Even though the manual is in German, the table will offer you plenty of insight, due to it's structured nature. Not ideal, I know. But as a quick remedy? Meanwhile I'm working on the translation.

regarding parameters:
EEP sees everything in the contact's Lua field as the function name. Brackets would therefore be misinterpreted as part of the name.

But any function call from within a contact always sends the name of the triggering train as a parameter. So all you need to do is get hold of it via that variable name in your function declaration.

One user programmed a clever single line which can catch whatever EEP is sending and translate it into a proper function call with multiple parameters and more. Visit our forum and ask for it and I'll point you in the right direction.
Last edited by Goetz; Dec 28, 2016 @ 7:42am
hambiUK Dec 31, 2016 @ 7:34am 
Hi Fritz. I am having difficulty accessing the EEP forum so could you help me here. I have seen that someone posted some Lua code that enables parameters to be passed from the contact points to the user code. However, the instructions on the forum are in German and if I translate the page the translation is poor and google translate tries to also translate the code. At the moment I cannot get the snippet working.

Could you kindly tell me what code I need to put at the start of my code for parameters to work?

Also I see some explanation about commas and point (fullstops) but I don't understand these comments - maybe it is the translation. Also there are comments that in later versions of EEP the train name is passed as standard to the user code but again the translations don't make sense what the user needs to do to maintain this.

Really the best solution is that EEP actually enables the real program to pass parameters. That would be the best solution. However, until that happens I really need to get the code working and would greatly appreciate your help.

Also, at the moment I am having problems with my internet connection. I know you sent me a link for the new EEP13 manual but I cannot view it. Is it available as a pdf to download?

Many thanks and best wishes for the new year
Goetz Jan 1, 2017 @ 4:11am 
Train names became a standard parameter in function calls from contacts with EEP version 12.

The first code line from Benny for parameter use was older and train names were lost when you used this early version. But Benny updated his code shortly after EEP 12 was released and it can now pass on the train names.

Another issue with the early version was that commas got converted to colons. Reason being that in the German language, a comma is used as a decimal separator. Benny quickly realised that commas are required as separators for multiple parameters and put his code right in that regard too.

He updated his posting recently so that the opening post now holds the current version of his code. This is the code line:

setmetatable(_ENV,{__index=function(s,k) local p=load(k);if p then local f=function(z) local s=Zugname;Zugname=z;p();Zugname=s end;_ENV[k]=f;return f end;return nil end})
Zugname is the variable for the train's name.

Make sure you run your script (containing this line of code) once before you enter any Lua functions into a contact's Lua field or else EEP will complain that this function doesn't exist in your script.

Hope that helps
Fritz
Last edited by Goetz; Jan 1, 2017 @ 4:15am
hambiUK Jan 1, 2017 @ 7:07am 
Happy New Year Fritz. Many thanks for posting the code needed. It now works. Brilliant.

I can now code the control system that I would like to build. I'll let you know when complete (target = within 1 week).

One other question. Is there any information about how to build assets? I don't plan to build anything complicated but would like to build some specific switchs/buttons to work with my lua code if it isn't difficult to do. I know there are some in the shop but 1) not sure they are exactly what I want and 2) it would be fun to build some myself. If I do (and if they work) I'm happy to make them available.
Goetz Jan 2, 2017 @ 1:44am 
You need the dedicated construction software called "Home-Nostruktor", available from the shop. You can create models with other modelling software (e.g. Blender), but the Home-Nos is needed to add some EEP specifics to the model and build the dedicated EEP model format.
< >
Showing 1-5 of 5 comments
Per page: 1530 50