Jump to content
NQ-Nomad

Alpha 2 Lua changes and novelties

Recommended Posts

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

x3CJXMeoLdWcuIwncPUrXA7bMxL28Wdb8nCutMWb

 

Hovercraft Seat

HCDczeC9xy33kHMrwLEHimiMj4e2ZXxUNOv9v8nU

 

Programing Board

StpudqGMBswhgMsjjYxxwhxq_pqgYhu4q6wqC0KG

 

Hovercraft Seat and Programming Board widgets do stack:

pjdnn7HZ60MVeuskFEKp-wyEU7posP73hj3q4XcO

 

 

Adding/removing element widgets in Lua

 

API:

slot.show()
slot.hide()

 

Default Cockpit LUA Script

cOdWeRNKaxukxWquvU91TA8Cuq7a_rtWXPA_-4k2

 

 

We can instead only show the Core Unit widget, and hide the Control Unit widget (shown by default):

core.show()
unit.hide()

y0vC1HWPgadb7AB5r3OTjycalOunvZ9CPrgFxwxI

 

tSh8A8aWleSKtCg0B9xICd_frXkfdrmuYdrPf56U

 

 

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

VYb7g8MH8Y2NcGUz-QSSTYotCS5nln2-bFPrhQLq

 

ywDPCChVXxU-0oFcPfrjS7v1wvJbIa3jZoX8-z--

 

 

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)

Hq7rn-et3cAlDSxEDOAtC5ibGt1tS-oXN2HKzSuG

 

QWfv-tFtm36ogDoav-kQXSJQCJGZGYXWFm3LgUZ3

 

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)

tLUpYtJ52PVpfYzGnpipnw9yI9AY4gBStfjNuE99

 

UJModMxQVFLaKUJZLgnBmSKLEScTJpPcQAibaXYC

 

Predefined style classes
 

DsnxNBaUrhA65dbTS2mlA5hj5a8IewZNHdCFWVRW

 

class=”monitor_left”         defines the area of the left monitor.
class=”monitor_right”        defines the area of the right monitor.

 

LXZUV_hSvbhDfPiB_mqdf43B5r3tPL44IEDBCRRP

 

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.

 

yvKo5BwAsouNIXnYT7mtWuggiFYWcEOaBs2GEQuO

 

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Do filters now work in svg? Eg: gausian blur, previously code that works in chrome would not work in game due to syntax  issues

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
Share on other sites

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 ???

Share this post


Link to post
Share on other sites
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()

 

Share this post


Link to post
Share on other sites

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?

cockpit_part.png

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

 

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

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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...