Difference between revisions of "Introduction to Mission Scripting"
Zonkmachine (talk | contribs) (fixup) |
Zonkmachine (talk | contribs) (Add link to new page: 'Missions and the mission list') |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | 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 | + | 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 working examples. 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 [http://lua-users.org/wiki/LearningLua lua-users wiki: Learning Lua] page is a good place to start, or read [http://tylerneylon.com/a/learn-lua/ "learn lua in 15 minutes"] | If you are not familiar with Lua, the [http://lua-users.org/wiki/LearningLua lua-users wiki: Learning Lua] page is a good place to start, or read [http://tylerneylon.com/a/learn-lua/ "learn lua in 15 minutes"] | ||
Line 16: | Line 16: | ||
* [[Strings and translation]] | * [[Strings and translation]] | ||
* [[Interacting with the player: BBS forms]] | * [[Interacting with the player: BBS forms]] | ||
+ | * [[Missions and the mission list]] | ||
* [[Missions and NPC Interaction]] | * [[Missions and NPC Interaction]] | ||
* [[Surviving a reload]] | * [[Surviving a reload]] |
Latest revision as of 23:12, 18 July 2024
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 working examples. 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: