Skip to content

Commit

Permalink
Merge pull request #1021 from wesnoth/lua_require
Browse files Browse the repository at this point in the history
Improve the wesnoth.require implementation
  • Loading branch information
CelticMinstrel committed May 4, 2017
2 parents 7139952 + 08b381d commit 787a468
Show file tree
Hide file tree
Showing 111 changed files with 874 additions and 790 deletions.
3 changes: 3 additions & 0 deletions changelog
Expand Up @@ -40,6 +40,9 @@ Version 1.13.7+dev:
* wesnoth.set_music is now deprecated, in favour of the above new API
* New wesnoth.sound_volume function gets/sets the current sound volume, as [volume]sound=
* New wesnoth.show_story function launches the storyscreen viewer
* wesnoth.dofile now forwards any excess arguments to the file in the "..." argument
* wesnoth.require can now load all modules in a directory and accepts some shortened paths,
for example omitting the ".lua" file extension.
* Multiplayer:
* Fixed statistics being lost when reloading an MP game.
* Performance:
Expand Down
4 changes: 2 additions & 2 deletions data/ai/lua/ai_helper.lua
@@ -1,6 +1,6 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local W = H.set_wml_action_metatable {}
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

-- This is a collection of Lua functions used for custom AI development.
-- Note that this is still work in progress with significant changes occurring
Expand Down
4 changes: 2 additions & 2 deletions data/ai/lua/battle_calcs.lua
@@ -1,6 +1,6 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

-- This is a collection of Lua functions used for custom AI development.
-- Note that this is still work in progress with significant changes occurring
Expand Down
4 changes: 2 additions & 2 deletions data/ai/lua/ca_high_xp_attack.lua
@@ -1,6 +1,6 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

-- Evaluation process:
--
Expand Down
4 changes: 2 additions & 2 deletions data/ai/lua/generic_recruit_engine.lua
Expand Up @@ -23,10 +23,10 @@ return {
end
math.randomseed(os.time())

local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local W = H.set_wml_action_metatable {}
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

local function print_time(...)
if turn_start_time then
Expand Down
4 changes: 2 additions & 2 deletions data/ai/lua/generic_rush_engine.lua
Expand Up @@ -6,11 +6,11 @@ return {

-- More generic grunt rush (and can, in fact, be used with other unit types as well)

local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local W = H.set_wml_action_metatable {}
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"
local HS = wesnoth.require "ai/micro_ais/cas/ca_healer_move.lua"
local R = wesnoth.require "ai/lua/retreat.lua"

Expand Down
4 changes: 2 additions & 2 deletions data/ai/lua/retreat.lua
Expand Up @@ -2,10 +2,10 @@
Functions to support the retreat of injured units
]=]

local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

local retreat_functions = {}

Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_assassin_move.lua
@@ -1,6 +1,6 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

local function get_units_target(cfg)
local units = AH.get_units_with_moves {
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_big_animals.lua
@@ -1,6 +1,6 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"

local function get_big_animals(cfg)
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_bottleneck_attack.lua
@@ -1,5 +1,5 @@
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"

local ca_bottleneck_attack = {}

Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_bottleneck_move.lua
@@ -1,5 +1,5 @@
local H = wesnoth.require "lua/helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local H = wesnoth.require "helper"
local LS = wesnoth.require "location_set"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
local MAISD = wesnoth.require "ai/micro_ais/micro_ai_self_data.lua"
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_coward.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local function get_coward(cfg)
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_fast_attack_utils.lua
@@ -1,6 +1,6 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"
local T = H.set_wml_tag_metatable{}

-- Functions to perform fast evaluation of attacks and attack combinations.
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_fast_combat.lua
@@ -1,7 +1,7 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local FAU = wesnoth.require "ai/micro_ais/cas/ca_fast_attack_utils.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

local ca_fast_combat = {}

Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_fast_combat_leader.lua
@@ -1,7 +1,7 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local FAU = wesnoth.require "ai/micro_ais/cas/ca_fast_attack_utils.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

local ca_fast_combat_leader = {}

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_fast_move.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local FAU = wesnoth.require "ai/micro_ais/cas/ca_fast_attack_utils.lua"

Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_forest_animals_move.lua
@@ -1,7 +1,7 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local W = H.set_wml_action_metatable {}
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

local function get_forest_animals(cfg)
-- We want the deer/rabbits to move first, tuskers afterward
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_forest_animals_new_rabbit.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local W = H.set_wml_action_metatable {}
local AH = wesnoth.require "ai/lua/ai_helper.lua"

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_forest_animals_tusker_attack.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local function get_tuskers(cfg)
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_forest_animals_tusklet_move.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local function get_tusklets(cfg)
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_goto.lua
@@ -1,7 +1,7 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
local MAISD = wesnoth.require "ai/micro_ais/micro_ai_self_data.lua"

Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_hang_out.lua
@@ -1,6 +1,6 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
local MAISD = wesnoth.require "ai/micro_ais/micro_ai_self_data.lua"

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_healer_initialize.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"

local ca_healer_initialize = {}

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_healer_may_attack.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"

local ca_healer_may_attack = {}

Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_healer_move.lua
@@ -1,5 +1,5 @@
local H = wesnoth.require "lua/helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local H = wesnoth.require "helper"
local LS = wesnoth.require "location_set"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_herding_attack_close_enemy.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local function get_sheep(cfg)
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_herding_dog_move.lua
@@ -1,6 +1,6 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

local function get_dog(cfg)
local dogs = AH.get_units_with_moves {
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_herding_dog_stopmove.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local function get_dog(cfg)
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_herding_f_herding_area.lua
@@ -1,5 +1,5 @@
local H = wesnoth.require "lua/helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local H = wesnoth.require "helper"
local LS = wesnoth.require "location_set"

return function(cfg)
-- Find the area that the sheep can occupy
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_herding_herd_sheep.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local herding_area = wesnoth.require "ai/micro_ais/cas/ca_herding_f_herding_area.lua"
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_herding_sheep_move.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local herding_area = wesnoth.require "ai/micro_ais/cas/ca_herding_f_herding_area.lua"
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_herding_sheep_runs_dog.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local function get_next_sheep(cfg)
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_herding_sheep_runs_enemy.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local function get_next_sheep_enemies(cfg)
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_hunter.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local W = H.set_wml_action_metatable {}
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_lurkers.lua
@@ -1,6 +1,6 @@
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"

local function get_lurker(cfg)
-- We simply pick the first of the lurkers, they have no strategy
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_messenger_attack.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local messenger_next_waypoint = wesnoth.require "ai/micro_ais/cas/ca_messenger_f_next_waypoint.lua"
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_messenger_escort_move.lua
@@ -1,6 +1,6 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"

local messenger_next_waypoint = wesnoth.require "ai/micro_ais/cas/ca_messenger_f_next_waypoint.lua"
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_messenger_f_next_waypoint.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_messenger_move.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local messenger_next_waypoint = wesnoth.require "ai/micro_ais/cas/ca_messenger_f_next_waypoint.lua"
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_patrol.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_protect_unit_attack.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_protect_unit_finish.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local ca_protect_unit_finish, PU_unit, PU_goal = {}
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_protect_unit_move.lua
@@ -1,5 +1,5 @@
local H = wesnoth.require "lua/helper.lua"
local LS = wesnoth.require "lua/location_set.lua"
local H = wesnoth.require "helper"
local LS = wesnoth.require "location_set"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"

Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_recruit_random.lua
@@ -1,6 +1,6 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require("ai/lua/ai_helper.lua")
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

local recruit_type

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_return_guardian.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local function get_guardian(cfg)
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_simple_attack.lua
@@ -1,7 +1,7 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
local LS = wesnoth.require "lua/location_set.lua"
local LS = wesnoth.require "location_set"

local ca_simple_attack, best_attack = {}

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_stationed_guardian.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local function get_guardian(cfg)
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_swarm_move.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local ca_swarm_move = {}
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_swarm_scatter.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"

local function get_enemies(cfg)
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_wolves_move.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_wolves_multipacks_attack.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
local WMPF = wesnoth.require "ai/micro_ais/cas/ca_wolves_multipacks_functions.lua"
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_wolves_multipacks_functions.lua
@@ -1,4 +1,4 @@
local H = wesnoth.require "lua/helper.lua"
local H = wesnoth.require "helper"
local W = H.set_wml_action_metatable {}
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"

Expand Down

0 comments on commit 787a468

Please sign in to comment.