Default Wert für Schalterbelegung in LUA
- sierra_uniform
-
Topic Author
- Offline
- Elite Member
-
- Posts: 306
- Thank you received: 149
TPL_KUNENA_MESSAGE_CREATED Default Wert für Schalterbelegung in LUA
02 Dec 2022 20:07 - 02 Dec 2022 20:45
Hallo LUA Spezialisten,
ich habe mir für die Ansteuerung eines MUDLED-Moduls von Lindinger eine LUA-App geschrieben, die mir die Auswahl von bis zu 16 verschiedenen Lichtsequenzen über eine spezielle Verwendung eines Dreifachschalters ermöglicht. Hierzu verwende ich folgende Variablen, die über dieses Formular geändert werden können:
Nachdem die Schalter SwitchLED und SwitchSEQ zugewiesen sind, funktioniert alles wie gewünscht. Ich würde jetzt den beiden Schaltern beim ersten Aufruf der App gerne einen default Wert zuweisen, so dass sie, wie die anderen Parameterwerte auch, nicht auf NIL sondern z.B. auf Sb und Sc stehen. Nach meinem Verständnis müsste ich dazu die zugehörigen Variablen vor dem addInputbox mit einem Switch Item vorbelegen. Leider finde ich nirgendwo in der API Beschreibung eine Aussage dazu, wie ein solcher Switch Item aussehen muss, bzw. wie ich die Variablen vor dem Aufruf des Formulars mit einem solchen versorgen kann. Kann mir da jemand weiterhelfen?
Gruß Hermann
ich habe mir für die Ansteuerung eines MUDLED-Moduls von Lindinger eine LUA-App geschrieben, die mir die Auswahl von bis zu 16 verschiedenen Lichtsequenzen über eine spezielle Verwendung eines Dreifachschalters ermöglicht. Hierzu verwende ich folgende Variablen, die über dieses Formular geändert werden können:
Attachment sc01.png not found
Nachdem die Schalter SwitchLED und SwitchSEQ zugewiesen sind, funktioniert alles wie gewünscht. Ich würde jetzt den beiden Schaltern beim ersten Aufruf der App gerne einen default Wert zuweisen, so dass sie, wie die anderen Parameterwerte auch, nicht auf NIL sondern z.B. auf Sb und Sc stehen. Nach meinem Verständnis müsste ich dazu die zugehörigen Variablen vor dem addInputbox mit einem Switch Item vorbelegen. Leider finde ich nirgendwo in der API Beschreibung eine Aussage dazu, wie ein solcher Switch Item aussehen muss, bzw. wie ich die Variablen vor dem Aufruf des Formulars mit einem solchen versorgen kann. Kann mir da jemand weiterhelfen?
Gruß Hermann
Last edit: 02 Dec 2022 20:45 by sierra_uniform.
Please Log in or Create an account to join the conversation.
- davidmcq137
-
- Offline
- Senior Member
-
- Posts: 79
- Thank you received: 87
TPL_KUNENA_MESSAGE_REPLIED_NEW Default Wert für Schalterbelegung in LUA
13 Dec 2022 14:46
Hi Herman,
As far as I know, there is no way to do this with the lua API .. I tried everything I could think of (e.g. copying instances of the switchitem) and could not find a way. I noticed that Jeti added the createSwitch function in the API. You can achieve what you want with createSwitch .. but you won't be able to use the standard switch assignment menu that pilots are familiar with. You end up specifying the switch and the active direction in the menu itself. I'll attach a screenshot of my maps app that shows that.
You might think (I did!) that if you have createSwitch and getSwitchInfo API calls that you have all that you need .. but sadly, that does not work either. Turns out you can't find out which direction the switch was assigned (which way is +1 and which way is -1) so it's a 50/50 shot of getting it right. I've been in touch with Jeti on this and have suggested a simple extension to these two calls that would allow it all to work. Hopefully they will get to it sometime.
The reason I ran into this originally was the same reason as you .. to pre-assign controls (e.g. throttle) that had an almost-always correct default. Later on, I wanted to replace the Jeti persistence model (pSave and pLoad) with a json-based file approach .. because the pSave info is lost when the app is updated and for complex apps this was intolerable to ask pilots to re-set them up every time a new version comes along.
So I did the approach shown in the screenshot using createSwitch.
Hope this helps, and if anyone else knows how to do this better I'd love to hear it.
Dave
As far as I know, there is no way to do this with the lua API .. I tried everything I could think of (e.g. copying instances of the switchitem) and could not find a way. I noticed that Jeti added the createSwitch function in the API. You can achieve what you want with createSwitch .. but you won't be able to use the standard switch assignment menu that pilots are familiar with. You end up specifying the switch and the active direction in the menu itself. I'll attach a screenshot of my maps app that shows that.
You might think (I did!) that if you have createSwitch and getSwitchInfo API calls that you have all that you need .. but sadly, that does not work either. Turns out you can't find out which direction the switch was assigned (which way is +1 and which way is -1) so it's a 50/50 shot of getting it right. I've been in touch with Jeti on this and have suggested a simple extension to these two calls that would allow it all to work. Hopefully they will get to it sometime.
The reason I ran into this originally was the same reason as you .. to pre-assign controls (e.g. throttle) that had an almost-always correct default. Later on, I wanted to replace the Jeti persistence model (pSave and pLoad) with a json-based file approach .. because the pSave info is lost when the app is updated and for complex apps this was intolerable to ask pilots to re-set them up every time a new version comes along.
So I did the approach shown in the screenshot using createSwitch.
Hope this helps, and if anyone else knows how to do this better I'd love to hear it.
Dave
The following user(s) said Thank You: sierra_uniform
Please Log in or Create an account to join the conversation.
- sierra_uniform
-
Topic Author
- Offline
- Elite Member
-
- Posts: 306
- Thank you received: 149
TPL_KUNENA_MESSAGE_REPLIED_NEW Default Wert für Schalterbelegung in LUA
13 Dec 2022 16:58
Hello Dave,
Thank you very much for your detailed comments. To be honest, they reassure me somewhat. I was already of the opinion that I was simply too stupid to realize this. Maybe Jeti will agree to implement your suggestion.
Many greetings
Hermann
Thank you very much for your detailed comments. To be honest, they reassure me somewhat. I was already of the opinion that I was simply too stupid to realize this. Maybe Jeti will agree to implement your suggestion.
Many greetings
Hermann
Please Log in or Create an account to join the conversation.
- kefro
-
- Offline
- Premium Member
-
- Posts: 115
- Thank you received: 69
TPL_KUNENA_MESSAGE_REPLIED_NEW Default Wert für Schalterbelegung in LUA
13 Dec 2022 18:06
Hallo Hermann,
einfach in der "Local Function Init" einen Defaultwert beim laden des Schalters eintragen.
Steht in der API!!!
Gruß
Alex
einfach in der "Local Function Init" einen Defaultwert beim laden des Schalters eintragen.
Steht in der API!!!
Gruß
Alex
Pilatus PC6 Turboporter, TS-Modelltechnik, 3740mm, Jetcat SPT-5, DC-24
Pilatus PC6 Turboporter, Bräuer Modellbau, 3520mm, 3W80R2, DC-16_I
Pilatus PC6 Turboporter, Flitework, 2300mm, elektrisch, DC-16_I
Pilatus PC21, Phoenix, Kingtech K-30TP, DC-24
Pilatus PC6 Turboporter, Bräuer Modellbau, 3520mm, 3W80R2, DC-16_I
Pilatus PC6 Turboporter, Flitework, 2300mm, elektrisch, DC-16_I
Pilatus PC21, Phoenix, Kingtech K-30TP, DC-24
Please Log in or Create an account to join the conversation.
- davidmcq137
-
- Offline
- Senior Member
-
- Posts: 79
- Thank you received: 87
TPL_KUNENA_MESSAGE_REPLIED_NEW Default Wert für Schalterbelegung in LUA
13 Dec 2022 18:57
Alex, please say more .. sounds interesting.. how exactly?
Please Log in or Create an account to join the conversation.
- sierra_uniform
-
Topic Author
- Offline
- Elite Member
-
- Posts: 306
- Thank you received: 149
TPL_KUNENA_MESSAGE_REPLIED_NEW Default Wert für Schalterbelegung in LUA
13 Dec 2022 20:04 - 13 Dec 2022 20:11Hallo Alex.Hallo Hermann,
einfach in der "Local Function Init" einen Defaultwert beim laden des Schalters eintragen.
Steht in der API!!!
Alex
Was muss man da konkret angeben? Ich habe einiges versucht, hatte aber keinen Erfolg. Wo steht das? ich habe es nicht gefunden.
Gruß Hermann
Last edit: 13 Dec 2022 20:11 by sierra_uniform.
Please Log in or Create an account to join the conversation.
Moderators: Thorn, IG-Modellbau
Time to create page: 0.353 seconds