[LuaDoc] Fix several errors in the inline documentation
This commit is contained in:
parent
795bb22be9
commit
c7741907c2
22 changed files with 141 additions and 66 deletions
|
@ -11,9 +11,9 @@ end
|
|||
|
||||
---Read a location from the front of a variable argument list.
|
||||
---@alias read_location_count
|
||||
---| '0' #Indicates no location was found.
|
||||
---| '1' #A location-like object was found - either an array of two integers, or a table or userdata with x and y keys.
|
||||
---| '2' #Two integer arguments were found and interpreted as the x and y coordinates respectively.
|
||||
---| 0 #Indicates no location was found.
|
||||
---| 1 #A location-like object was found - either an array of two integers, or a table or userdata with x and y keys.
|
||||
---| 2 #Two integer arguments were found and interpreted as the x and y coordinates respectively.
|
||||
---@return location|nil #The location, if one was found, or nil otherwise
|
||||
---@return read_location_count count #The number of arguments used to extract the location.
|
||||
function wesnoth.map.read_location(...)
|
||||
|
@ -92,9 +92,9 @@ if wesnoth.kernel_type() ~= "Application Lua Kernel" then
|
|||
|
||||
---Iterate over on-map hexes adjacent to a given hex.
|
||||
---@param map terrain_map
|
||||
---@return fun()
|
||||
---@overload fun(map:terrain_map, loc:location)
|
||||
---@overload fun(map:terrain_map, x:integer, y:integer)
|
||||
---@return fun():integer?,integer?
|
||||
---@overload fun(map:terrain_map, loc:location) : fun():integer?,integer?
|
||||
---@overload fun(map:terrain_map, x:integer, y:integer) : fun():integer?,integer?
|
||||
function wesnoth.map.iter_adjacent(map, ...)
|
||||
local where, n = wesnoth.map.read_location(...)
|
||||
if n == 0 then error('wesnoth.map.iter_adjacent: missing location') end
|
||||
|
@ -116,9 +116,7 @@ end
|
|||
|
||||
if wesnoth.kernel_type() == "Game Lua Kernel" then
|
||||
---Represents a reference to a single hex on the map
|
||||
---@class terrain_hex
|
||||
---@field x integer
|
||||
---@field y integer
|
||||
---@class terrain_hex : location
|
||||
---@field fogged boolean Whether the hex is fogged
|
||||
---@field shrouded boolean Whether the hex is shrouded
|
||||
---@field team_label? string|tstring The label on this hex visible to the current team
|
||||
|
@ -250,7 +248,7 @@ if wesnoth.kernel_type() == "Game Lua Kernel" then
|
|||
|
||||
---Get a label placed by a specific side
|
||||
---@param who integer
|
||||
---@return label_info
|
||||
---@return label_info?
|
||||
function hex_methods:label_for(who)
|
||||
return wesnoth.map.get_label(self.x, self.y, who)
|
||||
end
|
||||
|
@ -374,9 +372,9 @@ if wesnoth.kernel_type() == "Mapgen Lua Kernel" then
|
|||
return { "notall", ... }
|
||||
end,
|
||||
---Match adjacent hexes
|
||||
---@param f terrain_filter
|
||||
---@param adj direction[]
|
||||
---@param count integer|string A range list
|
||||
---@param f terrain_filter_tag
|
||||
---@param adj? direction[]|string
|
||||
---@param count? integer|string A range list
|
||||
---@return terrain_filter_tag
|
||||
adjacent = function(f, adj, count)
|
||||
return { "adjacent", f, adjacent = adj, count = count }
|
||||
|
@ -391,7 +389,7 @@ if wesnoth.kernel_type() == "Mapgen Lua Kernel" then
|
|||
---Match hexes within a given distance
|
||||
---@param r integer
|
||||
---@param f terrain_filter_tag
|
||||
---@param f_r terrain_filter_tag
|
||||
---@param f_r? terrain_filter_tag
|
||||
---@return terrain_filter_tag
|
||||
radius = function(r, f, f_r)
|
||||
return { "radius", r, f, filter_radius = f_r}
|
||||
|
|
|
@ -436,7 +436,6 @@ if wesnoth.kernel_type() ~= "Application Lua Kernel" then
|
|||
---@param var string Name of the variable to store
|
||||
---@param t WML[] An array of WML tables
|
||||
---@param context? WMLVariableContext Where to store the variable
|
||||
---@return WML[] #A table containing all the variables (starting at index 1)
|
||||
function wml.array_access.set(var, t, context)
|
||||
context = resolve_variable_context(context, "set_variable_array")
|
||||
context.set(var)
|
||||
|
|
|
@ -41,7 +41,7 @@ end
|
|||
---@generic T
|
||||
---@param input T[]
|
||||
---@param condition fun(val:T):boolean
|
||||
---@return T[]
|
||||
---@return T?
|
||||
function functional.find(input, condition)
|
||||
for _,v in ipairs(input) do
|
||||
if condition(v) then
|
||||
|
@ -55,8 +55,8 @@ end
|
|||
---@generic V
|
||||
---@param input table<K, V>
|
||||
---@param condition fun(key:K, val:V):boolean
|
||||
---@return K
|
||||
---@return V
|
||||
---@return K?
|
||||
---@return V?
|
||||
function functional.find_map(input, condition)
|
||||
for k,v in pairs(input) do
|
||||
if condition(k,v) then
|
||||
|
@ -186,7 +186,7 @@ local known_operators = {
|
|||
---@generic T
|
||||
---@param input T[]
|
||||
---@param operator string|fun(a:T, b:T):T
|
||||
---@param identity? T
|
||||
---@param ... T The initial value of the accumulator, typically the identity element.
|
||||
---@return T
|
||||
function functional.reduce(input, operator, ...)
|
||||
local f <const> = known_operators[operator] or operator
|
||||
|
|
|
@ -11,8 +11,9 @@ local function revindex(p)
|
|||
return x, p - x * 16384 - 2000
|
||||
end
|
||||
|
||||
---@alias location_set_operation fun(x:integer, y:integer, value:any):boolean
|
||||
---@alias location_set_operation fun(x:integer, y:integer, value:any):boolean|nil
|
||||
---@alias location_set_resolver fun(x:integer, y:integer, old:any, new:any):any
|
||||
|
||||
---A set of locations, with an optional associated value for each one.
|
||||
---@class location_set
|
||||
---@field values table<integer, any>
|
||||
|
@ -101,8 +102,8 @@ function methods:clear()
|
|||
end
|
||||
|
||||
---Look up a location in the set
|
||||
---@overload fun(x:integer, y:integer):any
|
||||
---@overload fun(loc:location):any
|
||||
---@overload fun(set:location_set, x:integer, y:integer):any
|
||||
---@overload fun(set:location_set, loc:location):any
|
||||
function methods:get(...)
|
||||
local loc = wesnoth.map.read_location(...)
|
||||
if loc ~= nil then
|
||||
|
@ -404,7 +405,7 @@ end
|
|||
|
||||
---Store the set in a WML variable
|
||||
---@param name string
|
||||
---@param mode "'always_clear'"|"'append'"|"'replace'"
|
||||
---@param mode? "'always_clear'"|"'append'"|"'replace'"
|
||||
function methods:to_wml_var(name, mode)
|
||||
mode = mode or "always_clear"
|
||||
local is_explicit_index = name[-1] == "]"
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
-- which is imo more convenient than the interface wesnoth.game_events.add or wesnoth.game_events.add_repeating offers
|
||||
-- even though its at this point technically equivalent to the latter.
|
||||
|
||||
|
||||
---Register an event handler
|
||||
---@param eventname string The event to handle; can be a comma-separated list
|
||||
---@param priority? number Events execute in order of decreasing priority, and secondarily in order of adding
|
||||
---@param fcn fun(ctx:event_context)
|
||||
---@overload fun(eventname:string, fcn:fun(ctx:event_context))
|
||||
return function(eventname, priority, fcn)
|
||||
if type(priority) == "function" then
|
||||
fcn = priority
|
||||
|
|
|
@ -35,7 +35,7 @@ end
|
|||
---Remove an item from the map
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param name string
|
||||
---@param name? string
|
||||
function wesnoth.interface.remove_item(x, y, name)
|
||||
local items = scenario_items:get(x, y)
|
||||
if not items then return end
|
||||
|
|
|
@ -85,81 +85,104 @@ function ai.suitable_keep(unit) end
|
|||
---@field result string
|
||||
|
||||
---Attack a unit
|
||||
---@param attacker unit
|
||||
---@param defender unit
|
||||
---@param attacker location
|
||||
---@param defender location
|
||||
---@param weapon? integer
|
||||
---@param aggression? number
|
||||
---@return ai_result
|
||||
---@overload fun(attacker:location, defender_x:integer, defender_y:integer, weapon?:integer, aggression?:number):ai_result
|
||||
---@overload fun(attacker_x:integer, attacker_y:integer, defender:location, weapon?:integer, aggression?:number):ai_result
|
||||
---@overload fun(attacker_x:integer, attacker_y:integer, defender_x:integer, defender_y:integer, weapon?:integer, aggression?:number):ai_result
|
||||
function ai.attack(attacker, defender, weapon, aggression) end
|
||||
|
||||
---Check if attacking a unit is possible
|
||||
---@param attacker unit
|
||||
---@param defender unit
|
||||
---@param attacker location
|
||||
---@param defender location
|
||||
---@param weapon? integer
|
||||
---@param aggression? number
|
||||
---@return ai_result
|
||||
---@overload fun(attacker:location, defender_x:integer, defender_y:integer, weapon?:integer, aggression?:number):ai_result
|
||||
---@overload fun(attacker_x:integer, attacker_y:integer, defender:location, weapon?:integer, aggression?:number):ai_result
|
||||
---@overload fun(attacker_x:integer, attacker_y:integer, defender_x:integer, defender_y:integer, weapon?:integer, aggression?:number):ai_result
|
||||
function ai.check_attack(attacker, defender, weapon, aggression) end
|
||||
|
||||
---Move a unit
|
||||
---@param unit unit
|
||||
---@param unit location
|
||||
---@param to location
|
||||
---@return ai_result
|
||||
---@overload fun(unit:unit, to_x:integer, to_y:integer):ai_result
|
||||
---@overload fun(unit_x:integer, unit_y:integer, to:location):ai_result
|
||||
---@overload fun(unit_x:integer, unit_y:integer, to_x:integer, to_y:integer):ai_result
|
||||
function ai.move(unit, to) end
|
||||
|
||||
---Move a unit and set its remaining moves to 0
|
||||
---@param unit unit
|
||||
---@param to location
|
||||
---@return ai_result
|
||||
---@overload fun(unit:unit, to_x:integer, to_y:integer):ai_result
|
||||
---@overload fun(unit_x:integer, unit_y:integer, to:location):ai_result
|
||||
---@overload fun(unit_x:integer, unit_y:integer, to_x:integer, to_y:integer):ai_result
|
||||
function ai.move_full(unit, to) end
|
||||
|
||||
---Check if moving a unit is possible
|
||||
---@param unit unit
|
||||
---@param to location
|
||||
---@return ai_result
|
||||
---@overload fun(unit:unit, to_x:integer, to_y:integer):ai_result
|
||||
---@overload fun(unit_x:integer, unit_y:integer, to:location):ai_result
|
||||
---@overload fun(unit_x:integer, unit_y:integer, to_x:integer, to_y:integer):ai_result
|
||||
function ai.check_move(unit, to) end
|
||||
|
||||
---Recall a unit
|
||||
---@param unit_id string
|
||||
---@param at? location
|
||||
---@return ai_result
|
||||
---@overload fun(unit_id:string, x:integer, y:integer):ai_result
|
||||
function ai.recall(unit_id, at) end
|
||||
|
||||
---Check if recalling a unit is possible
|
||||
---@param unit_id string
|
||||
---@param at? location
|
||||
---@return ai_result
|
||||
---@overload fun(unit_id:string, x:integer, y:integer):ai_result
|
||||
function ai.check_recall(unit_id, at) end
|
||||
|
||||
---Recruit a unit
|
||||
---@param unit_type string
|
||||
---@param at? location
|
||||
---@return ai_result
|
||||
---@overload fun(unit_type:string, x:integer, y:integer):ai_result
|
||||
function ai.recruit(unit_type, at) end
|
||||
|
||||
---Check if recruiting a unit is possible
|
||||
---@param unit_type string
|
||||
---@param at? location
|
||||
---@return ai_result
|
||||
---@overload fun(unit_type:string, x:integer, y:integer):ai_result
|
||||
function ai.check_recruit(unit_type, at) end
|
||||
|
||||
---Set a unit's attacks left to 0
|
||||
---@param unit unit
|
||||
---@param unit location
|
||||
---@return ai_result
|
||||
---@overload fun(unit_x:integer, unit_y:integer):ai_result
|
||||
function ai.stopunit_attacks(unit) end
|
||||
|
||||
---Set a unit's remaining moves to 0
|
||||
---@param unit unit
|
||||
---@param unit location
|
||||
---@return ai_result
|
||||
---@overload fun(unit_x:integer, unit_y:integer):ai_result
|
||||
function ai.stopunit_moves(unit) end
|
||||
|
||||
---Set a unit's remaining moves and attacks left to 0
|
||||
---@param unit unit
|
||||
---@param unit location
|
||||
---@return ai_result
|
||||
---@overload fun(unit_x:integer, unit_y:integer):ai_result
|
||||
function ai.stopunit_all(unit) end
|
||||
|
||||
---Check if setting a units remaining moves and/or attacks left to 0 is possible
|
||||
---@param unit unit
|
||||
---@param unit location
|
||||
---@return ai_result
|
||||
---@overload fun(unit_x:integer, unit_y:integer):ai_result
|
||||
function ai.check_stopunit(unit) end
|
||||
|
||||
---Give control to a human player for the rest of the turn
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
-- that exist in Wesnoth.
|
||||
|
||||
std_print = print
|
||||
wesnoth.require = require
|
||||
os = {}
|
||||
debug = {}
|
||||
|
||||
|
|
|
@ -9,8 +9,9 @@ function filesystem.read_file(path) end
|
|||
|
||||
---Check if a file exists
|
||||
---@param path string
|
||||
---@param real_file? boolean If true, the file must be a real file and not for example a directory.
|
||||
---@return boolean
|
||||
function filesystem.have_file(path) end
|
||||
function filesystem.have_file(path, real_file) end
|
||||
|
||||
---Resolve a file path relative to the current script
|
||||
---@param path string
|
||||
|
|
|
@ -60,8 +60,8 @@ function gui.show_popup(title, message, image) end
|
|||
---| "'yes_no'" #Two buttons labelled Yes and No
|
||||
---@param title tstring A title string for the dialog
|
||||
---@param message tstring The message to show
|
||||
---@param button string|gui_prompt_button_type The button label
|
||||
---@param markup boolean Whether to parse Pango markup
|
||||
---@param button? string|gui_prompt_button_type The button label
|
||||
---@param markup? boolean Whether to parse Pango markup
|
||||
---@return boolean #false if No or Cancel was clicked, otherwise true
|
||||
function gui.show_prompt(title, message, button, markup) end
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ string.join_map = stringx.join_map
|
|||
|
||||
---Substitute variables into a format string
|
||||
---@param format string|tstring
|
||||
---@param values table<string, string|tstring>
|
||||
---@param values table<string, string|tstring|number>
|
||||
---@return string|tstring
|
||||
function stringx.vformat(format, values) end
|
||||
string.vformat = stringx.vformat
|
||||
|
|
|
@ -21,7 +21,7 @@ tstring.vformat = stringx.vformat
|
|||
function wesnoth.textdomain(domain) end
|
||||
|
||||
---Logs a message to the console
|
||||
---@param logger "'info'"|"'debug'"|"'warning'"|"'error'"|"'wml'"
|
||||
---@param logger "'info'"|"'debug'"|"'dbg'"|"'warning'"|"'warn'"|"'wrn'"|"'error'"|"'err'"|"'wml'"
|
||||
---@param message string
|
||||
---@param in_chat? boolean
|
||||
---@overload fun(message:string, in_chat?:boolean)
|
||||
|
@ -36,6 +36,9 @@ function wesnoth.log(logger, message, in_chat) end
|
|||
---@return stats_evaluation defender_stats
|
||||
---@return weapon_evaluation attacker_weapon
|
||||
---@return weapon_evaluation defender_weapon
|
||||
---@overload fun(attacker:unit, defender:unit):stats_evaluation,stats_evaluation,weapon_evaluation,weapon_evaluation
|
||||
---@overload fun(attacker:unit, attacker_weapon:integer, defender:unit):stats_evaluation,stats_evaluation,weapon_evaluation,weapon_evaluation
|
||||
---@overload fun(attacker:unit, defender:unit, defender_weapon:integer):stats_evaluation,stats_evaluation,weapon_evaluation,weapon_evaluation
|
||||
function wesnoth.simulate_combat(attacker, attacker_weapon, defender, defender_weapon) end
|
||||
|
||||
---@class stats_evaluation
|
||||
|
@ -212,6 +215,7 @@ wesnoth.races = {}
|
|||
---@field turns integer
|
||||
---@field next string|nil
|
||||
---@field id string
|
||||
---@field name tstring
|
||||
---@field defeat_music string[]
|
||||
---@field victory_music string[]
|
||||
---@field show_credits boolean
|
||||
|
|
|
@ -6,7 +6,7 @@ wesnoth.audio = {}
|
|||
|
||||
---Play a sound
|
||||
---@param sound string
|
||||
---@param repeats integer
|
||||
---@param repeats? integer
|
||||
function wesnoth.audio.play(sound, repeats) end
|
||||
|
||||
---@class music_track
|
||||
|
@ -17,12 +17,12 @@ function wesnoth.audio.play(sound, repeats) end
|
|||
---@field title tstring
|
||||
---@field __cfg WMLTable
|
||||
|
||||
---@class wesnoth.audio.music_list
|
||||
---@class wesnoth.audio.music_list : music_track[]
|
||||
---@field current music_track
|
||||
---@field current_i integer|nil
|
||||
---@field previous music_track
|
||||
---@field volume number
|
||||
---@field all WMLTable[]
|
||||
---@type music_track[]
|
||||
wesnoth.audio.music_list = {}
|
||||
|
||||
---Add a new track to the player_list
|
||||
|
|
|
@ -67,18 +67,26 @@ function wesnoth.game_events.add_wml(event) end
|
|||
|
||||
---Fire an event by name
|
||||
---@param name string The event to fire
|
||||
---@param first? location|unit The primary location or unit of the event
|
||||
---@param second? location|unit The secondary location or unit of the event
|
||||
---@param first? location The primary location or unit of the event
|
||||
---@param second? location The secondary location or unit of the event
|
||||
---@param data? WMLTable Additional data to pass to the event
|
||||
---@return boolean #Indicates whether the event was handled or not
|
||||
---@overload fun(name:string, x1:integer, y1:integer, data?:WMLTable):boolean
|
||||
---@overload fun(name:string, x1:integer, y1:integer, x2:integer, y2:integer, data?:WMLTable):boolean
|
||||
---@overload fun(name:string, first:location, x2:integer, y2:integer, data?:WMLTable):boolean
|
||||
---@overload fun(name:string, x1:integer, y1:integer, second:location, data?:WMLTable):boolean
|
||||
function wesnoth.game_events.fire(name, first, second, data) end
|
||||
|
||||
---Fire an event by ID
|
||||
---@param id string The event to fire
|
||||
---@param first? location|unit The primary location or unit of the event
|
||||
---@param second? location|unit The secondary location or unit of the event
|
||||
---@param first? location The primary location or unit of the event
|
||||
---@param second? location The secondary location or unit of the event
|
||||
---@param data? WMLTable Additional data to pass to the event
|
||||
---@return boolean #Indicates whether the event was handled or not
|
||||
---@overload fun(id:string, x1:integer, y1:integer, data?:WMLTable):boolean
|
||||
---@overload fun(id:string, x1:integer, y1:integer, x2:integer, y2:integer, data?:WMLTable):boolean
|
||||
---@overload fun(id:string, first:location, x2:integer, y2:integer, data?:WMLTable):boolean
|
||||
---@overload fun(id:string, x1:integer, y1:integer, second:location, data?:WMLTable):boolean
|
||||
function wesnoth.game_events.fire_by_id(id, first, second, data) end
|
||||
|
||||
---Remove an event handler by ID
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
---Freeze the game for a specified time
|
||||
---@param ms number
|
||||
function wesnoth.interface.delay(ms) end
|
||||
---@param accel? boolean Whether to apply the current acceleration factor
|
||||
function wesnoth.interface.delay(ms, accel) end
|
||||
|
||||
---Deselect the active hex, if any
|
||||
function wesnoth.interface.deselect_hex() end
|
||||
|
@ -15,8 +16,10 @@ function wesnoth.interface.highlight_hex(loc) end
|
|||
---Animate a floating label on a hex
|
||||
---@param loc location
|
||||
---@param text tstring
|
||||
---@param color? color|string
|
||||
---@overload fun(x:integer, y:integer, text:tstring)
|
||||
function wesnoth.interface.float_label(loc, text) end
|
||||
---@overload fun(x:integer, y:integer, text:tstring, color:color|string)
|
||||
function wesnoth.interface.float_label(loc, text, color) end
|
||||
|
||||
---Get the currently-selected unit, the one displayed in the sidebar
|
||||
---@return unit
|
||||
|
@ -63,7 +66,7 @@ function wesnoth.interface.scroll(dx, dy) end
|
|||
function wesnoth.interface.zoom(factor, relative) end
|
||||
|
||||
---Set the skip messages flag
|
||||
---@param skip boolean
|
||||
---@param skip? boolean
|
||||
function wesnoth.interface.skip_messages(skip) end
|
||||
|
||||
---Check if messages are being skipped
|
||||
|
@ -71,8 +74,9 @@ function wesnoth.interface.skip_messages(skip) end
|
|||
function wesnoth.interface.is_skipping_messages() end
|
||||
|
||||
---Add a message to the onscreen chat
|
||||
---@param speaker? string
|
||||
---@param speaker string
|
||||
---@param message string
|
||||
---@overload fun(message:string)
|
||||
function wesnoth.interface.add_chat_message(speaker, message) end
|
||||
|
||||
---Clear all messages in the onscreen chat
|
||||
|
|
|
@ -34,7 +34,7 @@ wesnoth.map = {}
|
|||
--- will first attempt to replace just the base or just the overlay, and if that produces an
|
||||
--- invalid combination, will instead replace both.
|
||||
---@param terrain string
|
||||
---@param mode 'base'|'overlay'
|
||||
---@param mode 'base'|'overlay'|'both'
|
||||
---@return string
|
||||
function wesnoth.map.replace_if_failed(terrain, mode) end
|
||||
|
||||
|
@ -55,7 +55,7 @@ function wesnoth.map.find_in_radius(map, center, radius, filter) end
|
|||
|
||||
---Parse a mapgen location filter
|
||||
---@param filter terrain_filter_tag
|
||||
---@param data table<string, location[]>
|
||||
---@param data? table<string, location[]>
|
||||
---@return terrain_filter
|
||||
function wesnoth.map.filter(filter, data) end
|
||||
|
||||
|
@ -142,12 +142,15 @@ function wesnoth.map.remove_label(location) end
|
|||
---Get the label on the given hex, if any
|
||||
---@param location location
|
||||
---@param side integer
|
||||
---@return label_info|nil
|
||||
---@return label_info?
|
||||
---@overload fun(x:integer, y:integer, side:integer):label_info?
|
||||
function wesnoth.map.get_label(location, side) end
|
||||
|
||||
---Place a new time area on the map
|
||||
---@param id string
|
||||
---@param filter WML
|
||||
function wesnoth.map.place_area(filter) end
|
||||
---@param schedule WML
|
||||
function wesnoth.map.place_area(id, filter, schedule) end
|
||||
|
||||
---Remove a time area from the map
|
||||
---@param id string
|
||||
|
@ -162,11 +165,13 @@ function wesnoth.map.get_area(area) end
|
|||
---Set the owner of a village hex
|
||||
---@param loc location
|
||||
---@param side integer
|
||||
---@overload fun(x:integer, y:integer, side:integer)
|
||||
function wesnoth.map.set_owner(loc, side) end
|
||||
|
||||
---Get the owner of a village hex
|
||||
---@param loc location
|
||||
---@return integer
|
||||
---@overload fun(x:integer, y:integer):integer
|
||||
function wesnoth.map.get_owner(loc) end
|
||||
|
||||
---Create a new game map
|
||||
|
@ -219,6 +224,7 @@ function wesnoth.map.generate(width, height, options) end
|
|||
---@param steps? integer
|
||||
---@return location
|
||||
---@overload fun(from_x:integer, from_y:integer, dir:direction):location
|
||||
---@overload fun(from_x:integer, from_y:integer, dir:direction, steps:integer):location
|
||||
function wesnoth.map.get_direction(from, dir, steps) end
|
||||
|
||||
---Get the direction you need to travel to get from one hex to another
|
||||
|
@ -240,6 +246,7 @@ function wesnoth.map.rotate_right_around_center(loc, center, angle) end
|
|||
---Get a list of all potential adjacent hexes, including off-map locations
|
||||
---@param loc location
|
||||
---@return location n, location ne, location se, location s, location sw, location nw
|
||||
---@overload fun(x:integer, y:integer):location,location,location,location,location,location
|
||||
function wesnoth.map.get_adjacent_hexes(loc) end
|
||||
|
||||
---Get a list of all potential hexes within a given radius, including off-map locations
|
||||
|
@ -258,4 +265,7 @@ function wesnoth.map.are_hexes_adjacent(loc1, loc2) end
|
|||
---@param loc1 location
|
||||
---@param loc2 location
|
||||
---@return integer
|
||||
---@overload fun(x1:integer, y1:integer, loc2:location):integer
|
||||
---@overload fun(loc1:location, x2:integer, y2:integer):integer
|
||||
---@overload fun(x1:integer, y1:integer, x2:integer, y2:integer):integer``
|
||||
function wesnoth.map.distance_between(loc1, loc2) end
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
wesnoth.paths = {}
|
||||
|
||||
---@alias path_function fun(x:integer, y:integer, cost:integer):integer
|
||||
|
||||
---@class path_options
|
||||
---@field max_cost integer
|
||||
---@field ignore_units boolean
|
||||
|
@ -10,7 +12,7 @@ wesnoth.paths = {}
|
|||
---@field width integer
|
||||
---@field height integer
|
||||
---@field include_borders boolean
|
||||
---@field calculate fun(x:integer, y:integer, cost:integer):integer
|
||||
---@field calculate path_function
|
||||
|
||||
---Find a good path between two hexes
|
||||
---@param start location
|
||||
|
@ -21,14 +23,18 @@ wesnoth.paths = {}
|
|||
---@overload fun(x1:integer, y1:integer, finish:location, options:path_options):location[],integer
|
||||
---@overload fun(start:location, x2:integer, y2:integer, options:path_options):location[],integer
|
||||
---@overload fun(x1:integer, y1:integer, x2:integer, y2:integer, options:path_options):location[],integer
|
||||
---@overload fun(start:location, finish:location, calc:path_function):location[],integer
|
||||
---@overload fun(x1:integer, y1:integer, finish:location, calc:path_function):location[],integer
|
||||
---@overload fun(start:location, x2:integer, y2:integer, calc:path_function):location[],integer
|
||||
---@overload fun(x1:integer, y1:integer, x2:integer, y2:integer, calc:path_function):location[],integer
|
||||
function wesnoth.paths.find_path(start, finish, options) end
|
||||
|
||||
---Find a vacant hex as close as possible
|
||||
---@param x integer
|
||||
---@param y integer
|
||||
---@param unit unit
|
||||
---@param loc location
|
||||
---@param unit? unit
|
||||
---@return integer x, integer y
|
||||
function wesnoth.paths.find_vacant_hex(x, y, unit) end
|
||||
---@overload fun(x:integer, y:integer, unit:unit):integer,integer
|
||||
function wesnoth.paths.find_vacant_hex(loc, unit) end
|
||||
|
||||
---@class reach_options
|
||||
---@field additional_turns integer
|
||||
|
@ -38,7 +44,7 @@ function wesnoth.paths.find_vacant_hex(x, y, unit) end
|
|||
|
||||
---Get all locations a unit can reach
|
||||
---@param unit unit
|
||||
---@param options reach_options
|
||||
---@param options? reach_options
|
||||
---@return location[]
|
||||
function wesnoth.paths.find_reach(unit, options) end
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
---@param ref location|string|nil
|
||||
---@param turn? integer
|
||||
---@return time_info
|
||||
---@overload fun(x:integer, y:integer)
|
||||
---@overload fun(x:integer, y:integer, turn:integer)
|
||||
function wesnoth.schedule.get_time_of_day(ref, turn) end
|
||||
|
||||
---Get the time of day on the given hex, accounting for illumination
|
||||
|
|
|
@ -108,6 +108,7 @@ function wesnoth.sides.is_shrouded(side, location) end
|
|||
---Replace the AI for the given side
|
||||
---@param side integer|side
|
||||
---@param file string
|
||||
---@overload fun(side:integer|side, ai_cfg:WML)
|
||||
function wesnoth.sides.switch_ai(side, file) end
|
||||
|
||||
---Add AI parameters for the given side
|
||||
|
@ -130,8 +131,7 @@ function wesnoth.sides.change_ai_component(side, path, component) end
|
|||
---Remove a component from the given side's AI
|
||||
---@param side integer|side
|
||||
---@param path string
|
||||
---@param component WML
|
||||
function wesnoth.sides.delete_ai_component(side, path, component) end
|
||||
function wesnoth.sides.delete_ai_component(side, path) end
|
||||
|
||||
---Get a specific side
|
||||
---@param number integer
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
---@param ai_fcn? fun():WMLTable
|
||||
---@param for_side? integer[]
|
||||
---@return WMLTable
|
||||
---@overload fun(fcn: (fun():WMLTable), ai_fcn?: (fun():WMLTable), for_side?:integer[]):WMLTable
|
||||
function wesnoth.sync.evaluate_single(description, fcn, ai_fcn, for_side) end
|
||||
|
||||
---Evaluate an expression on multiple clients and synchronize the results to all clients
|
||||
|
|
|
@ -136,8 +136,11 @@ function wesnoth.units.matches(unit, filter, context) end
|
|||
---Place or move a unit on the map
|
||||
---@param unit unit
|
||||
---@param loc? location
|
||||
---@param fire_event? boolean
|
||||
---@overload fun(unit:unit, x:integer, y:integer)
|
||||
function wesnoth.units.to_map(unit, loc) end
|
||||
---@overload fun(unit:unit, x:integer, y:integer, fire_event:boolean)
|
||||
---@overload fun(unit:unit, fire_event:boolean)
|
||||
function wesnoth.units.to_map(unit, loc, fire_event) end
|
||||
|
||||
---Place a unit on a recall lists
|
||||
---@param unit unit
|
||||
|
@ -152,7 +155,10 @@ function wesnoth.units.transform(unit, to_type, to_variation) end
|
|||
|
||||
---Select the unit, as if it had been clicked with the mouse
|
||||
---@param unit unit
|
||||
function wesnoth.units.select(unit) end
|
||||
---@param highlight? boolean
|
||||
---@param fire_event? boolean
|
||||
---@overload fun(unit_x:integer, unit_y:integer, highlight?:boolean, fire_event?:boolean)
|
||||
function wesnoth.units.select(unit, highlight, fire_event) end
|
||||
|
||||
---Test if the unit is affected by an ability
|
||||
---@param unit unit
|
||||
|
@ -275,5 +281,7 @@ function wesnoth.units.create_weapon(cfg) end
|
|||
---@param ignore_passability boolean
|
||||
---@param clear_shroud boolean
|
||||
---@param animate boolean
|
||||
---@overload fun(unit:unit, x:integer, y:integer, ignore_passability:boolean, clear_shroud:boolean, animate:boolean)
|
||||
function wesnoth.units.teleport(unit, target, ignore_passability, clear_shroud, animate) end
|
||||
|
||||
wesnoth.units.get_hovered = wesnoth.interface.get_displayed_unit
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
---@meta
|
||||
|
||||
---@alias WMLValue number | boolean | string | tstring
|
||||
|
||||
---A WML table is a table consisting of an array part and string keys.
|
||||
---
|
||||
---String key values can be any of number | boolean | string | (string|boolean|number)[]
|
||||
---
|
||||
---Array values are of type WMLTag
|
||||
---@class WMLTable
|
||||
---@class WMLTable : { [string]: WMLValue | WMLValue[], [integer]: WMLTag }
|
||||
---A read-only WML table that auto-substitutes WML variables when read.
|
||||
---@class vconfig
|
||||
---@field __literal WMLTable
|
||||
|
@ -98,6 +100,11 @@ function wml.interpolate(vcfg, vars) end
|
|||
---@return vconfig
|
||||
function wml.tovconfig(cfg) end
|
||||
|
||||
---Evaluates a table of ConditionalWML
|
||||
---@param cfg WML
|
||||
---@return boolean
|
||||
function wml.eval_conditional(cfg) end
|
||||
|
||||
---@deprecated
|
||||
---@return WMLTable
|
||||
function wml.get_all_vars() end
|
||||
|
|
Loading…
Add table
Reference in a new issue