Make buttons and levers work properly
This commit is contained in:
parent
79a294b049
commit
3fd2beca9f
@ -19,7 +19,7 @@ minetest.register_node("redstone:button_off", {
|
||||
},
|
||||
},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.set_node(pos, {name="redstone:button_on",param2=node.param2})
|
||||
minetest.swap_node(pos, {name="redstone:button_on",param2=node.param2})
|
||||
|
||||
minetest.sound_play("lever", {pos=pos})
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
@ -67,7 +67,7 @@ minetest.register_node("redstone:button_on", {
|
||||
minetest.sound_play("lever", {pos=pos,pitch=0.8})
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.set_node(pos, {name="redstone:button_off",param2=node.param2})
|
||||
minetest.swap_node(pos, {name="redstone:button_off",param2=node.param2})
|
||||
|
||||
local dir = minetest.wallmounted_to_dir(node.param2)
|
||||
pos = vector.add(dir,pos)
|
||||
|
@ -237,20 +237,11 @@ end
|
||||
|
||||
|
||||
--make all power sources push power out
|
||||
local x_min
|
||||
local x_max
|
||||
local y_min
|
||||
local y_max
|
||||
local z_min
|
||||
local z_max
|
||||
local initial_check
|
||||
|
||||
|
||||
local pos
|
||||
local node
|
||||
local power
|
||||
function redstone.calculate()
|
||||
speed_test = minetest.get_us_time()/1000000
|
||||
--speed_test = minetest.get_us_time()/1000000
|
||||
|
||||
--pathfind through memory map
|
||||
for x,index_x in pairs(r_index) do
|
||||
@ -268,26 +259,26 @@ function redstone.calculate()
|
||||
end
|
||||
end
|
||||
|
||||
print("total torch calc time:"..minetest.get_us_time()/1000000-speed_test)
|
||||
--print("total torch calc time:"..minetest.get_us_time()/1000000-speed_test)
|
||||
|
||||
|
||||
|
||||
--reassemble the table into a position list minetest can understand
|
||||
--run through and set dust
|
||||
local count = 0
|
||||
--local count = 0
|
||||
|
||||
for x,datax in pairs(r_index) do
|
||||
for y,datay in pairs(datax) do
|
||||
for z,index in pairs(datay) do
|
||||
--print(get_node(new_vec(x,y,z)).name)
|
||||
if index and index.dust and index.level ~= check_table[x][y][z] then
|
||||
count = count + 1
|
||||
--count = count + 1
|
||||
minetest.set_node(new_vec(x,y,z),{name="redstone:dust_"..index.level})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
print("set "..count.." nodes")
|
||||
--print("set "..count.." nodes")
|
||||
|
||||
for x,datax in pairs(a_index) do
|
||||
for y,datay in pairs(datax) do
|
||||
@ -305,6 +296,7 @@ function redstone.calculate()
|
||||
--non directional activators
|
||||
else
|
||||
power = get_local_power(new_vec(x,y,z))
|
||||
--print(power)
|
||||
if power then
|
||||
if power > 0 then
|
||||
redstone_activate(new_vec(x,y,z),power)
|
||||
|
@ -22,7 +22,7 @@ minetest.register_node("redstone:lever_off", {
|
||||
},
|
||||
},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.set_node(pos, {name="redstone:lever_on",param2=node.param2})
|
||||
minetest.swap_node(pos, {name="redstone:lever_on",param2=node.param2})
|
||||
minetest.sound_play("lever", {pos=pos})
|
||||
|
||||
local dir = minetest.wallmounted_to_dir(node.param2)
|
||||
@ -66,7 +66,7 @@ minetest.register_node("redstone:lever_on", {
|
||||
},
|
||||
},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.set_node(pos, {name="redstone:lever_off",param2=node.param2})
|
||||
minetest.swap_node(pos, {name="redstone:lever_off",param2=node.param2})
|
||||
|
||||
minetest.sound_play("lever", {pos=pos})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user