Jump to content
The simFlight Network Forums

LUA - check a single bit of an offset


Recommended Posts

Hi there

i try to set a toggle switch for taxi lights.

I know how to check an complete offset for changes - it´s like that

event.offset("0D0C", "UW", "TaxiLights")

But how can check just the bit which is important for the TaxiLights? (In this case the bit i need to know is :cool:

I think i can read out the value of a bit so that i can decide if a LED has to turn on or off for the next step.

Hope you´ll understand my english

Thanks for your response.

Stefan

EDIT:

Sorry for the question i think i found a workaround.

If you´re interested in it i will post it.

function TaxiLights(offset, value) -- TaxiLights prüfen und LED schalten

gfd.SetBright(GFT8, 0, 12)

TL = logic.And(ipc.readUW(0x0D0C), 8) -- Wert prüfen ob TaxiLight ein oder aus sind

if TL == 1 then

gfd.SetLight(GFT8, 0, 1)

else

gfd.ClearLight(GFT8, 0, 1)

end

end

function SetTaxiLights(model, unit) -- Taxi Lights ein/ausschalten

gfd.GetValues(model, unit)

if gfd.TestButton(1) then -- prüfen ob Hebel für Taxi lights Wert true hat

ipc.clearbitsUW(0X0D0C,8)

else

ipc.setbitsUW(0X0D0C,8)

end

end

event.offset("0D0C", "UW", "TaxiLights") -- Abfrage ob Aktion bei Lichtern

event.gfd(GFT8, 0, "SetTaxiLights") -- Abfrage ob Aktion bei Switches

Edited by Kaffeebart
Link to comment
Share on other sites

Sorry for the question i think i found a workaround.

If you´re interested in it i will post it.

function TaxiLights(offset, value) -- TaxiLights prüfen und LED schalten

gfd.SetBright(GFT8, 0, 12)

TL = logic.And(ipc.readUW(0x0D0C), ...

...

This is okay, but because you are provided with the value of offset 0D0C as the parameter "value" it would be more efficient to use it, so:

TL = logic.And(value, ...

BTW you need to put a space before your final ")" to stop the Forum software turning things into emoticon faces! ;-)

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.