LuaWML/Time

From Wesnoth
(Redirected from LuaWML:Time)

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
This page was last modified on 11 March 2016, at 03:42.