The scenario library: Difference between revisions

From Scenario League Wiki
Jump to navigationJump to search
mNo edit summary
(Added onLoad and OnSave events)
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:


<code>civ.scen.onUnitKilled(function (loser, winner) -> void)</code>
<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, defender) -> boolean)</code>
<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


onTurn

civ.scen.onTurn(function (turn) -> void)


onUnitKilled

civ.scen.onUnitKilled(function (loser, winner) -> void)


onLoad

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.

onSave

<civ.scen.onSave( function () --> string)

The string returned is attached to the end of the saved game file.


onScenarioLoaded

civ.scen.onScenarioLoaded(function () -> void)


onNegotiation

civ.scen.onNegotiation(function (talker, listener) -> boolean)


onSchism

civ.scen.onSchism(function (tribe) -> boolean)


onCityTaken

civ.scen.onCityTaken(function (city, defender) -> void)


onCityProduction

civ.scen.onCityProduction(function (city, prod) -> void)


onCentauriArrival

civ.scen.onCentauriArrival(function (tribe) -> void)


onCityDestroyed

civ.scen.onCityDestroyed(function (city) -> void)


onBribeUnit

civ.scen.onBribeUnit(function (unit, previousOwner) -> void)


onGameEnds

civ.scen.onGameEnds(function (reason) -> boolean)


onKeyPress

civ.scen.onKeyPress(function (keyCode) -> void)

Registers a function to be called every time a key is pressed.


onActivateUnit

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.


onCityFounded

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.


onResolveCombat

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.


onCanBuild

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.