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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • 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.