Skip to content

Commit

Permalink
sorted init and added handle_fn_result
Browse files Browse the repository at this point in the history
  • Loading branch information
VorTechnix committed Oct 17, 2024
1 parent 0ffdb47 commit ae5d182
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
25 changes: 25 additions & 0 deletions worldeditadditions_core/utils/format/handle_fn_result.lua
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions worldeditadditions_core/utils/format/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit ae5d182

Please sign in to comment.