Scenario system: Difference between revisions
(Create page documenting the scenario system, from my own research) |
(moved scenario section from Tutorial:Localisation) |
||
(14 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{Languages}} | {{Languages}} | ||
The scenario system allows save-based mods to be created, so that installing mods separately is not necessary. This allows for server side scripting, or to provide a separate objective than the vanilla freeplay (which is actually a scenario, just like the [[tutorial|tutorial campaign]]). | |||
The scenario system allows save-based mods to be created, so that installing mods separately is not necessary. This allows for server side scripting, or to provide a separate objective than the vanilla freeplay (which is actually a scenario, just like the [[campaign]]). | |||
== Creation == | == Creation == | ||
Creation of a scenario starts in the | Creation of a scenario starts in the [[map editor]]. The map editor allows an author to save a map that they have created as a scenario. This allows players to add special scripting to the scenario. | ||
There are two ways to create a scenario: | There are two ways to create a scenario: | ||
* Via the [[Map editor]]. | * Via the [[Map editor]]. | ||
* Creating a new folder in the scenarios folder, and adding a control.lua. | |||
== Differences between scenarios, saves, and mods == | == Differences between scenarios, saves, and mods == | ||
Line 16: | Line 15: | ||
There are a few differences between a scenario, a save, and a mod. In a way, a scenario takes parts from both. | There are a few differences between a scenario, a save, and a mod. In a way, a scenario takes parts from both. | ||
* Scenarios, unlike mods, cannot add anything to the game. The only type of scripting allowed in a scenario is scripting that would occur in control. | * Scenarios, unlike mods, cannot add anything to the game. The only type of scripting allowed in a scenario is scripting that would occur in control.lua. | ||
* Scenarios | * Scenarios can have premade maps, such as the supply scenario, or can have maps made with the map generator, such as freeplay. | ||
* Scenarios do not need to be installed client side, unlike mods. This allows servers to implement small changes to gameplay on their end, such as displaying a MOTD to joining players. | * Scenarios do not need to be installed client side, unlike mods. This allows servers to implement small changes to gameplay on their end, such as displaying a MOTD to joining players. | ||
* Scenarios, unlike normal saves, are stored in a different folder. | * Scenarios, unlike normal saves, are stored in a different folder. | ||
* Scenarios can be used to create a bit of a story, as the campaign does. | * Scenarios can be used to create a bit of a story, as the campaign does. | ||
== Limitations of Scenarios == | == Limitations of Scenarios == | ||
* | * Scenarios must be packaged into a mod to be distributed on the mod portal. | ||
* Scenarios cannot add anything to the game (Namely, they may not make calls to data:extend()). | * Scenarios cannot add anything to the game (Namely, they may not make calls to data:extend()). | ||
* Scenarios count as mods for the purpose of isolating [[achievements]]. | * Scenarios count as mods for the purpose of isolating [[achievements]]. | ||
* Scenarios can be packaged without an <code>info.json</code> and <code>description.json</code>, but then it won't be possible to host a new multiplayer game using this scenario. | |||
== Playing a scenario == | == Playing a scenario == | ||
There are several scenarios included into the game by default. To play a scenario, click Play->Scenarios, and choose either a user scenario, or a scenario from the base game. The Freeplay scenario is the same as the basic game, where the objective is to launch a rocket. | There are several scenarios included into the game by default. To play a scenario, click Play->Scenarios, and choose either a user scenario, or a scenario from the base game or mod. The Freeplay scenario is the same as the basic game, where the objective is to launch a rocket. | ||
Upon choosing a scenario to play and saving the game, a normal save will be created that encompasses the map itself, and the control.Lua scripting that was provided by the scenario. This can be removed by deleting the script.dat and control.Lua files from the save, turning it into a normal save. Do this at your own risk, as it may break the save depending on how intertwined the scenario is with the save. | Upon choosing a scenario to play and saving the game, a normal save will be created that encompasses the map itself, and the control.Lua scripting that was provided by the scenario. This can be removed by deleting the script.dat and control.Lua files from the save, turning it into a normal save. Do this at your own risk, as it may break the save depending on how intertwined the scenario is with the save. | ||
Line 37: | Line 36: | ||
== Installing scenarios == | == Installing scenarios == | ||
Scenarios made by other players can be installed into a folder called scenarios in the player's [[application directory]]. It can then be played from the scenarios menu. | Scenarios made by other players can be installed into a folder called scenarios in the player's [[application directory#User_data_directory|user data directory]]. It can then be played from the scenarios menu. | ||
Scenarios added by mods are also shown in the Scenarios menu. | |||
== Packaging a scenario as a mod == | |||
Create an empty mod, as described in [[Tutorial:Mod_structure]]. Then, simply add a "scenarios" folder, and copy your scenario into that folder. If you created a scenario with the map editor, you can find it in the scenarios folder in your [[application directory#User_data_directory|user data directory]]. | |||
== Localization of scenario name and description == | |||
Scenario name and description, which are seen in the "Start a new game" scenario selector are localised using [[Tutorial:Localisation#File_format|locale files]] inside the scenario. The keys are <code>scenario-name</code> and <code>description</code>, both without a [category]. Example from freeplay/locale/en/freeplay.cfg: | |||
<pre>scenario-name=Freeplay | |||
description=Your task is to launch a rocket into space. Start from nothing, work your way up with automation, and don't forget to protect yourself from the natives.\n[font=default-bold]This is the intended way of playing Factorio.[/font]</pre> | |||
== See also == | == See also == | ||
* [[ | * [[Tutorial]] | ||
* [[Map editor]] | * [[Map editor]] | ||
* [[ | * [[Map generator]] |
Latest revision as of 16:15, 18 January 2023
The scenario system allows save-based mods to be created, so that installing mods separately is not necessary. This allows for server side scripting, or to provide a separate objective than the vanilla freeplay (which is actually a scenario, just like the tutorial campaign).
Creation
Creation of a scenario starts in the map editor. The map editor allows an author to save a map that they have created as a scenario. This allows players to add special scripting to the scenario.
There are two ways to create a scenario:
- Via the Map editor.
- Creating a new folder in the scenarios folder, and adding a control.lua.
Differences between scenarios, saves, and mods
There are a few differences between a scenario, a save, and a mod. In a way, a scenario takes parts from both.
- Scenarios, unlike mods, cannot add anything to the game. The only type of scripting allowed in a scenario is scripting that would occur in control.lua.
- Scenarios can have premade maps, such as the supply scenario, or can have maps made with the map generator, such as freeplay.
- Scenarios do not need to be installed client side, unlike mods. This allows servers to implement small changes to gameplay on their end, such as displaying a MOTD to joining players.
- Scenarios, unlike normal saves, are stored in a different folder.
- Scenarios can be used to create a bit of a story, as the campaign does.
Limitations of Scenarios
- Scenarios must be packaged into a mod to be distributed on the mod portal.
- Scenarios cannot add anything to the game (Namely, they may not make calls to data:extend()).
- Scenarios count as mods for the purpose of isolating achievements.
- Scenarios can be packaged without an
info.json
anddescription.json
, but then it won't be possible to host a new multiplayer game using this scenario.
Playing a scenario
There are several scenarios included into the game by default. To play a scenario, click Play->Scenarios, and choose either a user scenario, or a scenario from the base game or mod. The Freeplay scenario is the same as the basic game, where the objective is to launch a rocket.
Upon choosing a scenario to play and saving the game, a normal save will be created that encompasses the map itself, and the control.Lua scripting that was provided by the scenario. This can be removed by deleting the script.dat and control.Lua files from the save, turning it into a normal save. Do this at your own risk, as it may break the save depending on how intertwined the scenario is with the save.
Installing scenarios
Scenarios made by other players can be installed into a folder called scenarios in the player's user data directory. It can then be played from the scenarios menu.
Scenarios added by mods are also shown in the Scenarios menu.
Packaging a scenario as a mod
Create an empty mod, as described in Tutorial:Mod_structure. Then, simply add a "scenarios" folder, and copy your scenario into that folder. If you created a scenario with the map editor, you can find it in the scenarios folder in your user data directory.
Localization of scenario name and description
Scenario name and description, which are seen in the "Start a new game" scenario selector are localised using locale files inside the scenario. The keys are scenario-name
and description
, both without a [category]. Example from freeplay/locale/en/freeplay.cfg:
scenario-name=Freeplay description=Your task is to launch a rocket into space. Start from nothing, work your way up with automation, and don't forget to protect yourself from the natives.\n[font=default-bold]This is the intended way of playing Factorio.[/font]