From 1166ddcbc9c0c78a48f73617987741d502e92fa7 Mon Sep 17 00:00:00 2001 From: cheapie Date: Tue, 29 Dec 2015 16:48:57 -0600 Subject: Use colorization and add more colors --- README | 11 ++++++- init.lua | 54 ++++++++++++++++++++++++++++++--- textures/rgblightstone_black.png | Bin 101 -> 0 bytes textures/rgblightstone_blue.png | Bin 106 -> 0 bytes textures/rgblightstone_brown.png | Bin 108 -> 0 bytes textures/rgblightstone_cyan.png | Bin 105 -> 0 bytes textures/rgblightstone_darkblue.png | Bin 104 -> 0 bytes textures/rgblightstone_darkcyan.png | Bin 108 -> 0 bytes textures/rgblightstone_darkgray.png | Bin 106 -> 0 bytes textures/rgblightstone_darkgreen.png | Bin 108 -> 0 bytes textures/rgblightstone_darkmagenta.png | Bin 108 -> 0 bytes textures/rgblightstone_darkred.png | Bin 110 -> 0 bytes textures/rgblightstone_green.png | Bin 107 -> 0 bytes textures/rgblightstone_magenta.png | Bin 106 -> 0 bytes textures/rgblightstone_red.png | Bin 107 -> 0 bytes textures/rgblightstone_white.png | Bin 98 -> 0 bytes textures/rgblightstone_yellow.png | Bin 104 -> 0 bytes 17 files changed, 59 insertions(+), 6 deletions(-) delete mode 100644 textures/rgblightstone_black.png delete mode 100644 textures/rgblightstone_blue.png delete mode 100644 textures/rgblightstone_brown.png delete mode 100644 textures/rgblightstone_cyan.png delete mode 100644 textures/rgblightstone_darkblue.png delete mode 100644 textures/rgblightstone_darkcyan.png delete mode 100644 textures/rgblightstone_darkgray.png delete mode 100644 textures/rgblightstone_darkgreen.png delete mode 100644 textures/rgblightstone_darkmagenta.png delete mode 100644 textures/rgblightstone_darkred.png delete mode 100644 textures/rgblightstone_green.png delete mode 100644 textures/rgblightstone_magenta.png delete mode 100644 textures/rgblightstone_red.png delete mode 100644 textures/rgblightstone_white.png delete mode 100644 textures/rgblightstone_yellow.png diff --git a/README b/README index 9cb1f1c..50ff001 100644 --- a/README +++ b/README @@ -30,11 +30,20 @@ Grab the one you want from the creative inventory and place it. Survival mode is Colors: +Edit the settings at the top of init.lua to change what colors are available. The 16 colors from 16-color mode are always available. + +16 color mode: off, black, blue, brown, cyan, darkblue, darkcyan, darkgray, darkgreen, darkmagenta, darkred, gray, green, magenta, red, white, yellow +12-bit 4096 color mode: +Any 6-digit hex value where the two digits for each part are the same. For example, "00FF66" and "112233" work, but "5678AC" will not. + +24-bit "True Color" mode: +While the code is present, engine limitations do not allow this many nodes to be registered. If this ever changes, any hex value (such as "237AF0" or "C0FFEE") will work. + Adding more colors: -Provide a texture named "rgblightstone_color.png" (where "color" is the color you want to add) and call rgblightstone.add(color) +Call rgblightstone.add(name,color) - "name" is what digilines message should switch to it, and "color" is a hex color. Group addressing mode: diff --git a/init.lua b/init.lua index 325d029..7a1661d 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,9 @@ rgblightstone = {} -rgblightstone.colors = {"off","black","blue","brown","cyan","darkblue","darkcyan","darkgray","darkgreen","darkmagenta","darkred","gray","green","magenta","red","white","yellow"} +--If neither of the following are on, only the 16 colors listed in the readme will be available +rgblightstone.extracolors = true -- 12-bit 4096 Color Mode +rgblightstone.insanecolors = false -- 24-bit "True Color" Mode (DOES NOT WORK - the engine does not allow this many nodes to be registered. If it ever does, however...) +rgblightstone.colors = {} + function rgblightstone.autofill(pos,player) local meta = minetest.get_meta(pos) if (not meta:get_string("channel")) or meta:get_string("channel")=="" then @@ -24,9 +28,10 @@ function rgblightstone.autofill(pos,player) end end -function rgblightstone.add(name) +function rgblightstone.add(name,color) + table.insert(rgblightstone.colors,name) minetest.register_node("rgblightstone:lightstone_" .. name, { - tiles = name == "off" and {"jeija_lightstone_darkgray_off.png"} or {"rgblightstone_"..name..".png"}, + tiles = name == "off" and {"jeija_lightstone_darkgray_off.png"} or {"rgblightstone_gray.png^[colorize:#"..color.."CC"}, drop = "rgblightstone:lightstone_off", groups = name == "off" and {cracky=2} or {cracky=2,not_in_creative_inventory=1}, description="RGB Lightstone ("..name..")", @@ -52,7 +57,7 @@ function rgblightstone.add(name) if fields.addry then meta:set_string("addry",fields.addry) end end end, - light_source = name~= "off" and default.LIGHT_MAX-2 or 0, + light_source = name ~= "off" and default.LIGHT_MAX-2 or 0, digiline = { receptor = {}, effector = { @@ -80,7 +85,46 @@ function rgblightstone.add(name) } }) end -for _,i in ipairs(rgblightstone.colors) do rgblightstone.add(i) end +rgblightstone.add("off",nil) +rgblightstone.add("red","FF5555") +rgblightstone.add("green","55FF55") +rgblightstone.add("blue","5555FF") +rgblightstone.add("cyan","55FFFF") +rgblightstone.add("magenta","FF55FF") +rgblightstone.add("yellow","FFFF55") +rgblightstone.add("gray","AAAAAA") +rgblightstone.add("darkred","AA0000") +rgblightstone.add("darkgreen","00AA00") +rgblightstone.add("darkblue","0000AA") +rgblightstone.add("darkcyan","00AAAA") +rgblightstone.add("darkmagenta","AA00AA") +rgblightstone.add("brown","AA5500") +rgblightstone.add("darkgray","555555") +rgblightstone.add("white","FFFFFF") +rgblightstone.add("black","000000") + +if rgblightstone.extracolors and not rgblightstone.insanecolors then + for r=0x0,0xFF,0x11 do + for g=0x0,0xFF,0x11 do + for b=0x0,0xFF,0x11 do + local color = string.format("%02X%02X%02X",r,g,b) + rgblightstone.add(color,color) + end + end + end +end + +if rgblightstone.insanecolors then + for r=0x0,0xFF,0x1 do + for g=0x0,0xFF,0x1 do + for b=0x0,0xFF,0x1 do + local color = string.format("%02X%02X%02X",r,g,b) + rgblightstone.add(color,color) + end + end + end +end + if minetest.get_modpath("mesecons_luacontroller") and minetest.get_modpath("digilines") then minetest.register_craft({ output = "rgblightstone:lightstone_off", diff --git a/textures/rgblightstone_black.png b/textures/rgblightstone_black.png deleted file mode 100644 index f3e2010..0000000 Binary files a/textures/rgblightstone_black.png and /dev/null differ diff --git a/textures/rgblightstone_blue.png b/textures/rgblightstone_blue.png deleted file mode 100644 index 064f202..0000000 Binary files a/textures/rgblightstone_blue.png and /dev/null differ diff --git a/textures/rgblightstone_brown.png b/textures/rgblightstone_brown.png deleted file mode 100644 index d030973..0000000 Binary files a/textures/rgblightstone_brown.png and /dev/null differ diff --git a/textures/rgblightstone_cyan.png b/textures/rgblightstone_cyan.png deleted file mode 100644 index b359bca..0000000 Binary files a/textures/rgblightstone_cyan.png and /dev/null differ diff --git a/textures/rgblightstone_darkblue.png b/textures/rgblightstone_darkblue.png deleted file mode 100644 index b7a49b9..0000000 Binary files a/textures/rgblightstone_darkblue.png and /dev/null differ diff --git a/textures/rgblightstone_darkcyan.png b/textures/rgblightstone_darkcyan.png deleted file mode 100644 index 4f6fe92..0000000 Binary files a/textures/rgblightstone_darkcyan.png and /dev/null differ diff --git a/textures/rgblightstone_darkgray.png b/textures/rgblightstone_darkgray.png deleted file mode 100644 index 9a0b84f..0000000 Binary files a/textures/rgblightstone_darkgray.png and /dev/null differ diff --git a/textures/rgblightstone_darkgreen.png b/textures/rgblightstone_darkgreen.png deleted file mode 100644 index 9e4b3fa..0000000 Binary files a/textures/rgblightstone_darkgreen.png and /dev/null differ diff --git a/textures/rgblightstone_darkmagenta.png b/textures/rgblightstone_darkmagenta.png deleted file mode 100644 index 693a301..0000000 Binary files a/textures/rgblightstone_darkmagenta.png and /dev/null differ diff --git a/textures/rgblightstone_darkred.png b/textures/rgblightstone_darkred.png deleted file mode 100644 index f3d051e..0000000 Binary files a/textures/rgblightstone_darkred.png and /dev/null differ diff --git a/textures/rgblightstone_green.png b/textures/rgblightstone_green.png deleted file mode 100644 index 85cdaae..0000000 Binary files a/textures/rgblightstone_green.png and /dev/null differ diff --git a/textures/rgblightstone_magenta.png b/textures/rgblightstone_magenta.png deleted file mode 100644 index 3aa7238..0000000 Binary files a/textures/rgblightstone_magenta.png and /dev/null differ diff --git a/textures/rgblightstone_red.png b/textures/rgblightstone_red.png deleted file mode 100644 index ba656da..0000000 Binary files a/textures/rgblightstone_red.png and /dev/null differ diff --git a/textures/rgblightstone_white.png b/textures/rgblightstone_white.png deleted file mode 100644 index 095ca8f..0000000 Binary files a/textures/rgblightstone_white.png and /dev/null differ diff --git a/textures/rgblightstone_yellow.png b/textures/rgblightstone_yellow.png deleted file mode 100644 index c976bff..0000000 Binary files a/textures/rgblightstone_yellow.png and /dev/null differ -- cgit v1.2.3