Jump to content
The simFlight Network Forums

PMDG Failure & Pause FS


Recommended Posts

Is it possible to use FSUIPC to pause Flight Sim 9 when a failure occurs in the PMDG 747/737 or the LDS 767? I'm away from the sim during the cruise, but I do want to enable failures.

If the failures are set in FS, and not just local to PMDG code, then, yes. You could do it with a small Lua plug-in program.

You would need the list of FSUIPC offsets (a document in the FSUIPC SDK) to check through the ones which might be affected by failures -- there's a complete set starting at offset 0B64. Then, to see if the failures affect FS itself you could monitor those offsets (FSUIPC Logging tab, right-hand side) to see if they do get set.

If the failures are detectable (certainly, for instance, an engine out should be -- at minimum the Combustion flag in the Engine variables would change to 0), then the change can be set to cause an event in a pre-loaded Lua plug-in, which could then simply issue the pause control.

Let me know if you need any more help.

Regards

Pete

Link to comment
Share on other sites

  • 3 months later...

Pete:

I wrote up a small piece of code to perform event monitoring of the 'Brake Axis".

Its basically -

event.control(65588, 256, "BrakeApplied")

[its only my second lua script, so hope I got that correct]

Since this is an 'event monitor'-type script, I want this to be pre-loaded upon start up of FSUIPC.

Was researching the forum to find out how and i came upon this where i see you mention the word 'preloaded'.

If the failures are detectable (certainly, for instance, an engine out should be -- at minimum the Combustion flag in the Engine variables would change to 0), then the change can be set to cause an event in a pre-loaded Lua plug-in....

How does one 'pre-load' a lua script? The previous ones i used were all triggered by a button-press or key press, so i picked them from the dropdown. But in this case i want it loaded when FSUIPC comes up and wait for a brake event to occur.

Is this something that is automatically done - that when FSUIPC comes up, it reads all the .lua scripts in the Modules folder and loads them - or do i need to explicitly 'pre-load' scripts like this one?

Best regards,

CPJ

Link to comment
Share on other sites

Pete:

I wrote up a small piece of code to perform event monitoring of the 'Brake Axis".

Its basically -

event.control(65588, 256, "BrakeApplied")

[its only my second lua script, so hope I got that correct]

Well, that line on its own does nothing. You need the function BrakeApplied for it to call on your stated event.

Since this is an 'event monitor'-type script, I want this to be pre-loaded upon start up of FSUIPC.

Was researching the forum to find out howHow does one 'pre-load' a lua script?

Why "research the forum" when it is all written in the documents in the Lua package, or installed in your FS modules folder (for FSX)? Please look at the document which actually describes the FSUIPC Lua provisions, the one entitled "FSUIPC Lua Plug-Ins". It is explained in the section "What is provided in FSUIPC for Lua programming". The document isn't all that big, you should be able to find such information easily!

Regards

Pete

Link to comment
Share on other sites

Pete:

I have read that document multiple times since yesterday. I re-read that section again now. I cant see where it speaks of the manner in which lua scripts are loaded. I am missing it.

I will rephrase my question -

Are lua scripts loaded on demand by FSUIPC - Example - a button press occurs and the button is tied to the lua script.

OR

Does FSUIPC load all lua scripts on startup? - In this case i wouldnt need to do anything extra to get my event monitor script running.

All i meant to understand was your use of the term 'pre-loaded' in that post.

Here is the entire script -

-- This is a lua script to set Autobrake Disarm indicator based on Autobrake Switch Status and Brakes Control
-- Autobrake Disarm Annunciator is tied to Offset 66C0
-- Brakes control is FS Control 65588
-- Autobrake Physical Switch is connected as Virtual Button 64,0
-- March 15, 2009

function BrakeApplied(controlnum,param)  
	statusofvirtualbutton = ipc.testbutton(64,0) -- get the status of virtual button 64,0

	-- If Autobrake Switch (64,0) - Autobrake 1 - is ON AND Brakes Applied Control 65588 is received 
	-- then set Offset 66C0 to 1
	if (controlnum == 65588) and (statusofvirtualbutton) then
		-- set offset 66C0 to 1 
	    	ipc.writeUB(0x66C0,1)
	end
end

-- Start monitoring
event.control(65588, 256, "BrakeApplied")

Best regards,

CPJ

Link to comment
Share on other sites

I have read that document multiple times since yesterday. I re-read that section again now. I cant see where it speaks of the manner in which lua scripts are loaded. I am missing it.

Phew! You are missing it? I don't know how it could escape! ;-)

Does it not contain a paragraph, in the section I referred you to, beginning

"There are currently three explicitly reserved Lua names, for programs which are run automatically if present:"

Surely that is also in your copy? As it says, FSUIPC will automatically load Lua files with the given filenames.

You have several choices. First, please note that the term "pre-loaded" merely means "loaded before" -- i.e. loaded before the event which you are using to trigger the actions they specify. Preloading is NOT the same as "automatically loading", which I think is perhaps where you are getting mixed up?

There are several ways of "pre-loading":

1. You can assign a button or keypress to the Lua file, and use that to pre-load it. This would be a user-controlled pre-loading.

2. As 1 but make your assigned button an "initial button" which is automatically triggered. This initial button facility is an old one in FSUIPC, and is described in the Advanced Users guide.

3. You can name your Lua file "ipcinit.lua" or "ipcready.lua" (the latter is safer usually), as documented in the part of the PDF you appear to be missing.

4. You can leave your file named as it is now, and create an "ipcready" or "ipcinit" file which simply loads all the Lua files you want running. That used to involve writing strings to offset 0x0D70, but the latest FSUIPC interim releases (4.505 and 3.905) make that easier by the addition of the new:


  • ipc.macro()

library function, which can load macros or Lua programs by name.

Okay? Please do take another look, as I'm sure that section of the PDF can't have gone missing! :-(

Regards

Pete

Link to comment
Share on other sites

Pete:

Aha! I saw that and knew it had something to do with this. But didnt have the light go on in my head as to how.

I am smiling when i write this... didnt really mean missing it in the pdf... but more to mean that my brain doesnt seem to reading it right.... missing the point in my head! - like this :?

In any case... i SEE IT NOW - coming across loud and clear, my dear friend.

Someday i promise to impress you with my programming. :D

Since you mention ipc.macro, i have a related quesiton. I am clear that one can call a macro from a lua script. But can we call a lua script from a macro.

Tried it yesterday - didnt work. Here is the situation -

I have a mouse macro in my MIP Macro file.

It performs a Autobrake switch decrement 5 times to bring to RTO position. This works fine.

At the end of the 5 calls to decrement the switch, i ADDED another line to call a lua script. The lua script is to turn on the Autobrake Disarm annunciator ON for 3 seconds. The same one you helped with me with yesterday MyLight.lua with the following code -

ipc.writeUB(66C0, 1)
ipc.sleep(3000)
ipc.writeUB(66C0,0)

The switch decrement worked but the call to the lua script didnt work. I know that macros can include both mouse macros and keyboard macros. Cant lua calls be a part of a macro?

Here is the additional line i added to the macro -

3.6=CL2:R,1

Thanks in advance.

Link to comment
Share on other sites

... can we call a lua script from a macro.

Yes

Tried it yesterday - didnt work. Here is the situation -

... The switch decrement worked but the call to the lua script didnt work. I know that macros can include both mouse macros and keyboard macros. Cant lua calls be a part of a macro?

Yes

Here is the additional line i added to the macro -

3.6=CL2:R,1

Well, that should be okayprovided Lua file 2 is declared correctly in the INI file. I'll do some tests here. doesn't the FSUIPC log file show anything if you enable Button/Key logging?

Really, it would be tidier for you to put the other macro actions in the Lua file and assign to the Lua file instead of the Macro. That way it becomes independent of where the Lua file entry is in the INI file list, and is a neater approach in any case.

[LATER]

Ughbug! I've found out why the Lua file isn't called from a Macro. It actually tries to use entry 0 in the LuaFiles list, and logs a failure to load file ".lua".

I'll fix this now, watch for another update in the Announcement.

Regards

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.