Fragtality / PilotsDeck

Directly control the FlightSim from your StreamDeck!
Other
93 stars 6 forks source link

Truncate numerical values #46

Closed jonestristand closed 5 months ago

jonestristand commented 10 months ago

It would be very useful to be able to truncate a numerical value, for instance I can retrieve the transponder code from the dataref in xplane, but there's no way I can think of to get just the ones, or just the tens, or just the hundreds digit...

Fragtality commented 10 months ago

Hmm, that is right. But I can't follow why splitting up a Value would be beneficial at all? I mean what would be the Reasoning behind displaying the Transponder on 4 different Buttons instead of 1?

Have you considered looking into FlyWithLua? You could run some code There that would split up that Number and write it to 4 custom DataRefs (which then can be used like any other DataRef in the Plugin).

jonestristand commented 10 months ago

FlyWithLua will work and I'll implement with that - thanks! However would be nice if some more numerical manipulation/calculation methods were implemented.

In my case I have a Stream Deck Plug and want to show one digit of the transponder on each dial and use the dials to change the number

On Thu, Jan 4, 2024 at 7:06 AM Fragtality @.***> wrote:

Hmm, that is right. But I can't follow why splitting up a Value would be beneficial at all? I mean what would be the Reasoning behind displaying the Transponder on 4 different Buttons instead of 1?

Have you considered looking into FlyWithLua? You could run some code There that would split up that Number and write it to 4 custom DataRefs (which then can be used like any other DataRef in the Plugin).

— Reply to this email directly, view it on GitHub https://github.com/Fragtality/PilotsDeck/issues/46#issuecomment-1877246250, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOGK3Y4JXIDWMO65JIZ6OLYM3ANTAVCNFSM6AAAAABBMAHMZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZXGI2DMMRVGA . You are receiving this because you authored the thread.Message ID: @.***>

Fragtality commented 10 months ago

Because you want it to be such a waste of Space?

You could also work with an Encoder Stack. Like with the Radio-Action, but in that Case 4 Actions stacked.

jonestristand commented 10 months ago

Haha hey no need to insult my setup ;-)

I have a folder just for the transponder (ident, Ta/ra, mode c) and all the encoders sitting there unused 😁

On Thu, Jan 4, 2024, 12:38 Fragtality @.***> wrote:

Because you want it to be such a waste of Space?

You could also work with an Encoder Stack. Like with the Radio-Action, but in that Case 4 Actions stacked.

— Reply to this email directly, view it on GitHub https://github.com/Fragtality/PilotsDeck/issues/46#issuecomment-1877729637, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOGK3YCOB3CTLCYMNHUXO3YM4HMJAVCNFSM6AAAAABBMAHMZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZXG4ZDSNRTG4 . You are receiving this because you authored the thread.Message ID: @.***>

Fragtality commented 10 months ago

Haha that wasn't the Intention 😅

Just wanted to make you aware that you can have it smaller, if you want to 😉

jonestristand commented 10 months ago

No worries, all good!

Do you collect profiles anywhere? I've got a fairly comprehensive one for the Q4XP

On Fri, Jan 5, 2024 at 5:18 AM Fragtality @.***> wrote:

Haha that wasn't the Intention 😅

Just wanted to make you aware that you can have it smaller, if you want to 😉

— Reply to this email directly, view it on GitHub https://github.com/Fragtality/PilotsDeck/issues/46#issuecomment-1878647676, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOGK3Y2RXBOZKX2JGQ6GZDYM74SBAVCNFSM6AAAAABBMAHMZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZYGY2DONRXGY . You are receiving this because you authored the thread.Message ID: @.***>

Fragtality commented 10 months ago

Well apart from my own Profiles (shared here or on fs/xp.to) I've added some User Contributions whom did not want to publish it theirself.

So yeah, I could add it here on GitHub, but it would be way more discoverable/noticeable for others if you publish it on x-plane.to and/or x-plane.org (The Plugin itself is also published there) 😉

Chpouky commented 9 months ago

Hey jonestristand !

Did you figure out a way to do it without LUA ? I'm trying to do the same thing. Right now I have a setup with 4 encoder stack, but I want the thousands/hundreds/etc to be separate as well, juste for the cool factor and because I have no use for the two remaining dials :p

jonestristand commented 9 months ago

I use FlyWithLua and this script:

dataref("transponder_code", "sim/cockpit/radios/transponder_code", "readonly")
digits =  create_dataref_table("mysim/cockpit/radios/transponder_digits", "IntArray")

function get_digit(value, digit)
  return math.floor(math.abs(value) / 10 ^ digit) % 10
end

function split_transponder()
  digits[0] = get_digit(transponder_code, 0)
  digits[1] = get_digit(transponder_code, 1)
  digits[2] = get_digit(transponder_code, 2)
  digits[3] = get_digit(transponder_code, 3)
end

do_every_frame("split_transponder()")
Chpouky commented 9 months ago

Awesome, thank you ! I was not familiar with LUA, didn't know it was so easy to read and understand :o

richardkennedy commented 6 months ago

Being able to truncate values would be useful in cases where someone doesn't have a registered/paid version of FSUIPC7 which is required to use LUA scripts. It's lazy I know, but there's a potential use case.

Fragtality commented 5 months ago

Please test the current Development Build: https://github.com/Fragtality/PilotsDeck/blob/master/Install-PilotsDeck-latest.exe

It added Support for truncating Values as part of the "Format" Option - or more specifically: being able to get the Substring of the Value. Things to Note:

Fragtality commented 5 months ago

Closed => Fixed (Value Format or Lua Values)

richardkennedy commented 5 months ago

I've created a display value button with an address of (A:TRANSPONDER CODE:1, Number) and a format of 3..1

With the sim transponder set to 0123, I would have expected the output to be 3, but it's 123?

Fragtality commented 5 months ago

Yeah, typical off-by-one Error 🤦‍♂️

Fix will be committed when I've repaired SimConnect 😩