diff options
author | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2018-08-28 22:39:09 -0400 |
---|---|---|
committer | Vanessa Dannenberg <vanessa.e.dannenberg@gmail.com> | 2018-08-28 22:44:02 -0400 |
commit | c3036aba004bc35b4d8ba91ed07864de2a058326 (patch) | |
tree | d1b6e1abd1ff66a08a4c82a4b5f815f9c227ab11 /init.lua | |
parent | d53fb146dd9ba5bc126e326de2e3c1327f70623f (diff) | |
download | unifieddyes-c3036aba004bc35b4d8ba91ed07864de2a058326.tar unifieddyes-c3036aba004bc35b4d8ba91ed07864de2a058326.tar.gz unifieddyes-c3036aba004bc35b4d8ba91ed07864de2a058326.tar.bz2 unifieddyes-c3036aba004bc35b4d8ba91ed07864de2a058326.tar.xz unifieddyes-c3036aba004bc35b4d8ba91ed07864de2a058326.zip |
handle special case of split palette with full colors in node name
also check for ud_param2_colorable before proceeding to airbrush
also handle new -> old color names in split palette switching
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -665,7 +665,7 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing) return end - if not def.palette then + if not def.palette or not (def.groups and def.groups.ud_param2_colorable > 0) then minetest.chat_send_player(player_name, "*** That node can't be colored.") return end @@ -699,29 +699,41 @@ function unifieddyes.on_airbrush(itemstack, player, pointed_thing) end local oldidx = node.param2 - fdir - local name = def.airbrush_replacement_node or node.name if palette == true then - local s = string.sub(def.palette, 21) - local oldcolor = string.sub(s, 1, string.find(s, "s.png")-1) - local modname = string.sub(name, 1, string.find(name, ":")-1) local nodename2 = string.sub(name, string.find(name, ":")+1) + local oldcolor = "snozzberry" + local newcolor = "razzberry" -- intentionally misspelled ;-) + + if def.ud_color_start and def.ud_color_end then + oldcolor = string.sub(node.name, def.ud_color_start, def.ud_color_end) + newcolor = string.sub(painting_with, 5) + else + if hue ~= 0 then + newcolor = unifieddyes.HUES[hue] + else + newcolor = "grey" + end - local a,b + local s = string.sub(def.palette, 21) + oldcolor = string.sub(s, 1, string.find(s, "s.png")-1) + end - local newcolor = "grey" - if hue ~= 0 then - newcolor = unifieddyes.HUES[hue] + if newcolor == "spring" then newcolor = "aqua" + elseif newcolor == "azure" then newcolor = "skyblue" + elseif newcolor == "rose" then newcolor = "redviolet" end - local a,b = string.gsub(nodename2, oldcolor, newcolor) - name = modname..":"..a + name = modname..":"..string.gsub(nodename2, oldcolor, newcolor) + if not minetest.registered_items[name] then + minetest.chat_send_player(player_name, "*** "..string.sub(painting_with, 5).." can't be applied to that node.") + return + end elseif idx == oldidx then return end - minetest.swap_node(pos, {name = name, param2 = fdir + idx}) if not creative or not creative.is_enabled_for(player_name) then inv:remove_item("main", painting_with) |