From 784ba2e68ca534b4355ecc26509e53c214f13977 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Thu, 16 Feb 2017 17:05:50 -0500 Subject: update several mods and add a few updated: blox, bobblocks, castle, homedecor, coloredwood, ilights, stainedglass, unifiedbricks added: cheapie's rgblightstone, digistuff, unifiedmesecons, and solidcolor --- rgblightstone/README | 43 +++++++ rgblightstone/depends.txt | 0 rgblightstone/init.lua | 145 +++++++++++++++++++++++ rgblightstone/textures/rgblightstone_palette.png | Bin 0 -> 2824 bytes rgblightstone/textures/rgblightstone_white.png | Bin 0 -> 98 bytes 5 files changed, 188 insertions(+) create mode 100644 rgblightstone/README create mode 100644 rgblightstone/depends.txt create mode 100644 rgblightstone/init.lua create mode 100644 rgblightstone/textures/rgblightstone_palette.png create mode 100644 rgblightstone/textures/rgblightstone_white.png (limited to 'rgblightstone') diff --git a/rgblightstone/README b/rgblightstone/README new file mode 100644 index 0000000..1b042a0 --- /dev/null +++ b/rgblightstone/README @@ -0,0 +1,43 @@ +RGB Lightstones for Minetest + +License: +---Code: WTFPL +---Textures: "white" image by VanessaE (WTFPL), "palette" image is from here: https://commons.wikimedia.org/wiki/File:256colour.png + +Depends: mesecons_lightstone, digilines +(neither is in depends.txt since the order doesn't matter) + +Instructions: + +* Grab one from the creative inventory, or craft one: + nothing green lightstone nothing + red lightstone luacontroller blue lightstone + nothing digiline nothing + +* Place the thing +* Right-click and set a channel +* Send a digilines message to it on that channel with the color you want (choices listed below) + +Colors available: Any 6-digit hex color, such as "FF0000", "#c0ffee", "123456"... (will be set to the nearest color available) + +Group addressing mode: + +If you are building something with large numbers of these things, set them all to the same channel, set X and Y addresses on each, and send nested tables (Y on the outside) with colors for all of them. +For example, given this display: + +X=1 Y=1 X=2 Y=1 + +X=1 Y=2 X=2 Y=2 + +to make it show: + +red green +blue yellow + +send this: + +{{"red","green"}, +{"blue","yellow"}} + +Note that if you are using group addressing mode, if there is an already-configured RGB lightstone node directly above the one you are setting up, +punching the one you are setting up (or right-clicking and selecting the Auto-Fill option) will attempt to auto-fill it (incrementing the Y address) from the one above. diff --git a/rgblightstone/depends.txt b/rgblightstone/depends.txt new file mode 100644 index 0000000..e69de29 diff --git a/rgblightstone/init.lua b/rgblightstone/init.lua new file mode 100644 index 0000000..a26f7ab --- /dev/null +++ b/rgblightstone/init.lua @@ -0,0 +1,145 @@ +rgblightstone = {} + +if type(minetest.colorize) == "function" then + rgblightstone.colorize = minetest.colorize +else + rgblightstone.colorize = function(color,text) + return text + end +end + +function rgblightstone.autofill(pos, player) + 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 + end + local meta = minetest.get_meta(pos) + if (not meta:get_string("channel")) or meta:get_string("channel")=="" then + local pos_above = {x=pos.x,y=pos.y+1,z=pos.z} + local node_above = minetest.get_node(pos_above) + local meta_above = minetest.get_meta(pos_above) + if string.match(node_above.name,"rgblightstone") and + meta_above:get_string("channel") and + tonumber(meta_above:get_string("addrx")) and + tonumber(meta_above:get_string("addry")) then + local channel = meta_above:get_string("channel") + local addrx = meta_above:get_string("addrx") + local addry = tostring(1+tonumber(meta_above:get_string("addry"))) + meta:set_string("channel",channel) + meta:set_string("addrx",addrx) + meta:set_string("addry",addry) + minetest.chat_send_player(player:get_player_name(),rgblightstone.colorize("#55FF55","Success: ").."Auto-filled with channel "..rgblightstone.colorize("#00FFFF",channel)..", X address "..rgblightstone.colorize("#00FFFF",addrx)..", and Y address "..rgblightstone.colorize("#00FFFF",addry)..".") + meta:set_string("infotext","") + else + minetest.chat_send_player(player:get_player_name(),rgblightstone.colorize("#FF0000","ERROR: ").."Node above is not RGB Lightstone or is not configured correctly!") + end + end +end + +minetest.register_node("rgblightstone:rgblightstone", { + tiles = {"rgblightstone_white.png"}, + palette = "rgblightstone_palette.png", + groups = {cracky=2}, + description = "RGB Lightstone", + paramtype2 = "color", + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", "size[8,5;]field[1,1;6,2;channel;Channel;${channel}]field[1,2;2,2;addrx;X Address;${addrx}]field[5,2;2,2;addry;Y Address;${addry}]button_exit[2.25,3;3,1;submit;Save]button_exit[2.25,4;3,1;autofill;Auto-Fill From Node Above]label[3,2;Leave address blank\nfor individual mode]") + meta:set_string("infotext","Not configured! Right-click to set up manually, or punch to auto-fill from the node above.") + meta:set_string("color","000000") + end, + on_punch = function(pos, node, player, pointed_thing) + rgblightstone.autofill(pos,player) + end, + on_receive_fields = function(pos, formname, fields, sender) + local name = sender: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 + end + local meta = minetest.get_meta(pos) + if fields.autofill then + rgblightstone.autofill(pos,sender) + else + if fields.channel then + meta:set_string("channel", fields.channel) + meta:set_string("infotext","") + end + if fields.addrx then meta:set_string("addrx",fields.addrx) end + if fields.addry then meta:set_string("addry",fields.addry) end + end + end, + light_source = 0, + digiline = { + receptor = {}, + effector = { + action = function(pos, node, channel, msg) + local meta = minetest.get_meta(pos) + local setchan = meta:get_string("channel") + if channel ~= setchan then + return + end + + local addrx = tonumber(meta:get_string("addrx")) + local addry = tonumber(meta:get_string("addry")) + + if type(msg) == "table" then + if not (addrx and addry and type(msg[addry]) == "table" and msg[addry][addrx]) then + return + end + msg = msg[addry][addrx] + end + + --Validation starts here + if type(msg) ~= "string" then + return + end + msg = string.upper(msg) + --Drop a leading # if present (e.g. "#FF55AA") + if string.sub(msg,1,1) == "#" then + msg = string.sub(msg,2) + end + --Check length + if string.len(msg) ~= 6 then + return + end + --Make sure there aren't any invalid chars + local acceptable_chars = {["0"]=true,["1"]=true,["2"]=true,["3"]=true,["4"]=true,["5"]=true,["6"]=true,["7"]=true,["8"]=true,["9"]=true,["A"]=true,["B"]=true,["C"]=true,["D"]=true,["E"]=true,["F"]=true} + for i = 1,6,1 do + if not acceptable_chars[string.sub(msg,i,i)] then + return + else + end + end + --Should be a valid hex color by this point + + --Split into three colors + local r = tonumber(string.sub(msg,1,2),16) + local g = tonumber(string.sub(msg,3,4),16) + local b = tonumber(string.sub(msg,5,6),16) + + --Round to nearest available values and convert to a pixel count in the palette + r = math.floor(r/32) + g = math.floor(g/32) + b = math.floor(b/64) --Blue has one fewer bit + + local paletteidx = 32*g+4*r+b + + --Set the color + node.param2 = paletteidx + minetest.swap_node(pos,node) + end + } + } +}) + + +minetest.register_craft({ + output = "rgblightstone:rgblightstone", + recipe = { + {"","mesecons_lightstone:lightstone_green_off",""}, + {"mesecons_lightstone:lightstone_red_off","mesecons_luacontroller:luacontroller0000","mesecons_lightstone:lightstone_blue_off"}, + {"","digilines:wire_std_00000000",""} + } +}) diff --git a/rgblightstone/textures/rgblightstone_palette.png b/rgblightstone/textures/rgblightstone_palette.png new file mode 100644 index 0000000..6043ff1 Binary files /dev/null and b/rgblightstone/textures/rgblightstone_palette.png differ diff --git a/rgblightstone/textures/rgblightstone_white.png b/rgblightstone/textures/rgblightstone_white.png new file mode 100644 index 0000000..095ca8f Binary files /dev/null and b/rgblightstone/textures/rgblightstone_white.png differ -- cgit v1.2.3