Make redstone ore glow and ouput signal when punched random amount of time

This commit is contained in:
oilboi 2020-03-24 17:37:12 -04:00
parent 5b1e0e0a04
commit bf9f5e8042
2 changed files with 9 additions and 57 deletions

View File

@ -7,9 +7,16 @@ for i = 0,1 do
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,pathable = 1}
on_punch = function(pos, node, puncher, pointed_thing)
minetest.set_node(pos, {name="redstone:ore_1"})
redstone.collect_info(pos)
local timer = minetest.get_node_timer(pos)
timer:start(math.random(10,50))
end
else
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,pathable = 1,redstone=1,redstone_torch=1}
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,pathable = 1,redstone=1,redstone_torch=1,redstone_power=9}
on_timer = function(pos, elapsed)
minetest.set_node(pos, {name="redstone:ore_0"})
redstone.collect_info(pos)
end
end
minetest.register_node("redstone:ore_"..i, {
description = "Redstone Ore",
@ -48,6 +55,7 @@ for i = 0,1 do
},
},
on_punch = on_punch,
on_timer = on_timer,
})
end
--redstone ore

View File

@ -68,37 +68,6 @@ function repeater_on_timer(pos)
end
repeater_set_buffer(pos,0)
--[[
local new_power = repeater_get_new_power(pos)
local self_repeater_level = minetest.get_node_group(minetest.get_node(pos).name, "repeater_level")
local param2 = minetest.get_node(pos).param2
if new_power == 0 then
minetest.swap_node(pos,{name="redstone:repeater_off_"..self_repeater_level,param2=param2})
elseif new_power > 0 then
minetest.swap_node(pos,{name="redstone:repeater_on_"..self_repeater_level,param2=param2})
end
local param2 = minetest.get_node(pos).param2
local input = minetest.facedir_to_dir(param2)
input = vector.multiply(input,-1)
input = vector.add(pos,input)
local output = minetest.facedir_to_dir(param2)
output = vector.add(pos,output)
local input_node = minetest.get_node(input)
local output_node = minetest.get_node(output)
--minetest.after(0.5, function(pos,param2,input,output,input_node,output_node)
if minetest.get_node_group(output_node.name, "redstone_dust") > 0 then
redstone.collect_info(output)
elseif minetest.get_node_group(output_node.name, "repeater") > 0 then
local timer = minetest.get_node_timer(output)
timer:start(repeater_level/2)
elseif minetest.get_node_group(output_node.name, "redstone_activation") > 0 then
redstone.collect_info(output)
end
--end,pos,param2,input,output,input_node,output_node)
]]--
end
function repeater_input(pos)
@ -117,31 +86,6 @@ function repeater_input(pos)
local timer = minetest.get_node_timer(pos)
timer:start(self_repeater_level/2)
--[[
local param2 = minetest.get_node(pos).param2
local input = minetest.facedir_to_dir(param2)
input = vector.multiply(input,-1)
input = vector.add(pos,input)
local input_node = minetest.get_node(input)
local self_repeater_level = minetest.get_node_group(minetest.get_node(pos).name, "repeater_level")
if minetest.get_node_group(input_node.name, "redstone_power") == 0 then
minetest.swap_node(pos,{name="redstone:repeater_off_"..self_repeater_level,param2=param2})
elseif minetest.get_node_group(input_node.name, "redstone_power") > 0 then
minetest.swap_node(pos,{name="redstone:repeater_on_"..self_repeater_level,param2=param2})
end
set_old_power(pos,old_power)
local output = minetest.facedir_to_dir(param2)
output = vector.add(pos,output)
local timer = minetest.get_node_timer(output)
timer:start(level/2)
repeater_pass_new_power(output,old_power)
]]--
set_old_power(pos,power)
end