Lua Scripting

From Dual Universe Wiki
Jump to: navigation, search
A visualization of a Distributed Processing Unit

Dual Universe gives players the opportunity to optimize or automate certain parts of constructs through scripting using the Lua programming language. Lua is simple, one of easiest to learn among commonly used languages. In Dual Universe, each Element contains its own set of values and functions. An engine can exert a force, a sensor can detect an object, a door can open. Each of the values in these Elements has the potential to be used in a script. An engine can be told how much force to exert and when, as its thrust is an assignable value. A door can be opened or closed, and whether it is or open or closed is another value. The interaction between all of the Elements in a construct is orchestrated by the script within something called a Distributed Processing Unit, which resides within a constructs Core Unit.

Distributed Processing Units[edit | edit source]

A DPU can be considered to be a sort of computer program. A DPU has "slots" into which Elements can be plugged into. Each DPU has several event handlers, each with its own filter. When the filter conditions for an event handler are met, the corresponding Lua code for that filter is executed. The code can use or assign any of the values associated with the Elements that are connected to the DPU.

Multiple Players and Scripts[edit | edit source]

When a script is running, it is running on the computer of the script owner. But the text of the script is synchronized, so everybody can see it. Whatever the scripts do is synchronized by the server for all players. Scripts are run on the clients computer, but several players can be simultaneously running and using different scripts which are all made by a single player (and thus running on that one players computer), and all players can see the scripts and effects of the scripts. One exception is that there cannot be two players controlling the same element at the same time.

Limitations[edit | edit source]

Certain limitations are implemented to ensure that certain aspects of the game are not ruined for players.

  • Scripts will only run if a player is within a particular distance of the Core Unit running the script.
  • Weapons, when scripted, will be extremely inefficient or underpowered compared to when they are used normally by players. This is to make the game more balanced.
  • Mining cannot be scripted to any extent; mining can only be done by a player using their Nanoformer.

Note[edit | edit source]

In time, this page will become a much more comprehensive guide on scripting with Lua. For now, with so little information available, it is merely a summary.

See Also[edit | edit source]

Lua Script and Distributed Processing Units