diff --git a/README.md b/README.md index 69fb6a9..ea59679 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,17 @@ Related issues: * https://forum.minetest.net/viewtopic.php?p=296543#p296543 Supported chatcommands: -* pos1 -* pos2 -* set (without //y) +* /pos1 +* /pos2 +* /p +* /set (without /y confirmation) Ignored chatcommands: -* fixlight +* /fixlight TODO: -* Make it also work on command confirmation (//y) +* Make it also work on command confirmation (/y) * Implement more commands * Add mod load time info * Add settingtypes.txt for the settings diff --git a/init.lua b/init.lua index 89f46da..2c7c7e6 100644 --- a/init.lua +++ b/init.lua @@ -55,6 +55,7 @@ end local journal = {} local function add_to_history(data, name) name = name or command_invoker + assert(name, "Player name isn't known") journal[name] = journal[name] or { ring = {}, start = 0, @@ -243,6 +244,28 @@ override_chatcommand("/pos2", end ) +-- Punch before the /p command's punch +table.insert(minetest.registered_on_punchnodes, 1, function(_,_, player) + local name = player:get_player_name() + local typ = worldedit.set_pos[name] + if typ == "pos1" + or typ == "pos1only" then + add_to_history({ + type = "marker", + mem_use = 9 * 7, + id = 1, + pos = worldedit.pos1[name] + }, name) + elseif typ == "pos2" then + add_to_history({ + type = "marker", + mem_use = 9 * 7, + id = 2, + pos = worldedit.pos2[name] + }, name) + end +end) + undo_funcs.marker = function(name, data) local pos = data.pos local i = "pos" .. data.id