summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2017-01-25 12:58:49 -0600
committercheapie <no-email-for-you@example.com>2017-01-25 12:58:49 -0600
commit526521e7a6f9e0425adee90641ef85e32560ac8c (patch)
treeeb33c9f4de18b5180e069e349b82b487447b014b
parent9dace1bb719b65052205887d8e10a506aed9dcc4 (diff)
downloadplasticbox-526521e7a6f9e0425adee90641ef85e32560ac8c.tar
plasticbox-526521e7a6f9e0425adee90641ef85e32560ac8c.tar.gz
plasticbox-526521e7a6f9e0425adee90641ef85e32560ac8c.tar.bz2
plasticbox-526521e7a6f9e0425adee90641ef85e32560ac8c.tar.xz
plasticbox-526521e7a6f9e0425adee90641ef85e32560ac8c.zip
Use unifieddyes' version of some functions
-rw-r--r--depends.txt1
-rw-r--r--init.lua110
-rw-r--r--textures/plasticbox_ud_palette.pngbin443 -> 0 bytes
3 files changed, 4 insertions, 107 deletions
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 1d7c485..0000000
--- a/textures/plasticbox_ud_palette.png
+++ /dev/null
Binary files differ