fixes, added MV cable

This commit is contained in:
Maciej Kasatkin 2012-10-07 20:30:43 +02:00
parent 0821f3913a
commit a546665856
6 changed files with 497 additions and 4 deletions

View File

@ -25,7 +25,7 @@ register_alloy_recipe ("technic:copper_dust",3, "technic:tin_dust",1, "technic:b
register_alloy_recipe ("moreores:copper_ingot",3, "moreores:tin_ingot",1, "moreores:bronze_ingot",4) register_alloy_recipe ("moreores:copper_ingot",3, "moreores:tin_ingot",1, "moreores:bronze_ingot",4)
register_alloy_recipe ("technic:iron_dust",3, "technic:chromium_dust",1, "technic:stainless_steel_dust",4) register_alloy_recipe ("technic:iron_dust",3, "technic:chromium_dust",1, "technic:stainless_steel_dust",4)
register_alloy_recipe ("default:sand",2, "technic:coal_dust",2, "technic:silicon_wafer",1) register_alloy_recipe ("default:sand",2, "technic:coal_dust",2, "technic:silicon_wafer",1)
register_alloy_recipe ("technic:silicon_wafer",1, "technic:mithril_dust",3, "technic:doped_silicon_wafer",1) register_alloy_recipe ("technic:silicon_wafer",1, "technic:mithril_dust",2, "technic:doped_silicon_wafer",1)
minetest.register_alias("alloy_furnace", "technic:alloy_furnace") minetest.register_alias("alloy_furnace", "technic:alloy_furnace")

View File

@ -1,6 +1,5 @@
default default
moreores moreores
stairs
flowers flowers
dye dye
pipeworks pipeworks

View File

@ -23,6 +23,7 @@ dofile(minetest.get_modpath("technic").."/mithril_chest.lua")
dofile(minetest.get_modpath("technic").."/electric_furnace.lua") dofile(minetest.get_modpath("technic").."/electric_furnace.lua")
dofile(minetest.get_modpath("technic").."/battery_box.lua") dofile(minetest.get_modpath("technic").."/battery_box.lua")
dofile(minetest.get_modpath("technic").."/wires.lua") dofile(minetest.get_modpath("technic").."/wires.lua")
dofile(minetest.get_modpath("technic").."/wires_mv.lua")
dofile(minetest.get_modpath("technic").."/dyes.lua") dofile(minetest.get_modpath("technic").."/dyes.lua")
dofile(minetest.get_modpath("technic").."/ores.lua") dofile(minetest.get_modpath("technic").."/ores.lua")

View File

@ -1,3 +1,5 @@
-- Code of rubber tree by PilzAdam
minetest.register_node("technic:rubber_sapling", { minetest.register_node("technic:rubber_sapling", {
description = "Rubber Tree Sapling", description = "Rubber Tree Sapling",
drawtype = "plantlike", drawtype = "plantlike",
@ -69,7 +71,7 @@ minetest.register_abm({
interval = 60, interval = 60,
chance = 20, chance = 20,
action = function(pos, node) action = function(pos, node)
farming:generate_tree(pos, "technic:rubber_tree_full", "technic:rubber_leaves", {"default:dirt", "default:dirt_with_grass"}) technic:generate_tree(pos, "technic:rubber_tree_full", "technic:rubber_leaves", {"default:dirt", "default:dirt_with_grass"})
end end
}) })
@ -80,7 +82,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z} local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"}) local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
if pos ~= nil then if pos ~= nil then
farming:generate_tree({x=pos.x, y=pos.y+1, z=pos.z}, "technic:rubber_tree_full", "technic:rubber_leaves", {"default:dirt", "default:dirt_with_grass"}) technic:generate_tree({x=pos.x, y=pos.y+1, z=pos.z}, "technic:rubber_tree_full", "technic:rubber_leaves", {"default:dirt", "default:dirt_with_grass"})
end end
end) end)
@ -91,3 +93,94 @@ minetest.register_craft({
recipe = "technic:rubber_sapling", recipe = "technic:rubber_sapling",
burntime = 10 burntime = 10
}) })
function technic:generate_tree(pos, trunk, leaves, underground, replacements)
pos.y = pos.y-1
local nodename = minetest.env:get_node(pos).name
local ret = true
for _,name in ipairs(underground) do
if nodename == name then
ret = false
break
end
end
pos.y = pos.y+1
if ret or minetest.env:get_node_light(pos) < 8 then
return
end
node = {name = ""}
for dy=1,4 do
pos.y = pos.y+dy
if minetest.env:get_node(pos).name ~= "air" then
return
end
pos.y = pos.y-dy
end
node.name = trunk
for dy=0,4 do
pos.y = pos.y+dy
minetest.env:set_node(pos, node)
pos.y = pos.y-dy
end
if not replacements then
replacements = {}
end
node.name = leaves
pos.y = pos.y+3
for dx=-2,2 do
for dz=-2,2 do
for dy=0,3 do
pos.x = pos.x+dx
pos.y = pos.y+dy
pos.z = pos.z+dz
if dx == 0 and dz == 0 and dy==3 then
if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.env:set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
end
end
end
elseif dx == 0 and dz == 0 and dy==4 then
if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.env:set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
end
end
end
elseif math.abs(dx) ~= 2 and math.abs(dz) ~= 2 then
if minetest.env:get_node(pos).name == "air" then
minetest.env:set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
end
end
end
else
if math.abs(dx) ~= 2 or math.abs(dz) ~= 2 then
if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then
minetest.env:set_node(pos, node)
for name,rarity in pairs(replacements) do
if math.random(1, rarity) == 1 then
minetest.env:set_node(pos, {name=name})
end
end
end
end
end
pos.x = pos.x-dx
pos.y = pos.y-dy
pos.z = pos.z-dz
end
end
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 B

After

Width:  |  Height:  |  Size: 290 B

400
wires_mv.lua Normal file
View File

@ -0,0 +1,400 @@
--MV cable node boxes
minetest.register_alias("mv_cable", "technic:mv_cable")
minetest.register_craft({
output = 'technic:mv_cable 3',
recipe ={
{'technic:rubber','technic:rubber','technic:rubber'},
{'technic:lv_cable','technic:lv_cable','technic:lv_cable'},
{'technic:rubber','technic:rubber','technic:rubber'},
}
})
minetest.register_craftitem("technic:mv_cable", {
description = "Medium Voltage Copper Cable",
stack_max = 99,
})
minetest.register_node("technic:mv_cable", {
description = "Medium Voltage Copper Cable",
tiles = {"technic_mv_cable.png"},
inventory_image = "technic_mv_cable_wield.png",
wield_image = "technic_mv_cable_wield.png",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
drop = "technic:mv_cable",
mv_cablelike=1,
rules_x1=0,
rules_x2=0,
rules_y1=0,
rules_y2=0,
rules_z1=0,
rules_z2=0,
paramtype = "light",
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {
{ -0.1 , -0.1 , -0.1 , 0.1 , 0.1 , 0.1 },
}},
node_box = {
type = "fixed",
fixed = {
{ -0.1 , -0.1 , -0.1 , 0.1 , 0.1 , 0.1 },
}},
on_construct = function(pos)
meta=minetest.env:get_meta(pos)
meta:set_float("mv_cablelike",1)
meta:set_float("x1",0)
meta:set_float("x2",0)
meta:set_float("y1",0)
meta:set_float("y2",0)
meta:set_float("z1",0)
meta:set_float("z2",0)
MV_check_connections (pos)
end,
after_dig_node = function (pos, oldnode, oldmetadata, digger)
MV_check_connections_on_destroy (pos)
end,
})
str_y1= { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1 } --0 y+
str_x1= { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1 } --0 x+
str_z1= { -0.1 , -0.1 , 0.1 , 0.1 , 0.1 , 0.5 } --0 z+
str_z2= { -0.1 , -0.1, -0.5 , 0.1 , 0.1 , 0.1 } --0 z-
str_y2= { -0.1 , -0.5, -0.1 , 0.1 , 0.1 , 0.1 } --0 y-
str_x2= { -0.5 , -0.1, -0.1 , 0.1 , 0.1 , 0.1 } --0 x-
local x1,x2,y1,y2,z1,z2
local count=0
for x1 = 0, 1, 1 do --x-
for x2 = 0, 1, 1 do --x+
for y1 = 0, 1, 1 do --y-
for y2 = 0, 1, 1 do --y-
for z1 = 0, 1, 1 do --z-
for z2 = 0, 1, 1 do --z+
temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
if x1==1 then temp_x1=str_x1 end
if x2==1 then temp_x2=str_x2 end
if y1==1 then temp_y1=str_y1 end
if y2==1 then temp_y2=str_y2 end
if z1==1 then temp_z1=str_z1 end
if z2==1 then temp_z2=str_z2 end
minetest.register_node("technic:mv_cable"..count, {
description = "Medium Voltage Copper Cable",
tiles = {"technic_mv_cable.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
drop = "technic:mv_cable",
rules_x1=0,
rules_x2=0,
rules_y1=0,
rules_y2=0,
rules_z1=0,
rules_z2=0,
cablelike=1,
paramtype = "light",
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {
temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
}},
node_box = {
type = "fixed",
fixed = {
temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
}},
after_dig_node = function (pos, oldnode, oldmetadata, digger)
MV_check_connections_on_destroy (pos)
end,
})
count=count+1 end end end end end end
MV_check_connections = function(pos)
local pos1={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
pos1.x=pos1.x+1
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
x2=1
x1=minetest.env:get_meta(pos1):get_float("x1")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:mv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("x2",x2)
meta=minetest.env:get_meta(pos)
x1=1
x2=minetest.env:get_meta(pos):get_float("x2")
y1=minetest.env:get_meta(pos):get_float("y1")
y2=minetest.env:get_meta(pos):get_float("y2")
z1=minetest.env:get_meta(pos):get_float("z1")
z2=minetest.env:get_meta(pos):get_float("z2")
meta:set_float("x1",x1)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:mv_cable"..rule)
end
pos1.x=pos1.x-2
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
x1=1
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:mv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("x1",x1)
meta=minetest.env:get_meta(pos)
x2=1
x1=minetest.env:get_meta(pos):get_float("x1")
y1=minetest.env:get_meta(pos):get_float("y1")
y2=minetest.env:get_meta(pos):get_float("y2")
z1=minetest.env:get_meta(pos):get_float("z1")
z2=minetest.env:get_meta(pos):get_float("z2")
meta:set_float("x2",x2)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:mv_cable"..rule)
end
pos1.x=pos1.x+1
pos1.y=pos1.y+1
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
y2=1
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:mv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("y2",y2)
meta=minetest.env:get_meta(pos)
y1=1
x1=minetest.env:get_meta(pos):get_float("x1")
x2=minetest.env:get_meta(pos):get_float("x2")
y2=minetest.env:get_meta(pos):get_float("y2")
z1=minetest.env:get_meta(pos):get_float("z1")
z2=minetest.env:get_meta(pos):get_float("z2")
meta:set_float("y1",y1)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:mv_cable"..rule)
end
if minetest.env:get_meta(pos1):get_float("technic_mv_power_machine")==1 then
y1=1
x1=minetest.env:get_meta(pos):get_float("x1")
x2=minetest.env:get_meta(pos):get_float("x2")
y2=minetest.env:get_meta(pos):get_float("y2")
z1=minetest.env:get_meta(pos):get_float("z1")
z2=minetest.env:get_meta(pos):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:mv_cable"..rule)
meta=minetest.env:get_meta(pos)
meta:set_float("y1",y1)
end
pos1.y=pos1.y-2
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
y1=1
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:mv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("y1",y1)
meta=minetest.env:get_meta(pos)
y2=1
x1=minetest.env:get_meta(pos):get_float("x1")
x2=minetest.env:get_meta(pos):get_float("x2")
y1=minetest.env:get_meta(pos):get_float("y1")
z1=minetest.env:get_meta(pos):get_float("z1")
z2=minetest.env:get_meta(pos):get_float("z2")
meta:set_float("y2",y2)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:mv_cable"..rule)
end
pos1.y=pos1.y+1
pos1.z=pos1.z+1
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
z2=1
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:mv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("z2",z2)
meta=minetest.env:get_meta(pos)
z1=1
x1=minetest.env:get_meta(pos):get_float("x1")
x2=minetest.env:get_meta(pos):get_float("x2")
y1=minetest.env:get_meta(pos):get_float("y1")
y2=minetest.env:get_meta(pos):get_float("y2")
z2=minetest.env:get_meta(pos):get_float("z2")
meta:set_float("z1",z1)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:mv_cable"..rule)
end
pos1.z=pos1.z-2
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
z1=1
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos1,"technic:mv_cable"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_float("z1",z1)
meta=minetest.env:get_meta(pos)
z2=1
x1=minetest.env:get_meta(pos):get_float("x1")
x2=minetest.env:get_meta(pos):get_float("x2")
y1=minetest.env:get_meta(pos):get_float("y1")
y2=minetest.env:get_meta(pos):get_float("y2")
z1=minetest.env:get_meta(pos):get_float("z1")
meta:set_float("z2",z2)
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
hacky_swap_node(pos,"technic:mv_cable"..rule)
end
pos1.z=pos1.z+1
end
MV_check_connections_on_destroy = function(pos)
local pos1={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
pos1.x=pos1.x+1
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
x2=0
x1=minetest.env:get_meta(pos1):get_float("x1")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("x2",x2)
end
pos1.x=pos1.x-2
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
x1=0
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("x1",x1)
end
pos1.x=pos1.x+1
pos1.y=pos1.y+1
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
y2=0
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("y2",y2)
end
pos1.y=pos1.y-2
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
y1=0
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("y1",y1)
end
pos1.y=pos1.y+1
pos1.z=pos1.z+1
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
z2=0
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z1=minetest.env:get_meta(pos1):get_float("z1")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("z2",z2)
end
pos1.z=pos1.z-2
if minetest.env:get_meta(pos1):get_float("mv_cablelike")==1 then
z1=0
x1=minetest.env:get_meta(pos1):get_float("x1")
x2=minetest.env:get_meta(pos1):get_float("x2")
y1=minetest.env:get_meta(pos1):get_float("y1")
y2=minetest.env:get_meta(pos1):get_float("y2")
z2=minetest.env:get_meta(pos1):get_float("z2")
rule=make_rule_number(x1,x2,y1,y2,z1,z2)
if rule==0 then hacky_swap_node(pos1,"technic:mv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:mv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("z1",z1)
end
pos1.y=pos1.y+1
end