Support the /p command

This commit is contained in:
Hybrid Dog 2017-11-18 16:02:59 +01:00
parent 517011cf9e
commit 920f60cbf0
2 changed files with 29 additions and 5 deletions

@ -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

@ -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