summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-03-18 15:46:08 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-03-18 15:56:28 -0400
commitdf177c26a75ec1880704b24dafe402cfe91cfe33 (patch)
treed3a46194e4e5d3f1f195303c924eb8dada164729
parentcf186f5f9c829b70ad12a03e58573b7325703503 (diff)
downloadunifieddyes-df177c26a75ec1880704b24dafe402cfe91cfe33.tar
unifieddyes-df177c26a75ec1880704b24dafe402cfe91cfe33.tar.gz
unifieddyes-df177c26a75ec1880704b24dafe402cfe91cfe33.tar.bz2
unifieddyes-df177c26a75ec1880704b24dafe402cfe91cfe33.tar.xz
unifieddyes-df177c26a75ec1880704b24dafe402cfe91cfe33.zip
allow shift-punching on a colorable node, to cancel auto-coloring
also add a message in the chat when auto-color is activated, and with what.
-rw-r--r--init.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index 47faf46..9b85903 100644
--- a/init.lua
+++ b/init.lua
@@ -561,6 +561,7 @@ function unifieddyes.after_dig_node(pos, oldnode, oldmetadata, digger)
end
function unifieddyes.on_use(itemstack, player, pointed_thing)
+ local stackname = itemstack:get_name()
local playername = player:get_player_name()
if pointed_thing and pointed_thing.type == "node" then
@@ -593,6 +594,14 @@ function unifieddyes.on_use(itemstack, player, pointed_thing)
end
end
+ if player:get_player_control().sneak then
+ if unifieddyes.last_used_dye[playername] then
+ minetest.chat_send_player(playername, "Shift-punched a node, switching back to neutral color." )
+ end
+ unifieddyes.last_used_dye[playername] = nil
+ return
+ end
+
-- if the target is unknown, has no groups defined, or isn't UD-colorable, just bail out
if not (nodedef and nodedef.groups and nodedef.groups.ud_param2_colorable) then
minetest.chat_send_player(playername, "That node can't be colored.")
@@ -617,13 +626,15 @@ function unifieddyes.on_use(itemstack, player, pointed_thing)
return
end
- local stackname = itemstack:get_name()
local pos2 = unifieddyes.select_node(pointed_thing)
local paletteidx, hue = unifieddyes.getpaletteidx(stackname, palette_type)
if paletteidx then
- unifieddyes.last_used_dye[playername] = stackname
+ if unifieddyes.last_used_dye[playername] ~= stackname then
+ minetest.chat_send_player(playername, "Color "..stackname.." selected, auto-coloring activated." )
+ unifieddyes.last_used_dye[playername] = stackname
+ end
local meta = minetest.get_meta(pos)
local prevdye = meta:get_string("dye")