widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #11396
Re: [Merge] lp:~widelands-dev/widelands/dynamic_tribe_loading into lp:widelands
Diff comments:
> === modified file 'data/tribes/init.lua'
> --- data/tribes/init.lua 2017-02-12 09:10:57 +0000
> +++ data/tribes/init.lua 2017-09-03 11:19:20 +0000
> @@ -11,12 +11,33 @@
> --
> -- Basic load order (first wares, then immovables etc.) is important,
> -- because checks will be made in C++.
> --- Also, enhanced/upgraded units need to come before their basic units.
> --
>
> tribes = wl.Tribes()
> include "scripting/mapobjects.lua"
>
> +-- Load all init.lua files in the given table of directory names
> +function load_directories(directories)
> + -- Helper function to check for file name endings
> + function string.ends(haystack, needle)
> + return needle == '' or string.sub(haystack, -string.len(needle)) == needle
> + end
> +
> + while #directories > 0 do
> + local filepath = directories[1]
> + table.remove(directories, 1)
It should work and is more idiomatic.
> + if path.is_directory(filepath) then
> + for idx, listed_path in ipairs(path.list_directory(filepath)) do
> + if path.is_directory(listed_path) then
> + table.insert(directories, listed_path)
> + elseif string.ends(listed_path , "init.lua") then
> + include(listed_path)
> + end
> + end
> + end
> + end
> +end
> +
> print("┏━ Running Lua for tribes:")
>
> print_loading_message("┗━ took", function()
--
https://code.launchpad.net/~widelands-dev/widelands/dynamic_tribe_loading/+merge/329198
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/dynamic_tribe_loading.
References