diff --git a/README.md b/README.md index b69bc2d..fc679ba 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ `//redo` redo what was just undone
`//show_journal` view what can be undone and redone +The changes of nodes after invoking /set are compressed to improve memory usage. + Related issues: * https://github.com/Uberi/Minetest-WorldEdit/issues/43 * https://forum.minetest.net/viewtopic.php?p=296543#p296543 @@ -23,10 +25,8 @@ Ignored chatcommands: TODO: * simplify mem_usage -* Setting for disabling storing harmless things like pos changes * Add parameters to undo and redo: undo the last n * Allow undoing changes which happened before other changes (considered unsafe) e.g. //undo ~1 to undo the change before the latest one * Implement more commands * Add mod load time info -* Add settingtypes.txt for the settings diff --git a/init.lua b/init.lua index 17718d1..84eeeb7 100644 --- a/init.lua +++ b/init.lua @@ -2,10 +2,13 @@ ----------------- Settings ----------------------------------------------------- -local max_commands = 256 -local min_commands = 3 -local max_memory_usage = 2^25 -- 32 MiB -local remember_innocuous = true +local remember_innocuous = + minetest.settings:get_bool"we_undo.remember_innocuous" ~= false +local max_commands = tonumber( + minetest.settings:get"we_undo.max_commands") or 256 +local min_commands = tonumber(minetest.settings:get"we_undo.min_commands") or 3 +local max_memory_usage = tonumber( + minetest.settings:get"we_undo.max_memory_usage") or 2^25 ----------------- Journal and chatcommands ------------------------------------- diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..0671dde --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,19 @@ +# If set to false, only commands which can harm the map are added to the +# journal. +we_undo.remember_innocuous (remember innocuous changes) bool true + +# This is the maximum amount of commands in the journal of a player. +# The size of the journal is further limited by the memory setting. +we_undo.max_commands (maximum count of commands) int 256 1 + +# This is the minimum amount of commands in the journal of a player. +# The memory limit is ignored up to the last min_commands commands. +# This is because being unable to undo a big mistake is worse than exceeding +# the configured memory limit. +we_undo.min_commands (minimum count of commands) int 3 1 + +# If the size of the journal exceeds this limit, old history is removed. +# Specify the value in bytes, note that it only considers big data, +# approximately. +# default value: 2^25 (32 MiB) +we_undo.max_memory_usage (maximum memory usage) int 33554432 9