Difference between revisions of "Introduction to Mission Scripting"
Zonkmachine (talk | contribs) m |
Zonkmachine (talk | contribs) (Updating links) |
||
Line 14: | Line 14: | ||
Chapters: | Chapters: | ||
* [[Interacting with the game: Event-based programming]] | * [[Interacting with the game: Event-based programming]] | ||
+ | * [[Strings and translation]] | ||
* [[Interacting with the player: BBS forms]] | * [[Interacting with the player: BBS forms]] | ||
+ | * [[Missions and NPC Interaction]] | ||
* [[Surviving a reload]] | * [[Surviving a reload]] |
Revision as of 14:13, 17 November 2021
Pioneer is extensible through the Lua scripting language. This document is intended to take the reader through the basics of coding up a mission for Pioneer, with a working example. The assumption is made that the reader is already aware of basic programming concepts, and in particular has some knowledge of the Lua programming language.
If you are not familiar with Lua, the lua-users wiki: Learning Lua page is a good place to start, or read "learn lua in 15 minutes"
Pioneer's Lua environment
Pioneer contains a full Lua interpreter. There are three instances of the interpreter; one for defining models, one for defining the galaxy, and one for writing mission scripts. This document is focused exclusively on the latter of the three.
When Pioneer is started, the universe is generated. After the universe is generated, Pioneer traverses the data/libs directory and all subdirectories, looking for files ending in the .lua
extension. Each of these files are loaded into the interpreter and run. After these are run, Pioneer traverses the data/modules directory and does exactly the same thing. After this, the main menu is shown, and the player can begin a game.
The order in which the Lua scripts are loaded and run is not strictly defined, other than the fact that scripts in the data/libs directory will be executed before scripts in the data/modules directory.
Any globally defined functions or variables defined in those scripts will be available to any other scripts. We recommend that any functions or variables not explicitly intended for use by other scripts be declared with the local
keyword, which will make them available only within the scope of the current file.
Chapters: