The scenario library: Difference between revisions
(Created Page) |
(Added onLoad and OnSave events) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category: Resources]] | [[Category:Lua Resources]] | ||
Back To [[TOTPP Functions]] | Back To [[TOTPP Functions]] | ||
Line 10: | Line 10: | ||
[[civ.scen.onUnitKilled|onUnitKilled]] | [[civ.scen.onUnitKilled|onUnitKilled]] | ||
<code>civ.scen.onUnitKilled(function ( | <code>civ.scen.onUnitKilled(function (loser, winner) -> void)</code> | ||
[[civ.scen.onLoad|onLoad]] | |||
<code>civ.scen.onLoad(function (buffer) -> void)</code> | |||
Buffer is a string attached to the end of a saved game file. It can be unserialized back into a state table. | |||
[[civ.scen.onSave|onSave]] | |||
<civ.scen.onSave( function () --> string)</code> | |||
The string returned is attached to the end of the saved game file. | |||
Line 81: | Line 94: | ||
[[civ.scen.onResolveCombat|onResolveCombat]] | [[civ.scen.onResolveCombat|onResolveCombat]] | ||
<code>civ.scen.onResolveCombat(function (defaultResolutionFunction, attacker | <code>civ.scen.onResolveCombat(function (defaultResolutionFunction, defender, attacker) -> boolean)</code> | ||
Registers a function to be called during every combat turn. The first parameter of the callback is the default resolution function, as implemented by the game. It takes the attacker and defender as parameters. You can call this to produce a result for cases you don't need to handle yourself. | Registers a function to be called during every combat turn. The first parameter of the callback is the default resolution function, as implemented by the game. It takes the attacker and defender as parameters. You can call this to produce a result for cases you don't need to handle yourself. |
Latest revision as of 20:05, 15 August 2019
Back To TOTPP Functions
civ.scen.onTurn(function (turn) -> void)
civ.scen.onUnitKilled(function (loser, winner) -> void)
civ.scen.onLoad(function (buffer) -> void)
Buffer is a string attached to the end of a saved game file. It can be unserialized back into a state table.
<civ.scen.onSave( function () --> string)
The string returned is attached to the end of the saved game file.
civ.scen.onScenarioLoaded(function () -> void)
civ.scen.onNegotiation(function (talker, listener) -> boolean)
civ.scen.onSchism(function (tribe) -> boolean)
civ.scen.onCityTaken(function (city, defender) -> void)
civ.scen.onCityProduction(function (city, prod) -> void)
civ.scen.onCentauriArrival(function (tribe) -> void)
civ.scen.onCityDestroyed(function (city) -> void)
civ.scen.onBribeUnit(function (unit, previousOwner) -> void)
civ.scen.onGameEnds(function (reason) -> boolean)
civ.scen.onKeyPress(function (keyCode) -> void)
Registers a function to be called every time a key is pressed.
civ.scen.onActivateUnit(function (unit, source) -> void)
Registers a function to be called every time a unit is activated. The callback takes the unit activated as a parameter, and the source of unit activation. Source is `true` if activated by keyboard or mouse click, `false` if activated by the game itself.
civ.scen.onCityFounded(function (city) -> void)
Registers a function to be called every time a city is founded. The callback takes the city as a parameter.
civ.scen.onResolveCombat(function (defaultResolutionFunction, defender, attacker) -> boolean)
Registers a function to be called during every combat turn. The first parameter of the callback is the default resolution function, as implemented by the game. It takes the attacker and defender as parameters. You can call this to produce a result for cases you don't need to handle yourself. Return `true` to continue combat, `false` to stop.
civ.scen.onCanBuild(function (defaultBuildFunction, city, item) -> boolean)
Registers a function to be called every time a check is done whether a city can build something or not. It is called for all unit types, improvements and wonders. The first parameter of the callback is the default build function, as implemented by the game. It takes the city and item as parameters. You can call this to produce a result for cases you don't need to handle yourself. `item` can be a unittype, improvement or wonder. Return `true` if `city` is allowed to produce `item`, `false` if not.