Difference between revisions of "LuaWML/Time"

From The Battle for Wesnoth Wiki
(Move wesnoth.get_time_of_day to a dedicated ToD functions page)
 
(3 intermediate revisions by 2 users not shown)
Line 16: Line 16:
 
* '''name''': translatable string
 
* '''name''': translatable string
 
* '''red, green, blue''': integers (color adjustment for this time)
 
* '''red, green, blue''': integers (color adjustment for this time)
 +
 +
==== wesnoth.add_time_area ====
 +
 +
* '''wesnoth.add_time_area(''cfg'')'''
 +
 +
{{DevFeature1.13|0}}
 +
 +
Creates a new time area. This takes a WML table containing the same information normally used by the [[DirectActionsWML#.5Btime_area.5D|[time_area]]] tag.
 +
 +
{{DevFeature1.13|2}} Since 1.13.2, commas in the id attribute of the WML table are no longer handled specially for this function, allowing the creation of time areas with commas in their ids (but why would anyone want to do that, really).
 +
 +
==== wesnoth.remove_time_area ====
 +
 +
* '''wesnoth.remove_time_area(''id'')'''
 +
 +
{{DevFeature1.13|0}}
 +
 +
Removes a time area. This requires the time area to have been assigned an id at creation time.
 +
 +
{{DevFeature1.13|2}} Since 1.13.2, commas in the id are no longer handled specially for this function, requiring you to use a loop to remove multiple time areas instead.
 +
 +
for i, id in ipairs({'foo', 'bar', 'baz'}) do
 +
    wesnoth.remove_time_area(id)
 +
end
 +
 +
==== wesnoth.get_max_liminal_bonus ====
 +
 +
* '''wesnoth.get_max_liminal_bonus()'''
 +
 +
{{DevFeature1.15|4}} Returns the maximum attack bonus that liminal units can get in the current scenario.
 +
 +
[[Category: Lua Reference]]

Revision as of 15:07, 16 June 2020

LuaWML functions revolving around Time of Day schedule functionality, including time areas.

wesnoth.get_time_of_day

  • wesnoth.get_time_of_day([for_turn], [ {x, y, [consider_illuminates]} ])

Returns schedule information. First parameter (optional) is the turn number for which to return the information, if unspecified: the current turn ($turn_number). Second argument is an optional table. If present, first and second fields must be valid on-map coordinates and all current time_areas in the scenario are taken into account (if a time area happens to contain the passed hex). If the table isn't present, the scenario main schedule is returned. The table has an optional third parameter (boolean). If true (default: false), time of day modifying units and terrain (such as Mages of Light or lava) are taken into account (if the passed hex happens to be affected). The units' placement being considered is always the current one.

wesnoth.get_time_of_day(2, { 37, 3, true })

The function returns a table with these named fields:

  • id: string (as in [time])
  • lawful_bonus: integer (as in [time])
  • bonus_modified: integer (bonus change by units)
  • image: string (tod image in sidebar)
  • name: translatable string
  • red, green, blue: integers (color adjustment for this time)

wesnoth.add_time_area

  • wesnoth.add_time_area(cfg)

(Version 1.13.0 and later only)

Creates a new time area. This takes a WML table containing the same information normally used by the [time_area] tag.

(Version 1.13.2 and later only) Since 1.13.2, commas in the id attribute of the WML table are no longer handled specially for this function, allowing the creation of time areas with commas in their ids (but why would anyone want to do that, really).

wesnoth.remove_time_area

  • wesnoth.remove_time_area(id)

(Version 1.13.0 and later only)

Removes a time area. This requires the time area to have been assigned an id at creation time.

(Version 1.13.2 and later only) Since 1.13.2, commas in the id are no longer handled specially for this function, requiring you to use a loop to remove multiple time areas instead.

for i, id in ipairs({'foo', 'bar', 'baz'}) do
    wesnoth.remove_time_area(id)
end

wesnoth.get_max_liminal_bonus

  • wesnoth.get_max_liminal_bonus()

(Version 1.15.4 and later only) Returns the maximum attack bonus that liminal units can get in the current scenario.