Fandom

Freeciv

How to update a lua script from 2.5 to 2.6

704pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

This document describes how to convert freeciv 2.5 compatible lua script to 2.6 compatible ones. Please check these carefully to avoid your script mis-behaving, maybe in some rarely reached special case. These are changes to scripting API requiring special attention. Additions to the API that do not affect old scripts are not listed.

Disaster signalEdit

Signal disaster has been deprecated. Connect to new disaster_occurred signal instead. The new signal has one more parameter than the old signal. This new parameter, had_internal_effect, tells if the disaster caused any of the effects handled internally by the freeciv engine. Default default.lua has a handler that informs user that disaster was harmless if that parameter is true. If you are using default default.lua, and want to avoid it from giving out the message, for example if the disaster actually had some consequences in your own script.lua, simply prevent default.lua handler from firing by returning true from your own handler.

City Transferred signalEdit

Signal city_lost has been deprecated. Connect to new city_transferred signal instead and check reason parameter as needed; "conquest" is the one that's equivalent to old city_lost signal.

City Size Change signalEdit

Signal city_growth has been deprecated. Connect to new city_size_change signal instead and check reason parameter as needed; "growth" if the one that's equivalent to old city_growth signal.

Cost of Given TechnologyEdit

edit.give_technology() / Player:give_technology() have been deprecated in favor of give_tech() that has additional parameter cost. Value -1 ("apply freecost") results in similar behavior than give_technology() has hardcoded.

Notifying players about techsEdit

Since the shared research system has been revamped, you may want to update the way you send notifications about techs the script gives to someone. You can either request that server sends all the necessary notifications by setting notify parameter of give_tech(), or make custom notification messages. In the latter case you typically want to send three notifications; one for the player getting the tech (notify.event(...E.TECH_GAIN...)), one for ones sharing the research (notify.research(...E.TECH_GAIN...)), and one for the embassies (notify.embassies(...E.TECH_EMBASSY...)). You may leave the first one out, and set selfmsg to true in the second one if you don't want different message for the player getting the tech.

Creating Roads and BasesEdit

As Bases and Roads are now just subtypes of Extras, Tile:create_base() and Tile:create_road() have been deprecated in favor of generic Tile:create_extra()

See alsoEdit

How to update from an old to the next...
...tileset 1.14 to 2.0 2.0 to 2.1 2.1 to 2.2 2.2 to 2.3 2.3 to 2.4 2.4 to 2.5 2.5 to 2.6 2.6 to 3.0
...ruleset n/a n/a n/a 2.2 to 2.3 2.3 to 2.4 2.4 to 2.5 2.5 to 2.6 2.6 to 3.0
...lua script n/a n/a n/a n/a n/a n/a 2.5 to 2.6 2.6 to 3.0

Also on Fandom

Random Wiki