Freeciv
(give_tech() update)
Tag: rte-source
(give_tech() notify parameter usage)
Tag: rte-source
Line 17: Line 17:
   
 
==Notifying players about techs==
 
==Notifying players about techs==
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. Typically you want to send three notifications;
+
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.
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.
 

Revision as of 05:40, 19 December 2015

This document describes how to convert freeciv 2.5 compatible lua script to S2_6 version (one that will become freeciv 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. Currently this goes up to compatibility with freeciv trunk revision 30485.

Disaster signal

Signal disaster has one new parameter. The 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.

Cost of Given Technology

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 techs

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.