From 18155b3ebedd24fba5c3cbf109063f64f882d8a6 Mon Sep 17 00:00:00 2001 From: fluxionary <25628292+fluxionary@users.noreply.github.com> Date: Wed, 25 Jan 2023 23:25:46 -0800 Subject: some more updates (#9) * add proper settings (untested) * more constants -> settings * normalize whitespace between code files * refactor globalsteps in order to simplify logic * minor refactoring * rename file * use mod_storage for persistent data; optimize context initialization * refactoring (moving files around) * rewrite penalty * add settings; document; allow changing while game is running * add command to update settings * update init after splitting commands into files * fix bugs; add debugging tools; too much for one commit... * fix whitelist conversion * add adjustable blinky plant to timer overrides * add some more mesecons nodes with repeating timers * resolve luacheck warnings * tweak hud * Update documentation; parameterize more things; refactor some logic for readability * update lag even when mesecons isn't active * update lag even when mesecons isn't active * tweak default settings * move hud so it doesn't interfere w/ areas * tweak default settings * put the HUD in a place which doesn't conflict w/ areas mod * ensure that actions have a valid position to avoid a crash * stylua * make sure we don't update the wrong HUD * spaces not tabs Co-authored-by: AliasAlreadyTaken --- commands/user_commands.lua | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'commands/user_commands.lua') diff --git a/commands/user_commands.lua b/commands/user_commands.lua index 5836373..b0e3c14 100644 --- a/commands/user_commands.lua +++ b/commands/user_commands.lua @@ -1,3 +1,5 @@ +local f = string.format + minetest.register_chatcommand("mesecons_hud", { description = "mesecons_hud toggle", func = function(name) @@ -8,7 +10,7 @@ minetest.register_chatcommand("mesecons_hud", { else return true, "mesecons hud disabled" end - end + end, }) minetest.register_chatcommand("mesecons_global_stats", { @@ -26,10 +28,8 @@ minetest.register_chatcommand("mesecons_global_stats", { local txt if top_ctx then - txt = ( - "Most prominent mesecons usage at mapblock %s" .. - " with %f seconds penalty and %i us average use" - ):format( + txt = f( + "Most prominent mesecons usage at mapblock %s" .. " with %f seconds penalty and %i us average use", minetest.pos_to_string(minetest.get_position_from_hash(top_hash)), top_ctx.penalty, top_ctx.avg_micros_per_second @@ -39,7 +39,7 @@ minetest.register_chatcommand("mesecons_global_stats", { end return true, txt - end + end, }) minetest.register_chatcommand("mesecons_stats", { @@ -51,10 +51,11 @@ minetest.register_chatcommand("mesecons_stats", { end local ctx = mesecons_debug.get_context(player:get_pos()) - return true, ("Mapblock usage: %i us/s (across %i mapblocks)"):format( - ctx.avg_micros_per_second, - mesecons_debug.context_store_size - ) - end + return true, + f( + "Mapblock usage: %i us/s (across %i mapblocks)", + ctx.avg_micros_per_second, + mesecons_debug.context_store_size + ) + end, }) - -- cgit v1.2.3