From 2c9c2f9bf94d55f4016d93e5dd0935bcf0d27151 Mon Sep 17 00:00:00 2001 From: Elkien3 Date: Wed, 18 Oct 2017 11:49:20 -0500 Subject: [PATCH] Add longer commands to marker now you can use mrkr/clrmrkr as well as marker/clearmarker. --- mods/marker/init.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/mods/marker/init.lua b/mods/marker/init.lua index 1bdbe0a..9c4502d 100644 --- a/mods/marker/init.lua +++ b/mods/marker/init.lua @@ -21,6 +21,28 @@ minetest.register_chatcommand("mrkr", { }) end }) +minetest.register_chatcommand("marker", { + params = "[], [], []", + description = "Adds a waypoint marker at the selected position.", + privs = {}, + func = function(name, param) + local x, y, z = string.match(param, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$") + local player = minetest.get_player_by_name(name) + if not z then + minetest.chat_send_player(name, "You must have 3 coordinates!") + return + end + if marker[name] then + player:hud_remove(marker[name]) + end + marker[name] = player:hud_add({ + hud_elem_type = "waypoint", + name = x..", "..y..", "..z, + number = 0xFF0000, + world_pos = {x=x, y=y, z=z} + }) + end +}) minetest.register_chatcommand("clrmrkr", { params = "", description = "Removes the marker waypoint.", @@ -33,4 +55,17 @@ minetest.register_chatcommand("clrmrkr", { end end end +}) +minetest.register_chatcommand("clearmarker", { + params = "", + description = "Removes the marker waypoint.", + privs = {}, + func = function(name) + local player = minetest.get_player_by_name(name) + if marker[name] then + if player:hud_remove(marker[name]) then + marker[name] = nil + end + end + end }) \ No newline at end of file