From 267349a83045d7cfffb2a6ee22877cf8ffe3328a Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Tue, 27 Oct 2026 09:19:27 -0600 Subject: [PATCH] wip --- common/dump.lua | 38 +++++++++++++++++++++++++++++++++---- mods/jvmi_biomes/init.lua | 5 ----- mods/jvmi_biomes/mapenv.lua | 4 ++-- mods/jvmi_first/init.lua | 9 +-------- mods/jvmi_last/init.lua | 9 +-------- mods/jvmi_nodes/init.lua | 2 -- mods/jvmi_nodes/liquid.lua | 4 ++-- mods/jvmi_nodes/stony.lua | 2 +- mods/jvmi_player/init.lua | 12 ++++-------- 9 files changed, 45 insertions(+), 40 deletions(-) diff --git a/common/dump.lua b/common/dump.lua index fe164b3..3781839 100644 --- a/common/dump.lua +++ b/common/dump.lua @@ -2,9 +2,31 @@ local private = {} -function private.dump(value, depth, indent, seen) - depth = depth or -1 +--[[ + Creates a diagnostic string from a given object. + + This function recursively explores tables trying to show as much detail as possible within the + limits dictated by its arguments. For anything other than a table, it simply uses the results + of calling `tostring` with the object in question. + + The output is pretty printed for ease of reading using a new line for each key/value pair, and + indenting successive layers by four spaces. + + Args: + value:any - the value to be dumped + depth:int - the maximum layers of nested tables to explore (10 by default) + indent:string - the initial indent to use at the first layer + max_keys:int - the maximum number of keys to print for a single table (100 by default) + seen:table[any,true] - a table containing all the values already seen during a single, + recursive print attempt (to avoid cycles or duplication) + + Returns: + a string containing the pretty-printed version of the given object +]]-- +function private.dump(value, depth, indent, max_keys, seen) + depth = depth or 10 indent = indent or "" + max_keys = max_keys or 100 seen = seen or {} if depth == 0 then return "" end @@ -16,9 +38,15 @@ function private.dump(value, depth, indent, seen) if type(value) == "table" then result = result.."{\n" local inner_indent = indent.." " + local key_count = 0 for inner_key, inner_value in pairs(value) do - local inner_text = private.dump(inner_value, depth - 1, inner_indent, seen) + local inner_text = private.dump(inner_value, depth - 1, inner_indent, max_keys, seen) result = result..inner_indent..inner_key.." = "..inner_text.."\n" + key_count = key_count + 1 + if key_count >= max_keys then + result = result..inner_indent.."\n" + break + end end result = result..indent.."}" else @@ -31,4 +59,6 @@ end -- Export ----------------------------------------------------------------------------------------- -return private.dump +return { + dump = private.dump +} diff --git a/mods/jvmi_biomes/init.lua b/mods/jvmi_biomes/init.lua index da47567..12b9a18 100644 --- a/mods/jvmi_biomes/init.lua +++ b/mods/jvmi_biomes/init.lua @@ -7,8 +7,3 @@ local core = _G.core core.clear_registered_biomes() dofile(core.get_modpath("jvmi_biomes").."/definitions.lua") - - --- Script ------------------------------------------------------------------------------------------ - -core.log("info", "jvmi_biomes loaded") diff --git a/mods/jvmi_biomes/mapenv.lua b/mods/jvmi_biomes/mapenv.lua index 01d062a..8028ecf 100644 --- a/mods/jvmi_biomes/mapenv.lua +++ b/mods/jvmi_biomes/mapenv.lua @@ -21,7 +21,7 @@ local private = {} Args: region:Region - the region currently being generated ]]-- -function private.apply(region) +function private.apply_to(region) private.assign_biomes(region) private.fill_surface(region) end @@ -82,5 +82,5 @@ end -- Export ------------------------------------------------------------------------------------------ return { - apply_to = private.apply + apply_to = private.apply_to } diff --git a/mods/jvmi_first/init.lua b/mods/jvmi_first/init.lua index c56a0d1..b29b97b 100644 --- a/mods/jvmi_first/init.lua +++ b/mods/jvmi_first/init.lua @@ -1,8 +1 @@ --- Imports & Exports ------------------------------------------------------------------------------- - -local core = _G.core - - --- Script ------------------------------------------------------------------------------------------ - -core.log("info", "jvmi_first loaded") +-- Do nothing. diff --git a/mods/jvmi_last/init.lua b/mods/jvmi_last/init.lua index 56835f7..0b25308 100644 --- a/mods/jvmi_last/init.lua +++ b/mods/jvmi_last/init.lua @@ -1,8 +1 @@ --- Imports & Exports ------------------------------------------------------------------------------- - -local core = _G.core - - --- Script ------------------------------------------------------------------------------------------ - -core.log("info", "jvmi_last loaded") +-- Do nothing diff --git a/mods/jvmi_nodes/init.lua b/mods/jvmi_nodes/init.lua index 5f97da7..7bac185 100644 --- a/mods/jvmi_nodes/init.lua +++ b/mods/jvmi_nodes/init.lua @@ -9,5 +9,3 @@ local path = core.get_modpath("jvmi_nodes") dofile(path.."/earthy.lua") dofile(path.."/liquid.lua") dofile(path.."/stony.lua") - -core.log("info", "jvmi_nodes loaded") diff --git a/mods/jvmi_nodes/liquid.lua b/mods/jvmi_nodes/liquid.lua index 09a9890..11e3248 100644 --- a/mods/jvmi_nodes/liquid.lua +++ b/mods/jvmi_nodes/liquid.lua @@ -15,7 +15,7 @@ core.register_node("jvmi_nodes:water_flowing", { description = S("Flowing Water"), drawtype = C.DRAW_TYPE.FLOWING_LIQUID, tiles = {{ - name = "jvmi_nodes_water_flowing_animated.png", + name = "jvmi_nodes_water_flowing.png", animation = { type = C.ANIMATION_TYPE.VERTICAL_FRAMES, aspect_w = 16, @@ -49,7 +49,7 @@ core.register_node("jvmi_nodes:water_source", { drawtype = "liquid", waving = C.WAVING.LIQUID_LIKE, tiles = {{ - name = "jvmi_nodes_water_source_animated.png", + name = "jvmi_nodes_water_source.png", animation = { type = "vertical_frames", aspect_w = 16, diff --git a/mods/jvmi_nodes/stony.lua b/mods/jvmi_nodes/stony.lua index 7573dc3..d934b09 100644 --- a/mods/jvmi_nodes/stony.lua +++ b/mods/jvmi_nodes/stony.lua @@ -17,7 +17,7 @@ core.register_node("jvmi_nodes:bedrock", { sounds = { footstep = "jvmi_nodes_stone_footstep" }, tiles = {"jvmi_nodes_bedrock.png"}, }) -core.register_alias("mapgen_bedrock", "jvmi_nodes:stone") +core.register_alias("mapgen_bedrock", "jvmi_nodes:bedrock") core.register_node("jvmi_nodes:stone", { description = S("Stone"), diff --git a/mods/jvmi_player/init.lua b/mods/jvmi_player/init.lua index cc6cebb..faa3d4b 100644 --- a/mods/jvmi_player/init.lua +++ b/mods/jvmi_player/init.lua @@ -54,10 +54,12 @@ end away without finding anything. If this function gets called before the world has finished generating, it will automatically - delay + delay for a bit and try again. After too many delays, it will simply abort the attempt. Args: - - player:ObjectRef - the player to relocate + player:ObjectRef - the player to relocate + delays:int - how many times we've had to defer finding a location (0 by default) + ]]-- function private.set_starting_pos(player_name, delays) delays = delays or 0 @@ -105,7 +107,6 @@ function private.set_starting_pos(player_name, delays) end end - --[[ Set up privledges and settings for a new player. @@ -129,8 +130,3 @@ core.register_on_joinplayer(function(player, last_login) private.setup_player(player) private.set_starting_pos(player:get_player_name()) end) - - --- Script ------------------------------------------------------------------------------------------ - -core.log("info", "jvmi_player loaded")