Moving to Lua
Contents
Goal
This article assumes that a development goal of Pioneer is to move as much game logic as possible out of the C++ core, and into the Lua environment. That in time, Lua will govern what happens in the game, and the engine will be left to implement how that happens. What, not how is a guiding principle.
The goal of this article, therefore, is to determine a sequence of feature development where each feature is not implemented before something upon which it depends. Each feature is defined as a heading in the next section, including a bulleted list of features which must exist beforehand, and which should exist beforehand.
Features
Lua control of hyperspace
Instead of being a core API function, Ship.HyperspaceTo() would be a Lua function directly responsible for deciding upon the distance, fuel use, elapsed time, chance of failure and destination of a jump. This function could call a core function to initiate a jump with elapsed time and destination arguments, and the core would immediately set about destroying the current system, animating the jump and building the next one. If it decided the jump was to happen, the Lua function would deduct the relevant quantity of whichever cargo (if any).
Lua-defined cargo
All cargo (and equipment) items are defined in Lua, using some sort of cargo class. The engine itself is completely agnostic as to the concept of cargo. It doesn't know or care what you have, as long as it knows how much mass there is.
Depends on:
- #Lua control of Hyperspace (hyperspace requires Hydrogen)
- Presence of an UpdateCargoMass method in a ship.
Arbitrary cargo
Special items ("MacGuffins") required to complete missions or quests. Could include, for example, "5 Furies statue" or "Mycoid vaccination".
Depends on:
Arbitrary equipment
Mission-specific equipment, such as cameras, soil samplers, radiometers, beacons, etc which must be activated or deployed as part of a mission.
Depends on:
- #Lua-defined cargo
- New UI