LuaAPI/wesnoth/schedule

From The Battle for Wesnoth Wiki

The schedule module contains functions to query and manipulate the time of day schedule. In addition to the functions in this module, the wesnoth.current.schedule object represents the active schedule itself.

wesnoth.schedule.get_time_of_day

  • wesnoth.schedule.get_time_of_day(reference, [for turn]) → time of day info

Returns the schedule information. The reference can be any of the following:

  • a location - returns the information for that hex, accounting for any time areas
  • a time area ID - returns the information for that time area
  • nil - returns the information for the global scenario schedule

The second parameter is the turn number for which to return the information, which defaults to the current turn. This function does not account for any illumination type effects (either unit abilities or terrain lighting) that might alter the effective time of day - use get_illumination instead if you need that.

The function returns a table with these named fields:

  • time_of_day.idID

The ID of the [time] tag.

  • time_of_day.lawful_bonusbonus

The lawful bonus on this hex.

  • time_of_day.bonus_modifiedbonus

The difference between lawful_bonus and the base lawful bonus from the [time] tag. For get_time_of_day, this is always 0, but for get_illumination, it may be non-zero.

  • time_of_day.redinteger
  • time_of_day.greeninteger
  • time_of_day.blueinteger
  • time_of_day.imageimage path
  • time_of_day.maskimage path
  • time_of_day.soundsound path
  • time_of_day.namevisible name

All the information on how the time of day is shown to the player.

wesnoth.schedule.get_illumination

  • wesnoth.schedule.get_illumination(location, [for turn]) → time of day info

Like get_time_of_day, but also accounts for modifiers from unit illumination or terrain lighting on the passed hex. The parameters accepted are the same, but if passed nil or a time area ID, it will return the exact same information that get_time_of_day returns.

This only considers modifiers based on the current state of the map. If you wanted to perform a "what if" check to determine what the illumination would become after a unit moves, you would need to move the unit, call this function, and then move it back where it started. Similarly, if you wanted to consider the illumination after a hypothetical terrain change, you would need to change the terrain, call the function, and then change it back.

wesnoth.schedule.replace

  • wesnoth.schedule.replace(new schedule)

Replaces the global scenario schedule with a new schedule.

This page was last edited on 4 July 2021, at 23:35.