sorted init and added handle_fn_result

This commit is contained in:
VorTechnix 2024-10-17 08:49:14 -07:00
parent 0ffdb47b54
commit ae5d18248f
No known key found for this signature in database
GPG key ID: 091E91A69545D5BA
2 changed files with 28 additions and 2 deletions

View file

@ -0,0 +1,25 @@
---
-- @module worldeditadditions_core
local wea_c = worldeditadditions_core
--- Handles the result of a function call.
--- @param ... any The full output of the function call.
local function handle_fn_result(...)
local result = { ... }
local ret = ""
local success = table.remove(result, 1)
if #result > 1 then
ret = wea_c.table.tostring(result)
elseif #result == 1 then
ret = tostring(result[1])
else
ret = table.concat({
"Function returned \"",
tostring(success),
"\" with no other output."
}, " ")
end
return success, ret
end
return handle_fn_result

View file

@ -3,11 +3,12 @@ local wea_c = worldeditadditions_core
wea_c.format = { wea_c.format = {
array_2d = dofile(wea_c.modpath.."/utils/format/array_2d.lua"), array_2d = dofile(wea_c.modpath.."/utils/format/array_2d.lua"),
escape = dofile(wea_c.modpath.."/utils/format/escape.lua"),
handle_fn_result = dofile(wea_c.modpath.."/utils/format/handle_fn_result.lua"),
human_size = dofile(wea_c.modpath.."/utils/format/human_size.lua"), human_size = dofile(wea_c.modpath.."/utils/format/human_size.lua"),
human_time = dofile(wea_c.modpath.."/utils/format/human_time.lua"), human_time = dofile(wea_c.modpath.."/utils/format/human_time.lua"),
node_distribution = dofile(wea_c.modpath.."/utils/format/node_distribution.lua"),
make_ascii_table = dofile(wea_c.modpath.."/utils/format/make_ascii_table.lua"), make_ascii_table = dofile(wea_c.modpath.."/utils/format/make_ascii_table.lua"),
map = dofile(wea_c.modpath.."/utils/format/map.lua"), map = dofile(wea_c.modpath.."/utils/format/map.lua"),
escape = dofile(wea_c.modpath.."/utils/format/escape.lua") node_distribution = dofile(wea_c.modpath.."/utils/format/node_distribution.lua")
} }