Rename switches to levers and fix treecapitator with activated tree node
This commit is contained in:
parent
bd8db366c9
commit
2fe7a05a3d
@ -154,8 +154,9 @@ minetest.register_node("main:tree", {
|
||||
if not meta:contains("placed") then
|
||||
--remove tree
|
||||
for y = -6,6 do
|
||||
local name = minetest.get_node(vector.new(pos.x,pos.y+y,pos.z)).name
|
||||
--print(y)
|
||||
if minetest.get_node(vector.new(pos.x,pos.y+y,pos.z)).name == "main:tree" then
|
||||
if name == "main:tree" or name == "redstone:node_activated_tree" then
|
||||
minetest.node_dig(vector.new(pos.x,pos.y+y,pos.z), node, digger)
|
||||
end
|
||||
end
|
||||
|
@ -1,14 +1,12 @@
|
||||
--this removes power from node that the switch is powering
|
||||
--this removes power from node that the button is powering
|
||||
local function on_button_destroy(pos)
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local self = minetest.get_node(pos)
|
||||
local dir = minetest.wallmounted_to_dir(self.param2)
|
||||
|
||||
local dir = minetest.wallmounted_to_dir(param2)
|
||||
local pos = vector.add(dir,pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local name = node.name
|
||||
|
||||
local def = minetest.registered_nodes[name]
|
||||
|
||||
if def.drawtype == "normal" and string.match(name, "redstone:node_activated_") then
|
||||
name = "main:"..string.gsub(name, "redstone:node_activated_", "")
|
||||
minetest.set_node(pos, {name=name})
|
||||
@ -20,7 +18,7 @@ end
|
||||
minetest.register_node("redstone:button_off", {
|
||||
description = "Crafting Table",
|
||||
tiles = {"stone.png"},
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1},
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
|
||||
sounds = main.stoneSound(),
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
@ -60,7 +58,7 @@ minetest.register_node("redstone:button_off", {
|
||||
minetest.register_node("redstone:button_on", {
|
||||
description = "Crafting Table",
|
||||
tiles = {"stone.png"},
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1},
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
|
||||
sounds = main.stoneSound(),
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
|
@ -13,7 +13,7 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "redstone:switch_off",
|
||||
output = "redstone:lever_off",
|
||||
recipe = {
|
||||
{"main:stick"},
|
||||
{"main:stone"},
|
||||
|
@ -6,3 +6,10 @@ function vector.abs(v)
|
||||
z = math.abs(v.z)
|
||||
}
|
||||
end
|
||||
|
||||
--add a power signal to the position (i) that doesn't actually exist
|
||||
redstone.inject_power_signal = function(i)
|
||||
if not r_index[i.x] then r_index[i.x] = {} end
|
||||
if not r_index[i.x][i.y] then r_index[i.x][i.y] = {} end
|
||||
r_index[i.x][i.y][i.z] = {torch = true,power=9}
|
||||
end
|
||||
|
@ -1,9 +1,12 @@
|
||||
---set a torch source
|
||||
--define the class
|
||||
redstone = {}
|
||||
local r_index = {}
|
||||
|
||||
local path = minetest.get_modpath("redstone")
|
||||
dofile(path.."/functions.lua")
|
||||
dofile(path.."/wire.lua")
|
||||
dofile(path.."/torch.lua")
|
||||
dofile(path.."/switches.lua")
|
||||
dofile(path.."/lever.lua")
|
||||
dofile(path.."/button.lua")
|
||||
dofile(path.."/repeater.lua")
|
||||
dofile(path.."/light.lua")
|
||||
@ -16,9 +19,6 @@ dofile(path.."/player_detector.lua")
|
||||
dofile(path.."/space_maker.lua")
|
||||
dofile(path.."/pressure_plate.lua")
|
||||
|
||||
redstone = {}
|
||||
|
||||
local r_index = {}
|
||||
|
||||
get_old_power = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -18,7 +18,7 @@ for name,def in pairs(minetest.registered_nodes) do
|
||||
end
|
||||
|
||||
|
||||
--this removes power from node that the switch is powering
|
||||
--this removes power from node that the lever is powering
|
||||
local function on_lever_destroy(pos)
|
||||
local param2 = minetest.get_node(pos).param2
|
||||
local self = minetest.get_node(pos)
|
||||
@ -31,23 +31,23 @@ local function on_lever_destroy(pos)
|
||||
local def = minetest.registered_nodes[name]
|
||||
if def.drawtype == "normal" and string.match(name, "redstone:node_activated_")then
|
||||
name = "main:"..string.gsub(name, "redstone:node_activated_", "")
|
||||
minetest.set_node(pos, {name=name})
|
||||
minetest.swap_node(pos, {name=name})
|
||||
redstone.collect_info(pos)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
minetest.register_node("redstone:switch_off", {
|
||||
description = "Switch",
|
||||
minetest.register_node("redstone:lever_off", {
|
||||
description = "Lever",
|
||||
tiles = {"stone.png"},
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1},
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
|
||||
sounds = main.stoneSound(),
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
drawtype= "nodebox",
|
||||
drop="redstone:switch_off",
|
||||
drop="redstone:lever_off",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
@ -57,7 +57,7 @@ minetest.register_node("redstone:switch_off", {
|
||||
},
|
||||
},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.set_node(pos, {name="redstone:switch_on",param2=node.param2})
|
||||
minetest.set_node(pos, {name="redstone:lever_on",param2=node.param2})
|
||||
local dir = minetest.wallmounted_to_dir(node.param2)
|
||||
local pos = vector.add(dir,pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
@ -66,7 +66,7 @@ minetest.register_node("redstone:switch_off", {
|
||||
if def.drawtype == "normal" and string.match(name, "main:") then
|
||||
minetest.sound_play("lever", {pos=pos})
|
||||
name = "redstone:node_activated_"..string.gsub(name, "main:", "")
|
||||
minetest.set_node(pos,{name=name})
|
||||
minetest.swap_node(pos,{name=name})
|
||||
redstone.collect_info(pos)
|
||||
else
|
||||
minetest.sound_play("lever", {pos=pos,pitch=0.6})
|
||||
@ -74,17 +74,17 @@ minetest.register_node("redstone:switch_off", {
|
||||
end,
|
||||
on_destruct = on_lever_destroy,
|
||||
})
|
||||
minetest.register_node("redstone:switch_on", {
|
||||
description = "Crafting Table",
|
||||
minetest.register_node("redstone:lever_on", {
|
||||
description = "Lever On",
|
||||
tiles = {"stone.png"},
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1},
|
||||
groups = {stone = 1, hard = 1, pickaxe = 1, hand = 4,attached_node = 1,dig_immediate=1},
|
||||
sounds = main.stoneSound(),
|
||||
paramtype = "light",
|
||||
paramtype2 = "wallmounted",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
drawtype= "nodebox",
|
||||
drop="redstone:switch_off",
|
||||
drop="redstone:lever_off",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
@ -95,7 +95,7 @@ minetest.register_node("redstone:switch_on", {
|
||||
},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
minetest.sound_play("lever", {pos=pos,pitch=0.8})
|
||||
minetest.set_node(pos, {name="redstone:switch_off",param2=node.param2})
|
||||
minetest.set_node(pos, {name="redstone:lever_off",param2=node.param2})
|
||||
on_lever_destroy(pos)
|
||||
end,
|
||||
on_destruct = on_lever_destroy,
|
@ -4,7 +4,7 @@ local items = {
|
||||
"redstone:repeater_off_0 50",
|
||||
"redstone:comparator_0 50",
|
||||
"redstone:torch 50",
|
||||
"redstone:switch_off 50",
|
||||
"redstone:lever_off 50",
|
||||
"redstone:button_off 50",
|
||||
"redstone:piston_off 50",
|
||||
"redstone:light_off 50",
|
||||
|
Loading…
x
Reference in New Issue
Block a user