From 526521e7a6f9e0425adee90641ef85e32560ac8c Mon Sep 17 00:00:00 2001 From: cheapie Date: Wed, 25 Jan 2017 12:58:49 -0600 Subject: [PATCH] Use unifieddyes' version of some functions --- depends.txt | 1 + init.lua | 110 +---------------------------- textures/plasticbox_ud_palette.png | Bin 443 -> 0 bytes 3 files changed, 4 insertions(+), 107 deletions(-) delete mode 100644 textures/plasticbox_ud_palette.png diff --git a/depends.txt b/depends.txt index 16a7f0d..7910ab9 100644 --- a/depends.txt +++ b/depends.txt @@ -1,2 +1,3 @@ homedecor moreblocks +unifieddyes diff --git a/init.lua b/init.lua index 34f459f..94be57f 100644 --- a/init.lua +++ b/init.lua @@ -1,77 +1,3 @@ -local function getpaletteidx(color) - local aliases = { - ["pink"] = "light_red", - ["brown"] = "dark_orange", - } - - local grayscale = { - ["white"] = 1, - ["light_grey"] = 2, - ["grey"] = 3, - ["dark_grey"] = 4, - ["black"] = 5, - } - - local hues = { - ["red"] = 1, - ["orange"] = 2, - ["yellow"] = 3, - ["lime"] = 4, - ["green"] = 5, - ["aqua"] = 6, - ["cyan"] = 7, - ["skyblue"] = 8, - ["blue"] = 9, - ["violet"] = 10, - ["magenta"] = 11, - ["redviolet"] = 12, - } - - local shades = { - [""] = 1, - ["s50"] = 2, - ["light"] = 3, - ["medium"] = 4, - ["mediums50"] = 5, - ["dark"] = 6, - ["darks50"] = 7, - } - - if string.sub(color,1,4) == "dye:" then - color = string.sub(color,5,-1) - elseif string.sub(color,1,12) == "unifieddyes:" then - color = string.sub(color,13,-1) - else - return - end - - color = aliases[color] or color - - if grayscale[color] then - return(grayscale[color]) - end - - local shade = "" - if string.sub(color,1,6) == "light_" then - shade = "light" - color = string.sub(color,7,-1) - elseif string.sub(color,1,7) == "medium_" then - shade = "medium" - color = string.sub(color,8,-1) - elseif string.sub(color,1,5) == "dark_" then - shade = "dark" - color = string.sub(color,6,-1) - end - if string.sub(color,-4,-1) == "_s50" then - shade = shade.."s50" - color = string.sub(color,1,-5) - end - - if hues[color] and shades[shade] then - return(hues[color] * 8 + shades[shade]) - end -end - minetest.register_node("plasticbox:plasticbox", { description = "Plastic Box", tiles = {"plasticbox_white.png"}, @@ -79,39 +5,9 @@ minetest.register_node("plasticbox:plasticbox", { groups = {choppy=1, snappy=1, oddly_breakable_by_hand=1}, sounds = default.node_sound_stone_defaults(), paramtype2 = "color", - palette = "plasticbox_ud_palette.png", - on_destruct = function(pos) - local meta = minetest.get_meta(pos) - local prevdye = meta:get_string("dye") - if minetest.registered_items[prevdye] then - minetest.add_item(pos,prevdye) - end - end, - on_rightclick = function(pos,node,player,stack) - local name = player:get_player_name() - if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,{protection_bypass=true}) then - minetest.record_protection_violation(pos,name) - return stack - end - local name = stack:get_name() - local paletteidx = getpaletteidx(name) - if paletteidx then - local meta = minetest.get_meta(pos) - local prevdye = meta:get_string("dye") - if minetest.registered_items[prevdye] then - local inv = player:get_inventory() - if inv:room_for_item("main",prevdye) then - inv:add_item("main",prevdye) - else - minetest.add_item(pos,prevdye) - end - end - meta:set_string("dye",name) - stack:take_item() - node.param2 = paletteidx - minetest.swap_node(pos,node) - end - end, + palette = "unifieddyes_palette.png", + on_destruct = unifieddyes.on_destruct, + on_rightclick = unifieddyes.on_rightclick, }) stairsplus:register_all("plasticbox", "plasticbox", "plasticbox:plasticbox", { diff --git a/textures/plasticbox_ud_palette.png b/textures/plasticbox_ud_palette.png deleted file mode 100644 index 1d7c4854022b1523bcc61792d3bf297591f9fede..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 443 zcmV;s0Yv_ZP)RKoxO010qNS#tmY3ljhU3ljkVnw%H_000McNliru;Q<&2A`bjSN#y_l03B&m zSad^gZEa<4bN~PV002XBWnpw>WFU8GbZ8()Nlj2>E@cM*00AFKL_t(I%k9yzPE=74 z2Hd;|2x%31-p(!^xvJP*jdN1NF}&YP5riy>UzS%aWh_f<2=t*JH)lMK_`@0j^OPfFC%rq)=3eH_0ZW+N3b<#W3QOh zba@&cKTGXU*lb4d3av1e4r+r|jSzQtm{0hW)l}oVVyHxhOF4pOHJ3tdI^k5dRr;zl l#ND(0mc~DF5AMN#fg2UWdV08ik*ELw002ovPDHLkV1lNRvt$4O