Control Unit

From Dual Universe Wiki
(Redirected from Control Units)
Jump to: navigation, search
Concept art of a Control Unit

The Control Unit is an element that can be used to control the actions of other elements via Lua scripting. Control units can be placed on constructs and manually connected to other elements, then Lua scripts can be installed in the control unit's on-board Distributed Processing Unit (DPU), allowing the scripts to control the actions and effects of the attached elements. Before elaborating on Control Units, the user must first understand what a Distributed Processing Unit is.

Distributed Processing Units[edit | edit source]

DPUs are computers that can automatically perform a number of in-game functions, and they are found in a variety of predefined game elements. The DPUs in most elements will automatically connect themselves to the DPUs of other elements and will perform their designated functions without player intervention. For example, the DPU in the cockpit element automatically connects itself to all engines and adjusters on a construct and orders those engines to activate in accordance the with player's control inputs (WASD). While most DPUs cannot be modified themselves, control units can be used to manage the DPUs in other predefined game elements. It is possible to have multiple DPUs present and active on the same construct at the same time.

Customization[edit | edit source]

The DPU inside of a control unit has multiple slots and functions that allow the players to greatly customize the actions of the attached elements. Each DPU has different "slots" into which Lua scripts can be inserted, and each script can be assigned its own states, functions, actions, and triggers that determine when it activates, which elements it effects, and how it functions when it activates. These options are extremely robust and give the players a great deal of control over the actions of their constructs, even to the point of allowing for relatively complex actions. For example, constructs can easily be programmed to follow their owner around, with the on-board DPU automatically controlling the flight and pathing of the construct.

Other types of DPUs[edit | edit source]

One particularly important "abstract" DPU is the System DPU. This DPU is capable of emitting events when keys are pressed. It is almost always desirable to plug in the System DPU, because this allows the player to control a construct's scripts with keystrokes bound to actions. Thus, typically there will be several event handlers in a custom DPU to catch action events emitted by the System DPU. The System DPU is also capable of emitting "timeout" events when a timer is due, or at regular intervals, and many other useful functionalities.

Scripting with DPUs[edit | edit source]

There needs to be at least one Control Unit on a ship, and its DPU must be customized. Inside this DPU, the System DPU (typically in the "system" slot) must be plugged in, plus at least 3 engines pointing upwards to lift the ship, and 2 more engines at the back of the ship to make it move forward. There also needs to be an inclinometer, which is an Element that provides the getPitch and getRoll functions, to know about the pitch/roll angles of the ship. Next, set a timer with the system DPU (call the system.setTimer(0.1) function to set the update every 0.1 second) and catch the corresponding timeout event. The LUA script can then be set to query the inclinometer about the pitch/roll and use these values to correct the intensity of thrust power in the engines (using the setPower function) to stabilize the ship tilting. And of course, the action events can be caught from the System DPU to inform the script about the direction in which the player wants to steer the ship. [1]

See Also[edit | edit source]

Lua Scripting