LUA Debugging

LUA Debugging

Postby SteveP_trains » Fri Aug 17, 2018 6:04 pm

Hi
Hope this is a very simple question with a simple answer :)

Within an Engine LUA script to control emitters etc, what Debug command would I use to view the value of a global or variable that is being changed during the scripting?

Have tried various combinations of DEBUG commands and all seem to not compile or then blow up the script in-game.
I've managed to get the LogMate up but then that's it!!

Thanks in advance

Steve
SteveP_trains
General Shed Duties
 
Posts: 22
Joined: Mon Oct 05, 2015 6:16 pm
Has thanked: 1 time
Been thanked: 9 times

Re: LUA Debugging

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

I gave up with the built in debugging tools a while ago as they tend to get constantly spammed with non-essential messages making them very hard to read.
I have this in all our scripts..

-- Debug print
function DebugPrint ( str )
local t = Call( "GetSimulationTime" );
local n = string.sub (Call ( "GetRVNumber"));
SysCall ( "ScenarioManager:ShowAlertMessageExt", "Engine:" .. n .. " " .. t, str, 5, "" );
end

This produces a pop up in the top right corner that fades after 5 seconds and looks like:
Engine:1001YNNY13A 10:22:37
This is my debug message

Then I just call DebugPrint("This is my debug message") in the script as needed. I have some that are always there (Initial start up, loco reset on player take over/leave, etc) and some I throw in temporarily when I'm bug chasing.

When the engine is ready for public release I just comment out the 3 lines in the function so it's easy to put back in if needed later.
User avatar
VictoryWorks
Driver
 
Posts: 317
Joined: Mon Apr 07, 2014 1:22 pm
Has thanked: 34 times
Been thanked: 213 times

Re: LUA Debugging

Postby SteveP_trains » Wed Aug 29, 2018 7:56 am

Thanks for that information, Pete
I will give that a try. It sounds it will do what I need.

Steve
SteveP_trains
General Shed Duties
 
Posts: 22
Joined: Mon Oct 05, 2015 6:16 pm
Has thanked: 1 time
Been thanked: 9 times


Return to Rolling Stock General

Who is online

Users browsing this forum: No registered users and 1 guest