mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-26 17:12:59 +00:00
sorted init and added handle_fn_result
This commit is contained in:
parent
0ffdb47b54
commit
ae5d18248f
2 changed files with 28 additions and 2 deletions
25
worldeditadditions_core/utils/format/handle_fn_result.lua
Normal file
25
worldeditadditions_core/utils/format/handle_fn_result.lua
Normal 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
|
|
@ -3,11 +3,12 @@ local wea_c = worldeditadditions_core
|
|||
|
||||
wea_c.format = {
|
||||
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_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"),
|
||||
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")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue