Jump to content
The simFlight Network Forums

Recommended Posts

Posted (edited)

Hi , iam now continue my work for the Jeehell FMGS - MSFS mod..

now i try to make an lua to set vars on the MSFS

ive found out that i only can use the Readout of the Status LEDS ...

 

so for an Example on console log :

739A (U16) = 0x1 for "ON" 0x0 for "OFF" now i want to send a var to msfs for the EXT POWER.. the var ive found out is "1 (>K:TOGGLE_EXTERNAL_POWER) } "

 

how can i make an Lua for it ?    iam totaly new on Programming .. Thanks 🙂

 

An other options are to work with the events 

 

 

Edited by scorpi1987
Posted
16 hours ago, scorpi1987 said:

now i want to send a var to msfs for the EXT POWER.. the var ive found out is "1 (>K:TOGGLE_EXTERNAL_POWER) }

K-type variables are events/controls. Simulator variables, or simvars, are a-type variables. All events (i.e. k-type variables) are available, either for assignment via the UI, or in lua you can use the ipc.control function. The number for the TOGGLE_EXTERNAL_POWER event is 67090 (see the file Controls List for MSFS Build 999.txt in your FSUIPC7 documents folder for a list of controls with there corresponding event number.

16 hours ago, scorpi1987 said:

how can i make an Lua for it ? 

You don't need to use lua, you can just assign to it. If you want to use lua, it would be
     ipc.control(67090, 1)
or you can use the calc. code directly, i.e.
    ipc.execCalcCode("1 (>K:TOGGLE_EXTERNAL_POWER)")

John

Posted

Like This ?

 

-- OffsetStatusCheck.lua
local offset = 0x7398
local length = 1

function checkOffset(offsetValue)
  local status = ipc.readUB(offset)
  ipc.log("Offset status: " .. status)
 
  if status == 0 then
    ipc.log("Setting ELECTRICAL_ExternalPower_1 Off")
    ipc.control(67090, 0) -- Beispiel Event-ID für ELECTRICAL_ExternalPower_1 Off
  elseif status == 1 then
    ipc.log("Setting ELECTRICAL_ExternalPower_1 On")
    ipc.control(67090, 1) -- Beispiel Event-ID für ELECTRICAL_ExternalPower_1 On
  end
end

event.offset(offset, "UB", "checkOffset")

 

Posted

Ok that with the Ext powe works well ...

Now i want to use ELECTRICAL_Battery_1 and ELECTRICAL_Battery_2 but this not in the 999.txt file ?

some of the Asobo Events are not in the file.. where i can find these numbers ?

 

Posted
2 hours ago, scorpi1987 said:

Like This ?

Your lua script looks ok.

1 hour ago, scorpi1987 said:

Now i want to use ELECTRICAL_Battery_1 and ELECTRICAL_Battery_2 but this not in the 999.txt file ?

That is because they are NOT events (or k-type variables). They look to be Input Events (or B-type variables). Try listing Input Events - are they listed?
You can use Input Events like other events - either assign to them directly (by checking Select for Input Events), and in lua you can use the ipc.execInputEvent function.

Please see the Advanced User manual on Input Events, and the FSUIPC Lua Library manual for details on lua library functions for Input Events.

John

  • Like 1
Posted

Ok thank you very much , 

I problem occurs on my idea 

 

when I read the offset of the Jeehell offset 

739F then the status has many conditions depending what button is pressed 

 

is it possible to specify that I only want to read the specific Bit 

example 

 

I want the 0 or 1 status of the LED LTK1 OFF

 

 

IMG_4308.jpeg

Posted (edited)
15 hours ago, scorpi1987 said:

is it possible to specify that I only want to read the specific Bit 

example 

I want the 0 or 1 status of the LED LTK1 OFF

You can use the lua logic library, e.g. to get bit 1 use
    logic.And(ipc.readUB(0x739F), 2))
(as 2^1 = 2)


   

Edited by John Dowson
Corrected ipc.read to ipc.readUB
Posted

Ok thats to high for my nooby skills... i write down what i want , maybe someone could create the script for me if someone has time and desire🙂

Offset      Lenght       Bit                         InputEvent                                 Function

7398          1              0                    "ELECTRICAL_ExternalPower_1"            0=OFF 1=ON

7396          1              3                    "ELECTRICAL_Battery_1"                      0=ON  1=OFF

7396          1              5                    "ELECTRICAL_Battery_2"                     0=ON  1=OFF

739F          1              1                    "FUEL_Pump_Tank_L_1"                        0=ON  1=OFF

739F          1              3                    "FUEL_Pump_Tank_L_2"                        0=ON  1=OFF

739F          1             5                     "FUEL_Pump_Tank_R_1"                       0=ON  1=OFF

739F          1              7                     "FUEL_Pump_Tank_R_2"                       0=ON  1=OFF

73A0         1              1                     "FUEL_Pump_Center_1"                       0=ON   1=OFF

73A0         1              3                     "FUEL_Pump_Center_2"                       0=ON   1=OFF

739A         1              3                    "ELECTRICAL_APU_Bleed"                     0=OFF   1=ON

739C         1              1                    "FUEL_Valve_APU"                                0=OFF    1=ON

739C         1              3                    "ELECTRICAL_APU_Starter "                  0=OFF    1=ON

Posted
1 hour ago, scorpi1987 said:

i write down what i want , maybe someone could create the script for me if someone has time and desire🙂

Sorry, but it is not clear what you want. Do you want to read the Jeehall offsets, like the one described in your previous post, or do you want to add those Input Events to spare FSUIPC offsets?
If you add Input Events to an offset, the minimum size is 1 byte, not 1 bit.

If you are using JeeHell and you want to add Input Events to offsets, you should not use the offsets allocated to JeeHell, but use other offsets designated as free for general use (e.g. starting at A000).

To add Input Events to offsets. please see the Advance User guide.

John

Posted

I want to read the Jeehell "LED status" to control the input events in msfs as i descriped above

Like this

Quote

local offset2 = 0x7396

local length = 1

function checkOffset2(offsetValue)
  local status = ipc.readUB(offset2)
  ipc.log("Offset 2 status: " .. status)
 
  if status == 32 or status == 0 then                     ( THIS MUST REPLACED WITH THE VALUE FROM THE READED BIT VALUE !!! )
    ipc.log("BAT 1 ON")
    ipc.execInputEvent("ELECTRICAL_Battery_1" , 1)
  elseif status == 8 or status == 40 then
    ipc.log("BAT 1 OFF")
    ipc.execInputEvent("ELECTRICAL_Battery_1" , 0)
  end
end

 

Posted
2 hours ago, scorpi1987 said:

Holy .. ok thats to complicated for me

Why is it complicated?

3 hours ago, John Dowson said:

 logic.And(ipc.readUB(0x739F), 2))

ipc.readUB((0x739F) : this reads offset 0x739F as an Unsigned Byte
logic.And(value, 2)  : this will perform a bitwise and operation (&) on the value to return the value of bit 1. The second parameter is the bit you want to check, so bit 0 would be 1 (2^0=1), bit 1 would be 2 (2^1=2), but 2 would be 4 (2^2=4), etc

3 minutes ago, scorpi1987 said:

I want to read the Jeehell "LED status" to control the input events in msfs as i descriped above

But if you can use Input Events, why do you also need to use the Jeehell offsets? Why can't you just use the Input Events?

Jeehell offset 739F holds 'the led status' (fault or off) for LTK1/2 & RTK1/2 - are these the same as the FUEL_Pump_Tank_L/R_1/2 Input Events?

Try adding one of those Input Events to an offset (as an unsigned byte), then try logging that offsets value, and also assign a button or key to toggle the value using Offset Byte Togglebits. See page 52 of the Advanced User guide. You can also log the JeeHell offsets (as UB in hex) and see if the bit value of that offset matches the value of your Input Event offset,

John

Posted

I want to use this to bring on my MSFS Flight Model the same condtion of these parameters from jeehell.   because when you use a homecockpit Jeehell is not communicate to the plane systems.  this is neccesary to become a good sound aof the engine Start...

So i want when a button in jeehell is pressed the LED status triggers the the same in MSFS... because i cant READ the (Control Input Offsets of Jeehell)...

 

Posted
7 minutes ago, scorpi1987 said:

I want to use this to bring on my MSFS Flight Model the same condtion of these parameters from jeehell.   because when you use a homecockpit Jeehell is not communicate to the plane systems.  this is neccesary to become a good sound aof the engine Start...

So i want when a button in jeehell is pressed the LED status triggers the the same in MSFS... because i cant READ the (Control Input Offsets of Jeehell)...

I am sorry but I don't understand this - think there is a translation issue here... Why can you not read the JeeHell offsets? Do you even need to, ie. do the Input Events not hold the same value ()i.e. on/off)?

Why don't you just try what I proposed: add one input event to an FSUIPC7 offset (e.g. add FUEL_Pump_Tank_L_1 to offset A000). Then monitor (i.e. Log->Offsets) that offset (A000) as U8, and also log offset 739F as U8 but in hex. Then assign a button or key to the FSUIPC control Offset Byte Togglebits using offset A000 and parameter x1 (to toggle first bit). Open the logging console (Log->Open Console) Then press the button or key that you assigned - does the input event offset change? Does bit 1 of the Jeehell offset also change? You can also set logging for Buttons & Keys (Log->Buttons & Keys).

 

 

Posted

ok i try it to declare easyer ..an example :

when jeehell LED offset 739F bit3 = 1       it must trigger the event ipc.execInputEvent("FUEL_Pump_Tank_L_2" , 0)  (OFF)

                                              when 0 then ipc.execInputEvent("FUEL_Pump_Tank_L_2" , 1)     (ON)

 

It Depends only as Bridge From Jeehell to MSFS    to control the internal Systems of my FlightModell...  i use a Modifed Asobo A320... with the whole systems...

 

 

Posted (edited)
1 hour ago, scorpi1987 said:

ok i try it to declare easyer ..an example :

when jeehell LED offset 739F bit3 = 1       it must trigger the event ipc.execInputEvent("FUEL_Pump_Tank_L_2" , 0)  (OFF)

                                              when 0 then ipc.execInputEvent("FUEL_Pump_Tank_L_2" , 1)     (ON)

Then try something like:

function FuelPumpTank_L2(offset, value)
  if value == 0 then
	ipc.execInputEvent("FUEL_Pump_Tank_L_2" , 1)
  else
	ipc.execInputEvent("FUEL_Pump_Tank_L_2" , 0)
  end
end

event.offsetmask(0x739F, 8, "UB", "FuelPumpTank_L2")

(the third bit is 2^3 = 8 )

The script should be ran via the [Auto] or [Auto.xxx] section (where xxx is your profile name).

John

Edited by John Dowson
missed function keyword
Posted

Tryed but it doesnt work

The Script isnt loading

 

This is my first and it works now must add in the same scematic the other ..
 

Quote

 

local offset1 = 0x7398

local length = 1


function initializeIPC()
  ipc.execInputEvent("ELECTRICAL_ExternalPower_1" , 0)
 
end

function checkOffset1(offsetValue)
  local status = ipc.readUB(offset1)
  ipc.log("Offset 1 status: " .. status)
 
  if status == 0 then
    ipc.log("Setting ELECTRICAL_ExternalPower_1 Off")
    ipc.execInputEvent("ELECTRICAL_ExternalPower_1" , 0)
  elseif status == 1 then
    ipc.log("Setting ELECTRICAL_ExternalPower_1 On")
    ipc.execInputEvent("ELECTRICAL_ExternalPower_1" , 1)
  end
end

 

initializeIPC() --


event.offset(offset1, "UB", "checkOffset1")

 

 

Posted
2 hours ago, scorpi1987 said:

Tryed but it doesnt work

The Script isnt loading

Why not? Have you added it to the [Auto] section or your profile specific [Auto.xxx] section? Have you checked in the user manuals on how to get a lua script auto-started?
I did miss the function keyword - I have added that now. Was that the issue?

2 hours ago, scorpi1987 said:

This is my first and it works now must add in the same scematic the other ..

Well,  that script will work as you are using offset 0x7398, and it looks like only bit 0 is being used in that offset,so you can just check the whole byte, as you are doing. However, if checking offset bits, and not the full offset value, you would need to use event.offsetmask, as I showed you. The alternative, if using event.offset on the whole byte (8-bits), and you would then need to use a conditional and the logic library to test the bit you are interested in, as I showed earlier.

 

Posted
19 minutes ago, scorpi1987 said:

function checkOffset1(offsetValue)
  local status = ipc.readUB(offset1)
  ipc.log("Offset 1 status: " .. status)

Also, this is NOT correct. Please see the Lua Library documentation. The first parameter of the handling function is the offset, the second the value, so you do not need to read this again. It should be:

function checkOffset1(offset, status)
  ipc.log("Offset 1 status: " .. status)

  if status == 0 then
    ipc.log("Setting ELECTRICAL_ExternalPower_1 Off")
    ipc.execInputEvent("ELECTRICAL_ExternalPower_1" , 0)
  elseif status == 1 then
    ipc.log("Setting ELECTRICAL_ExternalPower_1 On")
    ipc.execInputEvent("ELECTRICAL_ExternalPower_1" , 1)
  end
end

 

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.