NQ-Nomad Posted July 4, 2019 Share Posted July 4, 2019 Hi guys, Following up the release of the third Alpha 2 DevBlog about Lua, we wanted to develop things further for the most curious, dedicated and skilled among you. The API has changed so you guys will have to redo a certain amount of stuff. This being said, you'll find below some documentation that will allow you to do pretty neat stuff so knock yourselves out! Thanks to NQ-Arlequin for his help and for writing this! How does it work All ControlUnits (Cockpits, HovercraftSeats and ProgramingBoards) can display information on the screen when activated by the current player. CockpitUnits and PilotingSeats have predefined behavior that should suit most players. However advanced players can edit the ControlUnit LUA script to adapt the display to their needs. There are different levels of customization possible: Intermediate Difficulty: Show/hide the default widget of an element linked to the Control Unit. Advanced Difficulty: Mixing those widgets in custom panels. (New in Alpha 2) Expert Difficulty: Create custom widgets from your own data or existing elements data. (New in Alpha 2) Expert Difficulty: Create your own HTML code to display custom content on your screen. (Modified in Alpha 2) Default behavior Cockpit view Hovercraft Seat Programing Board Hovercraft Seat and Programming Board widgets do stack: Adding/removing element widgets in Lua API: slot.show() slot.hide() Default Cockpit LUA Script We can instead only show the Core Unit widget, and hide the Control Unit widget (shown by default): core.show() unit.hide() NEW - Reorganizing Element widgets within panels in Lua API: system.createWidgetPanel(title) → panelId system.destroyWidgetPanel(panelId) system.createWidget(panelId, type) → widgetId system.destroyWidget(widgetId) system.addDataToWidget(dataId, widgetId) system.removeDataFromWidget(dataId, widgetId) slot.getDataId() → dataId slot.getWidgetType() → type Instead of having all the fuel container widgets in different panels, I can create my own panel and add all fuel widgets to this panel: fuelPanel = system.createWidgetPanel("Fuel Tanks") for i=1,container_size do widget = system.createWidget(fuelPanel, container[i].getWidgetType()) system.addDataToWidget(container[i].getDataId(), widget) end NEW - Creating custom widgets in Lua API: system.createData(json) → dataId system.destroyData(dataId) system.updateData(dataId, json) slot.getData() → json You can finally write your own custom data, and display them using predefined custom widget types. 4 exist for now: text, title, value, and gauge. panel = system.createWidgetPanel("Panel") -- Display “Hello World” widgetText = system.createWidget(panel, "text") dataText = system.createData('{"text": "Hello World"}') system.addDataToWidget(dataText, widgetText) -- Display a title “Title” widgetTitle = system.createWidget(panel, "title") dataTitle = system.createData('{"text": "Title"}') system.addDataToWidget(dataTitle, widgetTitle) -- Display a gauge filled at 60% widgetGauge = system.createWidget(panel, "gauge") dataGauge = system.createData('{"percentage": 60}') system.addDataToWidget(dataGauge, widgetGauge) -- Display “Weight 80 kg” widgetValue = system.createWidget(panel, "value") dataValue = system.createData('{"label": "Weight", "value": "80", "unit": "kg"}') system.addDataToWidget(dataValue, widgetValue) You can now combine all those methods to create your own customized panels. CHANGED- Customize screen using html code. API: system.setScreen(htmlContent) system.showScreen(1/0) You can write your own html code to change the appearance of the control unit screen. It will be displayed below the widgets, so if you want full control: you can hide all widgets. html = '<div class="monitor_left window">' html = html .. '<div class="center window">monitor_left</div>' html = html .. '</div>' html = html .. '<div class="monitor_right" style="background-color: red;">' html = html .. '<div class="center window">monitor_right</div>' html = html .. '</div>' system.setScreen(html) system.showScreen(1) Predefined style classes class=”monitor_left” defines the area of the left monitor. class=”monitor_right” defines the area of the right monitor. class=”grid” stacks all its child elements on an invisible wrapping vertical grid. class=”center” positions an element centered to its parent. Can be the viewport. class=”window” applies the Dual Universe background and border. Well, that's it for this time! We hope you'll enjoy the info here to surprise us Cheers, Nomad hdparm, Murmandamus, Elias24 and 8 others 11 Link to comment Share on other sites More sharing options...
Helediron Posted July 4, 2019 Share Posted July 4, 2019 Hmm, if i link antigravity generator to PB and call antigrav.GetData(), do i get AGG-specific variables like current base altitude and anti-g power as json? Link to comment Share on other sites More sharing options...
Mucus Posted July 4, 2019 Share Posted July 4, 2019 Do filters now work in svg? Eg: gausian blur, previously code that works in chrome would not work in game due to syntax issues Link to comment Share on other sites More sharing options...
Destrin Posted July 5, 2019 Share Posted July 5, 2019 Is there a way to get a full screen display window on a cockpit? The cockpit is less useful and not as functional as a chair because of the hud is not full screen. The cockpit has more mass, much larger and looks cooler but lacks in functionality compared to the other control units. VerZalj, Eviltek2099 and MathDrou 3 Link to comment Share on other sites More sharing options...
Lachenlaud Posted July 5, 2019 Share Posted July 5, 2019 7 hours ago, Destrin said: Is there a way to get a full screen display window on a cockpit? The cockpit is less useful and not as functional as a chair because of the hud is not full screen. The cockpit has more mass, much larger and looks cooler but lacks in functionality compared to the other control units. Yep. Lua Link to comment Share on other sites More sharing options...
Destrin Posted July 5, 2019 Share Posted July 5, 2019 2 hours ago, Lachenlaud said: Yep. Lua I have not yet seen this possible. If you have been able to do it, can you please show me? cause i have talked to multiple people about this in previous releases and it was not possible. Link to comment Share on other sites More sharing options...
Lachenlaud Posted July 5, 2019 Share Posted July 5, 2019 45 minutes ago, Destrin said: I have not yet seen this possible. If you have been able to do it, can you please show me? cause i have talked to multiple people about this in previous releases and it was not possible. I'll add it to my growing list of requests. Gotta play with the new changes they just dropped into Lua - was kinda broken during the test on the 4th, but they'll get it fixed and then I'll tool around with it a bit. Destrin 1 Link to comment Share on other sites More sharing options...
Patrox Posted October 4, 2019 Share Posted October 4, 2019 Sorry how do you Show your new widget ? i made those try: Panel.show() panel.show() but at each time it give me a scrit error ! Find !! as it is write in the unit modul, you must write: unit.show the widget appear, but "Hello Word" does not appear ??? Link to comment Share on other sites More sharing options...
Patrox Posted October 4, 2019 Share Posted October 4, 2019 On 7/4/2019 at 3:20 PM, NQ-Nomad said: dataText = system.createData('{“text”: "Hello World"}') if you make a copy of this line in your LUA code, it deos'nt work because the quote use for the label " text" hare not the good one. you must write : dataText = system.createData('{"text": "Hello World"}') And "Hello Word" appear in your windlet So the complet running code is: panel = system.createWidgetPanel("Panel") -- Display “Hello World” widgetText = system.createWidget(panel, "text") dataText = system.createData('{"text": "Hello Word"}') system.addDataToWidget(dataText, widgetText) -- Display a title “Title” widgetTitle = system.createWidget(panel, "text") dataTitle = system.createData('{"text": "Title"}') system.addDataToWidget(dataTitle, widgetTitle) -- Display a gauge filled at 60% widgetGauge = system.createWidget(panel, "gauge") dataGauge = system.createData('{"percentage": 60}') system.addDataToWidget(dataGauge, widgetGauge) -- Display “Weight 80 kg” widgetValue = system.createWidget(panel, "value") dataValue = system.createData('{"label": "Weight", "value": "80", "unit": "kg"}') system.addDataToWidget(dataValue, widgetValue) unit.show() Link to comment Share on other sites More sharing options...
NQ-Nomad Posted October 7, 2019 Author Share Posted October 7, 2019 Thanks Patrox! The original post has been edited to fix this. Cheers, Nomad Link to comment Share on other sites More sharing options...
NQ-Nomad Posted October 10, 2019 Author Share Posted October 10, 2019 It's fixed in the original post, Nanoman! Thank you. Cheers, Nomad Link to comment Share on other sites More sharing options...
Shealladh Posted October 27, 2019 Share Posted October 27, 2019 Can we modify or make classes like the Predefined style classes ? Also with the screen Grid Area, can we make them appear in the cockpit etc, so that when you look left, right, up and down, to have side widgets, so that you can place them on the joystick or say a small screen where the Fire Extinguisher is? Can we also change the perspective of the container, to make it look attached to the cockpit parts? Eviltek2099 1 Link to comment Share on other sites More sharing options...
Dinkledash Posted October 29, 2019 Share Posted October 29, 2019 On 7/5/2019 at 2:06 AM, Destrin said: Is there a way to get a full screen display window on a cockpit? The cockpit is less useful and not as functional as a chair because of the hud is not full screen. The cockpit has more mass, much larger and looks cooler but lacks in functionality compared to the other control units. I would think that widgets that are displaying in system will appear in 3 person view. Link to comment Share on other sites More sharing options...
Destrin Posted October 29, 2019 Share Posted October 29, 2019 1 hour ago, Dinkledash said: I would think that widgets that are displaying in system will appear in 3 person view. The default ones do not, are you saying custom widgets appear in 3rd person for the Cockpit? Link to comment Share on other sites More sharing options...
Taelessael Posted October 30, 2019 Share Posted October 30, 2019 If anyone can get the hud in the cockpit to display like the hud for every other control unit, both in first person and in third, I would love to know how. Link to comment Share on other sites More sharing options...
Kalion Posted October 31, 2019 Share Posted October 31, 2019 11 hours ago, Taelessael said: If anyone can get the hud in the cockpit to display like the hud for every other control unit, both in first person and in third, I would love to know how. +1 Eviltek2099 1 Link to comment Share on other sites More sharing options...
Shealladh Posted December 23, 2019 Share Posted December 23, 2019 Is three widgets on a screen the limit? How can we control how the placement and Window wrapping inside each widget. They seem to just flow in a column and are randomly placed Link to comment Share on other sites More sharing options...
Shealladh Posted December 23, 2019 Share Posted December 23, 2019 Having acess to the CSS/Style Class would also help. Otherise have to be like everyone else and skip these and just never use cockpits Link to comment Share on other sites More sharing options...
basox70 Posted January 7, 2020 Share Posted January 7, 2020 Hi all, Is there any chance that cockpit UI will change ? Displayed informations are a bit to low on the screen... I thought we could have some kind of augmented reality UI but it is not possible to do so ? Also, i join Taelessael & Kalion, it would be great if cockpit UI was the same as others UI Link to comment Share on other sites More sharing options...
JayleBreak Posted January 7, 2020 Share Posted January 7, 2020 I haven't tried them yet, but you can place "stickers" (either an oriented arrow or a single digit (0-9)) in 3-D space which is a limited form augmented reality. Link to comment Share on other sites More sharing options...
NilinChan Posted September 19, 2020 Share Posted September 19, 2020 hmmm Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now