dofile(path.."/lever.lua")
dofile(path.."/button.lua")
dofile(path.."/repeater.lua")
---dofile(path.."/light.lua")
+dofile(path.."/light.lua")
--dofile(path.."/piston.lua")
--dofile(path.."/comparator.lua")
--dofile(path.."/craft.lua")
-- activators
-local n
+local n_pos
local temp_pool
+local temp_pool2
local non_directional_activator = function(pos)
+ temp_pool = pool[pos.x][pos.y][pos.z]
for _,order in pairs(order) do
n_pos = add_vec(pos,order)
- temp_pool = pool[n.x][n.y][n.z]
- if temp_pool then
- --if temp_pool.dust and temp_pool.dust > 0 or
- --print(get_node(add_vec(new_vec(x,y,z),pos)).name)
- if get_item_group(get_node(add_vec(new_vec(order.x,order.y,order.z),pos)).name, "redstone_power") > 0 then
- return(1)
+ if pool[n_pos.x] and pool[n_pos.x][n_pos.y] and pool[n_pos.x][n_pos.y][n_pos.z] then
+ temp_pool2 = pool[n_pos.x][n_pos.y][n_pos.z]
+ if temp_pool2 then
+ if (not temp_pool2.directional_activator and temp_pool2.torch) or
+ (temp_pool2.dust and temp_pool2.dust > 0) then
+ if activator_table[temp_pool.name].activate then
+ activator_table[temp_pool.name].activate(pos)
+ end
+ return
+ end
end
end
end
- return(0)
+ if activator_table[temp_pool.name].deactivate then
+ activator_table[temp_pool.name].deactivate(pos)
+ end
end
-- directional activators
local minetest = minetest
-minetest.register_node("redstone:light_on", {
- description = "Redstone Light",
- tiles = {"redstone_light.png"},
- drawtype = "normal",
- light_source = 12,
- groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,pathable = 1,redstone_activation=1},
- sounds = main.stoneSound({
- footstep = {name = "glass_footstep", gain = 0.4},
- dug = {name = "break_glass", gain = 0.4},
- }),
- drop = "redstone:light_off",
- redstone_activation = function(pos)
+
+local colors = {
+ "white",
+ "yellow",
+ "green",
+ "blue",
+ "violet",
+ "red",
+ "orange",
+ "black"
+}
+
+--this allows for a more pale off state so players have more freedom to create different colors
+for _,color in pairs(colors) do
+ minetest.register_node("redstone:light_on_"..color, {
+ description = color:gsub("^%l", string.upper).." Redstone Light",
+ tiles = {"redstone_light.png^[colorize:"..color..":200"},
+ drawtype = "normal",
+ light_source = 12,
+ groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,pathable = 1},
+ sounds = main.stoneSound({
+ footstep = {name = "glass_footstep", gain = 0.4},
+ dug = {name = "break_glass", gain = 0.4},
+ }),
+ drop = "redstone:light_off_"..color,
+
+ after_place_node = function(pos, placer, itemstack, pointed_thing)
+ redstone.inject(pos,{
+ name = "redstone:light_on_"..color,
+ activator = true,
+ })
+
+ redstone.update(pos)
+ end,
+ after_destruct = function(pos, oldnode)
+ redstone.inject(pos,nil)
+ redstone.update(pos)
+ end
+ })
+
+ redstone.register_activator({
+ name = "redstone:light_on_"..color,
+ deactivate = function(pos)
+
+ minetest.swap_node(pos,{name="redstone:light_off_"..color})
+
+ redstone.inject(pos,{
+ name = "redstone:light_off_"..color,
+ activator = true,
+ })
+ end
+ })
+
+ minetest.register_lbm({
+ name = "redstone:light_on_"..color,
+ nodenames = {"redstone:light_on_"..color},
+ run_at_every_load = true,
+ action = function(pos)
+ redstone.inject(pos,{
+ name = "redstone:light_on_"..color,
+ activator = true,
+ })
+
+ minetest.after(0,function()
+ redstone.update(pos)
+ end)
end,
- redstone_deactivation = function(pos)
- minetest.set_node(pos,{name="redstone:light_off"})
-
+ })
+
+
+
+ minetest.register_node("redstone:light_off_"..color, {
+ description = color:gsub("^%l", string.upper).." Redstone Light",
+ tiles = {"redstone_light.png^[colorize:"..color..":100"},
+ drawtype = "normal",
+ groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,pathable = 1,redstone_activation=1},
+ sounds = main.stoneSound({
+ footstep = {name = "glass_footstep", gain = 0.4},
+ dug = {name = "break_glass", gain = 0.4},
+ }),
+ drop = "redstone:light_off_"..color,
+
+
+ after_place_node = function(pos, placer, itemstack, pointed_thing)
+ redstone.inject(pos,{
+ name = "redstone:light_off_"..color,
+ activator = true,
+ })
+
+ redstone.update(pos)
+ end,
+
+ after_destruct = function(pos, oldnode)
+ redstone.inject(pos,nil)
+ redstone.update(pos)
+ end
+ })
+
+
+ redstone.register_activator({
+ name = "redstone:light_off_"..color,
+ activate = function(pos)
+
+ minetest.swap_node(pos,{name="redstone:light_on_"..color})
+
+ redstone.inject(pos,{
+ name = "redstone:light_on_"..color,
+ activator = true,
+ })
+ end
+ })
+
+ minetest.register_lbm({
+ name = "redstone:light_off_"..color,
+ nodenames = {"redstone:light_off_"..color},
+ run_at_every_load = true,
+ action = function(pos)
+ redstone.inject(pos,{
+ name = "redstone:light_off_"..color,
+ activator = true,
+ })
+
+ minetest.after(0,function()
+ redstone.update(pos)
+ end)
end,
-})
-minetest.register_node("redstone:light_off", {
- description = "Redstone Light",
- tiles = {"redstone_light.png"},
- drawtype = "normal",
- groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,pathable = 1,redstone_activation=1},
- sounds = main.stoneSound({
- footstep = {name = "glass_footstep", gain = 0.4},
- dug = {name = "break_glass", gain = 0.4},
- }),
- drop = "redstone:light_off",
- redstone_activation = function(pos)
- minetest.set_node(pos,{name="redstone:light_on"})
- end,
- redstone_deactivation = function(pos)
- end,
-})
+ })
+
+
+
+ minetest.register_craft({
+ output = "redstone:light_off_"..color,
+ type = "shapeless",
+ recipe = {"main:glass","redstone:dust","dye:"..color},
+ })
+end
\ No newline at end of file