Merge pull request #1 from Pitriss/master

Update to have similiar repos
master
fairiestoy 2013-10-06 01:22:11 -07:00
commit c3345c41a8
214 changed files with 8439 additions and 7024 deletions

View File

@ -1,6 +1,8 @@
technic 0.4.7
Classic technic 0.4.7
Technic mod for Minetest 0.4.7
Classic technic mod for Minetest 0.4.7
This is older version of technic mod which we consider as more challenging than later builds.
Credits for contributing to the project:
Nekogloop
@ -8,7 +10,7 @@ ShadowNinja
VanessaE
Nore/Novatux
kpoppel
And many others for ideas/inspiring
And many others for ideas/inspiring
License:
LGPLv2+

View File

@ -1,15 +1,6 @@
--Minetest 0.4.7 mod: concrete
--(c) 2013 by RealBadAngel <mk@realbadangel.pl>
local technic = technic or {}
technic.concrete_posts = {}
minetest.register_alias("technic:concrete_post", "technic:concrete_post0")
minetest.register_alias("technic:concrete_post32", "technic:concrete_post12")
minetest.register_alias("technic:concrete_post33", "technic:concrete_post3")
minetest.register_alias("technic:concrete_post34", "technic:concrete_post28")
minetest.register_alias("technic:concrete_post35", "technic:concrete_post19")
minetest.register_craft({
output = 'technic:rebar 6',
recipe = {
@ -31,12 +22,12 @@ minetest.register_craft({
minetest.register_craft({
output = 'technic:concrete_post_platform 6',
recipe = {
{'technic:concrete','technic:concrete_post0','technic:concrete'},
{'technic:concrete','technic:concrete_post','technic:concrete'},
}
})
minetest.register_craft({
output = 'technic:concrete_post0 12',
output = 'technic:concrete_post 12',
recipe = {
{'default:stone','technic:rebar','default:stone'},
{'default:stone','technic:rebar','default:stone'},
@ -53,195 +44,500 @@ minetest.register_craft({
}
})
local box_platform = {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}
local box_center = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
local box_x1 = {0, -0.3, -0.1, 0.5, 0.3, 0.1}
local box_z1 = {-0.1, -0.3, 0, 0.1, 0.3, 0.5}
local box_x2 = {0, -0.3, -0.1, -0.5, 0.3, 0.1}
local box_z2 = {-0.1, -0.3, 0, 0.1, 0.3, -0.5}
platform_box = {-0.5 , 0.3 , -0.5 , 0.5 , 0.5 , 0.5 }
post_str_y={ -0.15 , -0.5 , -0.15 , 0.15 , 0.5 , 0.15 }
post_str_x1={ 0 , -0.3 , -0.1, 0.5 , 0.3 , 0.1 } -- x+
post_str_z1={ -0.1 , -0.3 , 0, 0.1 , 0.3 , 0.5 } -- z+
post_str_x2={ 0 , -0.3 , -0.1, -0.5 , 0.3 , 0.1 } -- x-
post_str_z2={ -0.1 , -0.3 , 0, 0.1 , 0.3 , -0.5 } -- z-
minetest.register_craftitem(":technic:rebar", {
description = "Rebar",
inventory_image = "technic_rebar.png",
stack_max = 99,
})
minetest.register_craftitem(":technic:blast_resistant_concrete", {
description = "Blast-resistant Concrete Block",
inventory_image = "technic_blast_resistant_concrete_block.png",
stack_max = 99,
})
minetest.register_craftitem(":technic:concrete", {
description = "Concrete Block",
inventory_image = "technic_concrete_block.png",
stack_max = 99,
})
minetest.register_craftitem(":technic:concrete_post", {
description = "Concrete Post",
stack_max = 99,
})
minetest.register_craftitem(":technic:concrete_post_platform", {
description = "Concrete Post Platform",
stack_max = 99,
})
minetest.register_node(":technic:concrete", {
description = "Concrete Block",
tile_images = {"technic_concrete_block.png",},
groups = {cracky=1, level=2, concrete=1},
is_ground_content = true,
groups={cracky=1,level=2},
sounds = default.node_sound_stone_defaults(),
after_place_node = function(pos, placer, itemstack)
technic.update_posts(pos, false)
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
on_construct = function(pos)
meta=minetest.env:get_meta(pos)
meta:set_float("postlike",1)
check_post_connections (pos,1)
end,
after_dig_node = function (pos, oldnode, oldmetadata, digger)
technic.update_posts(pos, false)
check_post_connections (pos,0)
end,
})
minetest.register_node(":technic:blast_resistant_concrete", {
description = "Blast-resistant Concrete Block",
tile_images = {"technic_blast_resistant_concrete_block.png",},
groups={cracky=1, level=3, concrete=1},
is_ground_content = true,
groups={cracky=1,level=3},
sounds = default.node_sound_stone_defaults(),
after_place_node = function(pos, player, itemstack)
technic.update_posts(pos, false)
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
on_construct = function(pos)
meta=minetest.env:get_meta(pos)
meta:set_float("postlike",1)
check_post_connections (pos,1)
end,
after_dig_node = function (pos, oldnode, oldmetadata, digger)
technic.update_posts(pos, false)
check_post_connections (pos,0)
end,
})
minetest.register_node(":technic:concrete_post_platform", {
description = "Concrete Post Platform",
tile_images = {"technic_concrete_block.png",},
groups={cracky=1, level=2},
is_ground_content = true,
groups={cracky=1,level=2},
sounds = default.node_sound_stone_defaults(),
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {platform_box}
},
node_box = {
type = "fixed",
fixed = {box_platform}
},
on_place = function (itemstack, placer, pointed_thing)
local node = minetest.get_node(pointed_thing.under)
if not technic.concrete_posts[node.name] then
return minetest.item_place_node(itemstack, placer, pointed_thing)
end
local links = technic.concrete_posts[node.name]
if links[5] ~= 0 then -- The post already has a platform
return minetest.item_place_node(itemstack, placer, pointed_thing)
end
local id = technic.get_post_id({links[1], links[2], links[3], links[4], 1})
minetest.set_node(pointed_thing.under, {name="technic:concrete_post"..id})
itemstack:take_item()
placer:set_wielded_item(itemstack)
return itemstack
fixed = {platform_box}
},
on_place=function (itemstack, placer, pointed_thing)
local node=minetest.env:get_node(pointed_thing.under)
if minetest.get_item_group(node.name, "concrete_post")==0 then
return minetest.item_place_node(itemstack, placer, pointed_thing)
end
local meta=minetest.env:get_meta(pointed_thing.under)
y1=meta:get_float("y1")
platform=meta:get_float("platform")
if y1==1 or platform==1 then
return minetest.item_place_node(itemstack, placer, pointed_thing)
end
y2=meta:get_float("y2")
x1=meta:get_float("x1")
x2=meta:get_float("x2")
z1=meta:get_float("z1")
z2=meta:get_float("z2")
rule=make_post_rule_number(x1,x2,y1,y2,z1,z2,1)
meta:set_float("platform",1)
hacky_swap_posts(pointed_thing.under,"technic:concrete_post"..rule)
itemstack:take_item()
placer:set_wielded_item(itemstack)
return itemstack
end,
})
local function gen_post_nodebox(x1, x2, z1, z2, platform)
local box = {box_center}
if x1 ~= 0 then
table.insert(box, box_x1)
end
if x2 ~= 0 then
table.insert(box, box_x2)
end
if z1 ~= 0 then
table.insert(box, box_z1)
end
if z2 ~= 0 then
table.insert(box, box_z2)
end
if platform ~= 0 then
table.insert(box, box_platform)
end
return box
end
local function dig_post_with_platform(pos, oldnode, oldmetadata)
oldnode.name = "technic:concrete_post0"
minetest.set_node(pos, oldnode)
technic.update_posts(pos, true)
end
minetest.register_node(":technic:concrete_post", {
description = "Concrete Post",
tiles = {"technic_concrete_block.png"},
groups={cracky=1,level=2,concrete_post=1},
sounds = default.node_sound_stone_defaults(),
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = { -0.15 , -0.5 , -0.15 , 0.15 , 0.5 , 0.15 }},
node_box = {
type = "fixed",
fixed = {-0.15 , -0.5 , -0.15 , 0.15 , 0.5 , 0.15 }},
on_construct = function(pos)
meta=minetest.env:get_meta(pos)
meta:set_int("postlike",1)
meta:set_int("platform",0)
meta:set_int("x1",0)
meta:set_int("x2",0)
meta:set_int("y1",0)
meta:set_int("y2",0)
meta:set_int("z1",0)
meta:set_int("z2",0)
check_post_connections (pos,1)
end,
function technic.posts_should_connect(pos)
local node = minetest.get_node(pos)
if technic.concrete_posts[node.name] then
return "post"
elseif minetest.get_item_group(node.name, "concrete") ~= 0 then
return "block"
end
end
after_dig_node = function (pos, oldnode, oldmetadata, digger)
check_post_connections (pos,0)
end,
function technic.get_post_id(links)
return (links[4] * 1) + (links[3] * 2)
+ (links[2] * 4) + (links[1] * 8)
+ (links[5] * 16)
end
})
function technic.update_posts(pos, set, secondrun)
local node = minetest.get_node(pos)
local link_positions = {
{x=pos.x+1, y=pos.y, z=pos.z},
{x=pos.x-1, y=pos.y, z=pos.z},
{x=pos.x, y=pos.y, z=pos.z+1},
{x=pos.x, y=pos.y, z=pos.z-1},
}
local x1,x2,y1,z1,z2
local count=0
local links = {0, 0, 0, 0, 0}
for x1 = 0, 1, 1 do --x-
for x2 = 0, 1, 1 do --x+
for z1 = 0, 1, 1 do --z-
for z2 = 0, 1, 1 do --z+
temp_x1={} temp_x2={} temp_z1={} temp_z2={}
for i, link_pos in pairs(link_positions) do
local connecttype = technic.posts_should_connect(link_pos)
if connecttype then
links[i] = 1
-- Have posts next to us update theirselves,
-- but only once. (We don't want to start an
-- infinite loop of updates)
if not secondrun and connecttype == "post" then
technic.update_posts(link_pos, true, true)
end
end
end
-- We don't want to set ourselves if we have been removed or we are
-- updating a concrete node
if set then
-- Preserve platform
local oldlinks = technic.concrete_posts[node.name]
if oldlinks then
links[5] = oldlinks[5]
end
minetest.set_node(pos, {name="technic:concrete_post"
..technic.get_post_id(links)})
end
end
if x1==1 then temp_x1=post_str_x1 end
if x2==1 then temp_x2=post_str_x2 end
if z1==1 then temp_z1=post_str_z1 end
if z2==1 then temp_z2=post_str_z2 end
for x1 = 0, 1 do
for x2 = 0, 1 do
for z1 = 0, 1 do
for z2 = 0, 1 do
for platform = 0, 1 do
local links = {x1, x2, z1, z2, platform}
local id = technic.get_post_id(links)
technic.concrete_posts["technic:concrete_post"..id] = links
local groups = {cracky=1, level=2, concrete_post=1}
if id ~= 0 then
groups.not_in_creative_inventory = 1
end
local drop = "technic:concrete_post0"
local after_dig_node = function(pos, oldnode, oldmetadata, digger)
technic.update_posts(pos, false)
end
if platform ~= 0 then
drop = "technic:concrete_post_platform"
after_dig_node = function(pos, oldnode, oldmetadata, digger)
dig_post_with_platform(pos, oldnode, oldmetadata)
end
end
minetest.register_node(":technic:concrete_post"..count, {
description = "Concrete Post",
tiles = {"technic_concrete_block.png"},
groups={cracky=1,level=2,not_in_creative_inventory=1,concrete_post=1},
sounds = default.node_sound_stone_defaults(),
drop = "technic:concrete_post",
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {
temp_x1,temp_x2,post_str_y,temp_z1,temp_z2,
}},
minetest.register_node(":technic:concrete_post"..id, {
description = "Concrete Post",
tiles = {"technic_concrete_block.png"},
groups = groups,
sounds = default.node_sound_stone_defaults(),
drop = drop,
paramtype = "light",
sunlight_propagates = true,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = gen_post_nodebox(x1, x2, z1, z2, platform),
node_box = {
type = "fixed",
fixed = {
temp_x1,temp_x2,post_str_y,temp_z1,temp_z2,
}},
after_dig_node = function (pos, oldnode, oldmetadata, digger)
check_post_connections (pos,0)
end,
})
minetest.register_node(":technic:concrete_post"..count+16, {
description = "Concrete Post",
tiles = {"technic_concrete_block.png"},
groups={cracky=1,level=2,not_in_creative_inventory=1,concrete_post=1},
sounds = default.node_sound_stone_defaults(),
drop = "technic:concrete_post_platform",
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {
platform_box,temp_x1,temp_x2,post_str_y,temp_z1,temp_z2,
}},
node_box = {
type = "fixed",
fixed = {
platform_box,temp_x1,temp_x2,post_str_y,temp_z1,temp_z2,
}},
after_dig_node = function (pos, oldnode, oldmetadata, digger)
dig_post_with_platform (pos,oldnode,oldmetadata)
end,
})
count=count+1 end end end end
minetest.register_node(":technic:concrete_post32", {
description = "Concrete Post",
tiles = {"technic_concrete_block.png"},
groups={cracky=1,level=2,not_in_creative_inventory=1,concrete_post=1},
sounds = default.node_sound_stone_defaults(),
drop = "technic:concrete_post",
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {-0.5,-0.3,-0.1,0.5,0.3,0.1},
},
after_place_node = function(pos, placer, itemstack)
technic.update_posts(pos, true)
end,
after_dig_node = after_dig_node,
})
end
end
end
end
node_box = {
type = "fixed",
fixed = {
post_str_x1,post_str_x2,
}},
after_dig_node = function (pos, oldnode, oldmetadata, digger)
check_post_connections (pos,0)
end,
})
minetest.register_node(":technic:concrete_post33", {
description = "Concrete Post",
tiles = {"technic_concrete_block.png"},
groups={cracky=1,level=2,not_in_creative_inventory=1,concrete_post=1},
sounds = default.node_sound_stone_defaults(),
drop = "technic:concrete_post",
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {
post_str_z1,post_str_z2,
}},
node_box = {
type = "fixed",
fixed = {
post_str_z1,post_str_z2,
}},
after_dig_node = function (pos, oldnode, oldmetadata, digger)
check_post_connections (pos,0)
end,
})
minetest.register_node(":technic:concrete_post34", {
description = "Concrete Post",
tiles = {"technic_concrete_block.png"},
groups={cracky=1,level=2,not_in_creative_inventory=1,concrete_post=1},
sounds = default.node_sound_stone_defaults(),
drop = "technic:concrete_post_platform",
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {
platform_box,post_str_x1,post_str_x2,
}},
node_box = {
type = "fixed",
fixed = {
platform_box,post_str_x1,post_str_x2,
}},
after_dig_node = function (pos, oldnode, oldmetadata, digger)
dig_post_with_platform (pos,oldnode,oldmetadata)
end,
})
minetest.register_node(":technic:concrete_post35", {
description = "Concrete Post",
tiles = {"technic_concrete_block.png"},
groups={cracky=1,level=2,not_in_creative_inventory=1,concrete_post=1},
sounds = default.node_sound_stone_defaults(),
drop = "technic:concrete_post_platform",
paramtype = "light",
light_source = 0,
sunlight_propagates = true,
drawtype = "nodebox",
selection_box = {
type = "fixed",
fixed = {
platform_box,post_str_z1,post_str_z2,
}},
node_box = {
type = "fixed",
fixed = {
platform_box,post_str_z1,post_str_z2,
}},
after_dig_node = function (pos, oldnode, oldmetadata, digger)
dig_post_with_platform (pos,oldnode,oldmetadata)
end,
})
dig_post_with_platform = function (pos,oldnode,oldmetadata)
x1=tonumber(oldmetadata.fields["x1"])
x2=tonumber(oldmetadata.fields["x2"])
y1=tonumber(oldmetadata.fields["y1"])
y2=tonumber(oldmetadata.fields["y2"])
z1=tonumber(oldmetadata.fields["z1"])
z2=tonumber(oldmetadata.fields["z2"])
print(dump(x1))
oldmetadata.fields["platform"]="0"
local rule=make_post_rule_number(x1,x2,y1,y2,z1,z2,0)
--print(dump(rule))
oldnode.name="technic:concrete_post"..rule
minetest.env:set_node(pos,oldnode)
meta = minetest.env:get_meta(pos)
meta:from_table(oldmetadata)
end
check_post_connections = function(pos,mode)
local pos1={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
tempx1=0
tempx2=0
tempy1=0
tempy2=0
tempz1=0
tempz2=0
pos1.x=pos1.x+1
if minetest.env:get_meta(pos1):get_int("postlike")==1 then
x2=mode
x1=minetest.env:get_meta(pos1):get_int("x1")
y1=minetest.env:get_meta(pos1):get_int("y1")
y2=minetest.env:get_meta(pos1):get_int("y2")
z1=minetest.env:get_meta(pos1):get_int("z1")
z2=minetest.env:get_meta(pos1):get_int("z2")
platform=minetest.env:get_meta(pos1):get_int("platform")
rule=make_post_rule_number(x1,x2,y1,y2,z1,z2,platform)
hacky_swap_posts(pos1,"technic:concrete_post"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_int("x2",x2)
tempx1=mode
end
pos1.x=pos1.x-2
if minetest.env:get_meta(pos1):get_int("postlike")==1 then
x1=mode
x2=minetest.env:get_meta(pos1):get_int("x2")
y1=minetest.env:get_meta(pos1):get_int("y1")
y2=minetest.env:get_meta(pos1):get_int("y2")
z1=minetest.env:get_meta(pos1):get_int("z1")
z2=minetest.env:get_meta(pos1):get_int("z2")
platform=minetest.env:get_meta(pos1):get_int("platform")
rule=make_post_rule_number(x1,x2,y1,y2,z1,z2,platform)
hacky_swap_posts(pos1,"technic:concrete_post"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_int("x1",x1)
tempx2=mode
end
pos1.x=pos1.x+1
pos1.y=pos1.y+1
if minetest.env:get_meta(pos1):get_int("postlike")==1 then
y2=mode
x1=minetest.env:get_meta(pos1):get_int("x1")
x2=minetest.env:get_meta(pos1):get_int("x2")
y1=minetest.env:get_meta(pos1):get_int("y1")
z1=minetest.env:get_meta(pos1):get_int("z1")
z2=minetest.env:get_meta(pos1):get_int("z2")
platform=minetest.env:get_meta(pos1):get_int("platform")
rule=make_post_rule_number(x1,x2,y1,y2,z1,z2,platform)
hacky_swap_posts(pos1,"technic:concrete_post"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_int("y2",y2)
tempy1=mode
end
pos1.y=pos1.y-2
if minetest.env:get_meta(pos1):get_int("postlike")==1 then
y1=mode
x1=minetest.env:get_meta(pos1):get_int("x1")
x2=minetest.env:get_meta(pos1):get_int("x2")
y2=minetest.env:get_meta(pos1):get_int("y2")
z1=minetest.env:get_meta(pos1):get_int("z1")
z2=minetest.env:get_meta(pos1):get_int("z2")
platform=minetest.env:get_meta(pos1):get_int("platform")
rule=make_post_rule_number(x1,x2,y1,y2,z1,z2,platform)
hacky_swap_posts(pos1,"technic:concrete_post"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_int("y1",y1)
tempy2=mode
end
pos1.y=pos1.y+1
pos1.z=pos1.z+1
if minetest.env:get_meta(pos1):get_int("postlike")==1 then
z2=mode
x1=minetest.env:get_meta(pos1):get_int("x1")
x2=minetest.env:get_meta(pos1):get_int("x2")
y1=minetest.env:get_meta(pos1):get_int("y1")
y2=minetest.env:get_meta(pos1):get_int("y2")
z1=minetest.env:get_meta(pos1):get_int("z1")
platform=minetest.env:get_meta(pos1):get_int("platform")
rule=make_post_rule_number(x1,x2,y1,y2,z1,z2,platform)
hacky_swap_posts(pos1,"technic:concrete_post"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_int("z2",z2)
tempz1=mode
end
pos1.z=pos1.z-2
if minetest.env:get_meta(pos1):get_int("postlike")==1 then
z1=mode
x1=minetest.env:get_meta(pos1):get_int("x1")
x2=minetest.env:get_meta(pos1):get_int("x2")
y1=minetest.env:get_meta(pos1):get_int("y1")
y2=minetest.env:get_meta(pos1):get_int("y2")
z2=minetest.env:get_meta(pos1):get_int("z2")
platform=minetest.env:get_meta(pos1):get_int("platform")
rule=make_post_rule_number(x1,x2,y1,y2,z1,z2,platform)
hacky_swap_posts(pos1,"technic:concrete_post"..rule)
meta=minetest.env:get_meta(pos1)
meta:set_int("z1",z1)
tempz2=mode
end
pos1.z=pos1.z+1
if mode==1 then
meta=minetest.env:get_meta(pos)
meta:set_int("x1",tempx1)
meta:set_int("x2",tempx2)
meta:set_int("y1",tempy1)
meta:set_int("y2",tempy2)
meta:set_int("z1",tempz1)
meta:set_int("z2",tempz2)
rule=make_post_rule_number(tempx1,tempx2,tempy1,tempy2,tempz1,tempz2,0)
hacky_swap_posts(pos,"technic:concrete_post"..rule)
end
end
function make_post_rule_number (x1,x2,y1,y2,z1,z2,platform)
local tempy=y1+y2
local tempx=x1+x2
local tempz=z1+z2
if platform==0 then
if tempy==0 and tempx==0 and tempz==0 then return 0 end
if x1==1 and x2==1 and tempz==0 and tempy==0 then return 32 end
if z1==1 and z2==1 and tempx==0 and tempy==0 then return 33 end
return z2+z1*2+x2*4+x1*8
else
if tempy==0 and tempx==0 and tempz==0 then return 16 end
if x1==1 and x2==1 and tempz==0 and tempy==0 then return 34 end
if z1==1 and z2==1 and tempx==0 and tempy==0 then return 35 end
return z2+z1*2+x2*4+x1*8+16
end
end
function hacky_swap_posts(pos,name)
local node = minetest.env:get_node(pos)
if node.name == "technic:concrete" or node.name == "technic:blast_resistant_concrete" then
return nil
end
local meta = minetest.env:get_meta(pos)
local meta0 = meta:to_table()
node.name = name
local meta0 = meta:to_table()
minetest.env:set_node(pos,node)
meta = minetest.env:get_meta(pos)
meta:from_table(meta0)
return 1
end

1
framedglass/depends.txt Normal file
View File

@ -0,0 +1 @@
default

107
framedglass/init.lua Normal file
View File

@ -0,0 +1,107 @@
-- Minetest 0.4.5 mod: framedglass
minetest.register_craft({
output = 'framedglass:wooden_framed_glass 4',
recipe = {
{'default:glass', 'default:glass', 'default:stick'},
{'default:glass', 'default:glass', 'default:stick'},
{'default:stick', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'framedglass:steel_framed_glass 4',
recipe = {
{'default:glass', 'default:glass', 'default:steel_ingot'},
{'default:glass', 'default:glass', 'default:steel_ingot'},
{'default:steel_ingot', 'default:steel_ingot', ''},
}
})
minetest.register_craft({
output = 'framedglass:wooden_framed_obsidian_glass 4',
recipe = {
{'default:obsidian_glass', 'default:obsidian_glass', 'default:stick'},
{'default:obsidian_glass', 'default:obsidian_glass', 'default:stick'},
{'default:stick', 'default:stick', ''},
}
})
minetest.register_craft({
output = 'framedglass:steel_framed_obsidian_glass 4',
recipe = {
{'default:obsidian_glass', 'default:obsidian_glass', 'default:steel_ingot'},
{'default:obsidian_glass', 'default:obsidian_glass', 'default:steel_ingot'},
{'default:steel_ingot', 'default:steel_ingot', ''},
}
})
minetest.register_node("framedglass:wooden_framed_glass", {
description = "Wooden-framed Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_wooden_frame.png","framedglass_glass_face_streaks.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("framedglass:steel_framed_glass", {
description = "Steel-framed Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_steel_frame.png","framedglass_glass_face_streaks.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("framedglass:wooden_framed_obsidian_glass", {
description = "Wooden-framed Obsidian Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_wooden_frame.png","framedglass_glass_face_clean.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("framedglass:steel_framed_obsidian_glass", {
description = "Steel-framed Obsidian Glass",
drawtype = "glasslike_framed",
tiles = {"framedglass_steel_frame.png","framedglass_glass_face_clean.png"},
paramtype = "light",
sunlight_propagates = true,
groups = {cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
function add_coloured_framedglass(name, desc, dye, texture)
minetest.register_node( "framedglass:steel_framed_obsidian_glass"..name, {
description = "Steel-framed "..desc.." Obsidian Glass",
tiles = {"framedglass_steel_frame.png",texture},
drawtype = "glasslike_framed",
paramtype = "light",
sunlight_propagates = true,
is_ground_content = true,
use_texture_alpha = true,
groups = {cracky=3},
sounds = default.node_sound_glass_defaults(),
})
end
add_coloured_framedglass ("red","Red","","framedglass_redglass.png")
add_coloured_framedglass ("green","Green","","framedglass_greenglass.png")
add_coloured_framedglass ("blue","Blue","","framedglass_blueglass.png")
add_coloured_framedglass ("cyan","Cyan","","framedglass_cyanglass.png")
add_coloured_framedglass ("darkgreen","Dark Green","","framedglass_darkgreenglass.png")
add_coloured_framedglass ("violet","Violet","","framedglass_violetglass.png")
add_coloured_framedglass ("pink","Pink","","framedglass_pinkglass.png")
add_coloured_framedglass ("yellow","Yellow","","framedglass_yellowglass.png")
add_coloured_framedglass ("orange","Orange","","framedglass_orangeglass.png")
add_coloured_framedglass ("brown","Brown","","framedglass_brownglass.png")
add_coloured_framedglass ("white","White","","framedglass_whiteglass.png")
add_coloured_framedglass ("grey","Grey","","framedglass_greyglass.png")
add_coloured_framedglass ("darkgrey","Dark Grey","","framedglass_darkgreyglass.png")
add_coloured_framedglass ("black","Black","","framedglass_blackglass.png")

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 951 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

View File

@ -1,25 +1,42 @@
technic.config = {}
local worldpath = minetest.get_worldpath()
technic.config.loaded = {}
technic.config = Settings(worldpath.."/technic.conf")
local conf_table = technic.config:to_table()
local defaults = {
technic.config.default = {
enable_mining_drill = "true",
enable_mining_laser = "true",
enable_flashlight = "true",
enable_item_drop = "true",
enable_item_pickup = "true",
enable_rubber_tree_generation = "true",
enable_marble_generation = "true",
enable_granite_generation = "true",
enable_granite_generation = "true"
}
for k, v in pairs(defaults) do
if conf_table[k] == nil then
technic.config:set(k, v)
function technic.config:load(filename)
file, error = io.open(filename, "r")
if error then return end
local line = file:read("*l")
while line do
local found, _, setting, value = line:find("^([^#%s=]+)%s?=%s?([^%s#]+)")
if found then
self.loaded[setting] = value
end
line = file:read("*l")
end
file:close()
end
technic.config:load(minetest.get_worldpath().."/technic.conf")
function technic.config:get(setting)
if self.loaded[setting] then
return self.loaded[setting]
else
return self.default[setting]
end
end
-- Create the config file if it doesn't exist
technic.config:write()
function technic.config:getBool(setting)
return string.lower(self:get(setting)) == "true"
end

View File

@ -1,169 +0,0 @@
-- tubes crafting recipes
minetest.register_craft({
output = 'pipeworks:tube_000000 9',
recipe = {
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
}
})
minetest.register_craft({
output = 'pipeworks:mese_tube_000000',
recipe = {
{'default:mese_crystal_fragment', 'pipeworks:tube_000000', 'default:mese_crystal_fragment'},
}
})
minetest.register_craft({
output = 'pipeworks:accelerator_tube_000000',
recipe = {
{'technic:copper_coil', 'pipeworks:tube_000000', 'technic:copper_coil'},
}
})
minetest.register_craft({
output = 'pipeworks:detector_tube_off_000000',
recipe = {
{'mesecons:mesecon', 'pipeworks:tube_000000', 'mesecons:mesecon'},
}
})
minetest.register_craft({
output = 'pipeworks:sand_tube_000000',
recipe = {
{'default:sand', 'pipeworks:tube_000000', 'default:sand'},
}
})
minetest.register_craft({
output = 'pipeworks:mese_sand_tube_000000',
recipe = {
{'default:mese_crystal_fragment', 'pipeworks:sand_tube_000000', 'default:mese_crystal_fragment'},
}
})
minetest.register_craft({
output = 'pipeworks:teleport_tube_000000',
recipe = {
{'default:mese_crystal', 'technic:copper_coil', 'default:mese_crystal'},
{'pipeworks:tube_000000', 'technic:control_logic_unit', 'pipeworks:tube_000000'},
{'default:mese_crystal', 'technic:copper_coil', 'default:mese_crystal'},
}
})
minetest.register_craft({
output = 'technic:diamond_drill_head',
recipe = {
{'technic:stainless_steel_ingot', 'default:diamond', 'technic:stainless_steel_ingot'},
{'default:diamond', '', 'default:diamond'},
{'technic:stainless_steel_ingot', 'default:diamond', 'technic:stainless_steel_ingot'},
}
})
minetest.register_craft({
output = 'technic:green_energy_crystal',
recipe = {
{'default:gold_ingot', 'technic:battery', 'dye:green'},
{'technic:battery', 'technic:red_energy_crystal', 'technic:battery'},
{'dye:green', 'technic:battery', 'default:gold_ingot'},
}
})
minetest.register_craft({
output = 'technic:blue_energy_crystal',
recipe = {
{'default:gold_ingot', 'technic:battery', 'dye:blue'},
{'technic:battery', 'technic:green_energy_crystal', 'technic:battery'},
{'dye:blue', 'technic:battery', 'default:gold_ingot'},
}
})
minetest.register_craft({
output = 'technic:red_energy_crystal',
recipe = {
{'default:gold_ingot', 'technic:battery', 'dye:red'},
{'technic:battery', 'default:diamondblock', 'technic:battery'},
{'dye:red', 'technic:battery', 'default:gold_ingot'},
}
})
minetest.register_craft({
output = 'technic:fine_copper_wire 2',
recipe = {
{'', 'default:copper_ingot', ''},
{'', 'default:copper_ingot', ''},
{'', 'default:copper_ingot', ''},
}
})
minetest.register_craft({
output = 'technic:copper_coil 1',
recipe = {
{'technic:fine_copper_wire', 'default:steel_ingot', 'technic:fine_copper_wire'},
{'default:steel_ingot', '', 'default:steel_ingot'},
{'technic:fine_copper_wire', 'default:steel_ingot', 'technic:fine_copper_wire'},
}
})
minetest.register_craft({
output = 'technic:motor',
recipe = {
{'default:steel_ingot', 'technic:copper_coil', 'default:steel_ingot'},
{'default:steel_ingot', 'technic:copper_coil', 'default:steel_ingot'},
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
}
})
minetest.register_craft({
output = 'technic:lv_transformer',
recipe = {
{'default:iron_lump', 'default:iron_lump', 'default:iron_lump'},
{'technic:copper_coil', 'default:iron_lump', 'technic:copper_coil'},
{'default:iron_lump', 'default:iron_lump', 'default:iron_lump'},
}
})
minetest.register_craft({
output = 'technic:mv_transformer',
recipe = {
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
{'technic:copper_coil', 'default:steel_ingot', 'technic:copper_coil'},
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
}
})
minetest.register_craft({
output = 'technic:hv_transformer',
recipe = {
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
{'technic:copper_coil', 'technic:stainless_steel_ingot', 'technic:copper_coil'},
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
}
})
minetest.register_craft({
output = 'technic:control_logic_unit',
recipe = {
{'', 'default:gold_ingot', ''},
{'default:copper_ingot', 'technic:silicon_wafer', 'default:copper_ingot'},
{'', 'default:copper_ingot', ''},
}
})
minetest.register_craft({
output = 'technic:mixed_metal_ingot 9',
recipe = {
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
{'default:bronze_ingot', 'default:bronze_ingot', 'default:bronze_ingot'},
{'moreores:tin_ingot', 'moreores:tin_ingot', 'moreores:tin_ingot'},
}
})
minetest.register_craft({
output = 'technic:carbon_cloth',
recipe = {
{'technic:graphite', 'technic:graphite', 'technic:graphite'}
}
})

View File

@ -2,4 +2,4 @@ default
moreores
pipeworks
mesecons
mesecons_mvps?
moretrees

View File

@ -4,25 +4,26 @@
technic = {}
local load_start = os.clock()
local modpath = minetest.get_modpath("technic")
technic.modpath = modpath
technic.dprint = function(string)
if technic.DBG == 1 then
print(string)
end
end
-- Read configuration file
--Read technic config file
dofile(modpath.."/config.lua")
-- Helper functions
--helper functions
dofile(modpath.."/helpers.lua")
-- Items
--items
dofile(modpath.."/items.lua")
-- Craft recipes for items
dofile(modpath.."/crafts.lua")
-- Register functions
dofile(modpath.."/register.lua")
dofile(modpath.."/register_machine_and_tool.lua")
-- Machines
dofile(modpath.."/machines/init.lua")
@ -30,31 +31,24 @@ dofile(modpath.."/machines/init.lua")
-- Tools
dofile(modpath.."/tools/init.lua")
-- Aliases for legacy node/item names
dofile(modpath.."/legacy.lua")
function has_locked_chest_privilege(meta, player)
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
if player:get_player_name() ~= meta:get_string("owner") then
return false
end
return true
end
-- Swap nodes out. Return the node name.
function hacky_swap_node(pos, name)
local node = minetest.get_node(pos)
if node.name ~= name then
local meta = minetest.get_meta(pos)
local meta_table = meta:to_table()
node.name = name
minetest.set_node(pos, node)
meta = minetest.get_meta(pos)
meta:from_table(meta_table)
end
return node.name
function hacky_swap_node(pos,name)
local node = minetest.env:get_node(pos)
if node.name ~= name then
local meta = minetest.env:get_meta(pos)
local meta0 = meta:to_table()
node.name = name
minetest.env:set_node(pos,node)
meta = minetest.env:get_meta(pos)
meta:from_table(meta0)
end
return node.name
end
if minetest.setting_get("log_mod") then
print("[Technic] Loaded in "..tostring(os.clock() - load_start).."s")
end

View File

@ -1,69 +1,131 @@
minetest.register_craftitem( "technic:silicon_wafer", {
description = "Silicon Wafer",
inventory_image = "technic_silicon_wafer.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craftitem( "technic:doped_silicon_wafer", {
description = "Doped Silicon Wafer",
inventory_image = "technic_doped_silicon_wafer.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craftitem("technic:enriched_uranium", {
minetest.register_craftitem( "technic:enriched_uranium", {
description = "Enriched Uranium",
inventory_image = "technic_enriched_uranium.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craftitem("technic:uranium_fuel", {
description = "Uranium Fuel",
inventory_image = "technic_uranium_fuel.png",
-- tubes crafting recipes
minetest.register_craft({
output = 'pipeworks:tube_000000 9',
recipe = {
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
{'technic:stainless_steel_ingot', 'default:glass', 'technic:stainless_steel_ingot'},
}
})
minetest.register_craft({
output = 'pipeworks:mese_tube_000000',
recipe = {
{'default:mese_crystal_fragment', 'pipeworks:tube_000000', 'default:mese_crystal_fragment'},
}
})
minetest.register_craft({
output = 'pipeworks:accelerator_tube_000000',
recipe = {
{'technic:copper_coil', 'pipeworks:tube_000000', 'technic:copper_coil'},
}
})
minetest.register_craft({
output = 'pipeworks:detector_tube_off_000000',
recipe = {
{'mesecons:mesecon', 'pipeworks:tube_000000', 'mesecons:mesecon'},
}
})
minetest.register_craft({
output = 'pipeworks:sand_tube_000000',
recipe = {
{'default:sand', 'pipeworks:tube_000000', 'default:sand'},
}
})
minetest.register_craft({
output = 'pipeworks:mese_sand_tube_000000',
recipe = {
{'default:mese_crystal_fragment', 'pipeworks:sand_tube_000000', 'default:mese_crystal_fragment'},
}
})
minetest.register_craft({
output = 'pipeworks:teleport_tube_000000',
recipe = {
{'default:mese_crystal', 'technic:copper_coil', 'default:mese_crystal'},
{'pipeworks:tube_000000', 'technic:control_logic_unit', 'pipeworks:tube_000000'},
{'default:mese_crystal', 'technic:copper_coil', 'default:mese_crystal'},
}
})
minetest.register_craftitem( "technic:diamond_drill_head", {
description = "Diamond Drill Head",
inventory_image = "technic_diamond_drill_head.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_tool("technic:blue_energy_crystal", {
description = "Blue Energy Crystal",
inventory_image = minetest.inventorycube(
"technic_diamond_block_blue.png",
"technic_diamond_block_blue.png",
"technic_diamond_block_blue.png"),
tool_capabilities = {
max_drop_level = 0,
groupcaps = {
fleshy = {times={}, uses=10000, maxlevel=0}
}
minetest.register_craft({
output = 'technic:diamond_drill_head',
recipe = {
{'technic:stainless_steel_ingot', 'default:diamond', 'technic:stainless_steel_ingot'},
{'default:diamond', '', 'default:diamond'},
{'technic:stainless_steel_ingot', 'default:diamond', 'technic:stainless_steel_ingot'},
}
})
})
minetest.register_tool("technic:green_energy_crystal", {
description = "Green Energy Crystal",
inventory_image = minetest.inventorycube(
"technic_diamond_block_green.png",
"technic_diamond_block_green.png",
"technic_diamond_block_green.png"),
tool_capabilities = {
max_drop_level = 0,
groupcaps = {
fleshy = {times={}, uses=10000, maxlevel=0}
}
minetest.register_craft({
output = 'technic:green_energy_crystal',
recipe = {
{'default:gold_ingot', 'technic:battery', 'dye:green'},
{'technic:battery', 'technic:red_energy_crystal', 'technic:battery'},
{'dye:green', 'technic:battery', 'default:gold_ingot'},
}
})
})
minetest.register_tool("technic:red_energy_crystal", {
description = "Red Energy Crystal",
inventory_image = minetest.inventorycube(
"technic_diamond_block_red.png",
"technic_diamond_block_red.png",
"technic_diamond_block_red.png"),
tool_capabilities = {
max_drop_level = 0,
groupcaps = {
fleshy = {times={}, uses=10000, maxlevel=0}
}
minetest.register_craft({
output = 'technic:blue_energy_crystal',
recipe = {
{'default:gold_ingot', 'technic:battery', 'dye:blue'},
{'technic:battery', 'technic:green_energy_crystal', 'technic:battery'},
{'dye:blue', 'technic:battery', 'default:gold_ingot'},
}
})
})
minetest.register_craft({
output = 'technic:red_energy_crystal',
recipe = {
{'default:gold_ingot', 'technic:battery', 'dye:red'},
{'technic:battery', 'default:diamondblock', 'technic:battery'},
{'dye:red', 'technic:battery', 'default:gold_ingot'},
}
})
minetest.register_tool("technic:blue_energy_crystal",
{description = "Blue Energy Crystal",
inventory_image = minetest.inventorycube("technic_diamond_block_blue.png", "technic_diamond_block_blue.png", "technic_diamond_block_blue.png"),
tool_capabilities = {load=0,max_drop_level=0, groupcaps={fleshy={times={}, uses=10000, maxlevel=0}}}})
minetest.register_tool("technic:green_energy_crystal",
{description = "Green Energy Crystal",
inventory_image = minetest.inventorycube("technic_diamond_block_green.png", "technic_diamond_block_green.png", "technic_diamond_block_green.png"),
tool_capabilities = {load=0,max_drop_level=0, groupcaps={fleshy={times={}, uses=10000, maxlevel=0}}}})
minetest.register_tool("technic:red_energy_crystal",
{description = "Red Energy Crystal",
inventory_image = minetest.inventorycube("technic_diamond_block_red.png", "technic_diamond_block_red.png", "technic_diamond_block_red.png"),
tool_capabilities = {load=0,max_drop_level=0, groupcaps={fleshy={times={}, uses=10000, maxlevel=0}}}})
minetest.register_craftitem( "technic:fine_copper_wire", {
@ -72,22 +134,43 @@ minetest.register_craftitem( "technic:fine_copper_wire", {
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
output = 'technic:fine_copper_wire 2',
recipe = {
{'', 'default:copper_ingot', ''},
{'', 'default:copper_ingot', ''},
{'', 'default:copper_ingot', ''},
}
})
minetest.register_craftitem( "technic:copper_coil", {
description = "Copper Coil",
inventory_image = "technic_copper_coil.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
output = 'technic:copper_coil 1',
recipe = {
{'technic:fine_copper_wire', 'default:steel_ingot', 'technic:fine_copper_wire'},
{'default:steel_ingot', '', 'default:steel_ingot'},
{'technic:fine_copper_wire', 'default:steel_ingot', 'technic:fine_copper_wire'},
}
})
minetest.register_craftitem( "technic:motor", {
description = "Electric Motor",
inventory_image = "technic_motor.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craftitem( "technic:lv_transformer", {
description = "Low Voltage Transformer",
inventory_image = "technic_lv_transformer.png",
on_place_on_ground = minetest.craftitem_place_item,
minetest.register_craft({
output = 'technic:motor',
recipe = {
{'default:steel_ingot', 'technic:copper_coil', 'default:steel_ingot'},
{'default:steel_ingot', 'technic:copper_coil', 'default:steel_ingot'},
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
}
})
minetest.register_craftitem( "technic:lv_transformer", {
@ -95,30 +178,91 @@ minetest.register_craftitem( "technic:lv_transformer", {
inventory_image = "technic_lv_transformer.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
output = 'technic:lv_transformer',
recipe = {
{'default:iron_lump', 'default:iron_lump', 'default:iron_lump'},
{'technic:copper_coil', 'default:iron_lump', 'technic:copper_coil'},
{'default:iron_lump', 'default:iron_lump', 'default:iron_lump'},
}
})
minetest.register_craftitem( "technic:lv_transformer", {
description = "Low Voltage Transformer",
inventory_image = "technic_lv_transformer.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
output = 'technic:lv_transformer',
recipe = {
{'default:iron_lump', 'default:iron_lump', 'default:iron_lump'},
{'technic:copper_coil', 'default:iron_lump', 'technic:copper_coil'},
{'default:iron_lump', 'default:iron_lump', 'default:iron_lump'},
}
})
minetest.register_craftitem( "technic:mv_transformer", {
description = "Medium Voltage Transformer",
inventory_image = "technic_mv_transformer.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
output = 'technic:mv_transformer',
recipe = {
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
{'technic:copper_coil', 'default:steel_ingot', 'technic:copper_coil'},
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
}
})
minetest.register_craftitem( "technic:hv_transformer", {
description = "High Voltage Transformer",
inventory_image = "technic_hv_transformer.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
output = 'technic:hv_transformer',
recipe = {
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
{'technic:copper_coil', 'technic:stainless_steel_ingot', 'technic:copper_coil'},
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
}
})
minetest.register_craftitem( "technic:control_logic_unit", {
description = "Control Logic Unit",
inventory_image = "technic_control_logic_unit.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
output = 'technic:control_logic_unit',
recipe = {
{'', 'default:gold_ingot', ''},
{'default:copper_ingot', 'technic:silicon_wafer', 'default:copper_ingot'},
{'', 'default:copper_ingot', ''},
}
})
minetest.register_craftitem("technic:mixed_metal_ingot", {
description = "Mixed Metal Ingot",
inventory_image = "technic_mixed_metal_ingot.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
output = 'technic:mixed_metal_ingot 2',
recipe = {
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
{'default:bronze_ingot', 'default:bronze_ingot', 'default:bronze_ingot'},
{'moreores:tin_ingot', 'moreores:tin_ingot', 'moreores:tin_ingot'},
}
})
minetest.register_craftitem("technic:composite_plate", {
description = "Composite Plate",
inventory_image = "technic_composite_plate.png",
@ -149,3 +293,10 @@ minetest.register_craftitem("technic:carbon_cloth", {
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
output = 'technic:carbon_cloth',
recipe = {
{'technic:graphite', 'technic:graphite', 'technic:graphite'}
}
})

View File

@ -1,30 +0,0 @@
-- Aliases to convert from legacy node/item names
technic.legacy_nodenames = {
["technic:alloy_furnace"] = "technic:lv_alloy_furnace",
["technic:alloy_furnace_active"] = "technic:lv_alloy_furnace_active",
["technic:battery_box"] = "technic:lv_battery_box0",
["technic:battery_box1"] = "technic:lv_battery_box1",
["technic:battery_box2"] = "technic:lv_battery_box2",
["technic:battery_box3"] = "technic:lv_battery_box3",
["technic:battery_box4"] = "technic:lv_battery_box4",
["technic:battery_box5"] = "technic:lv_battery_box5",
["technic:battery_box6"] = "technic:lv_battery_box6",
["technic:battery_box7"] = "technic:lv_battery_box7",
["technic:battery_box8"] = "technic:lv_battery_box8",
["technic:electric_furnace"] = "technic:lv_electric_furnace",
["technic:electric_furnace_active"] = "technic:lv_electric_furnace_active",
["technic:grinder"] = "technic:lv_grinder",
["technic:grinder_active"] = "technic:lv_grinder_active",
["technic:hv_battery_box"] = "technic:hv_battery_box0",
["technic:hv_cable"] = "technic:hv_cable0",
["technic:lv_cable"] = "technic:lv_cable0",
["technic:mv_cable"] = "technic:mv_cable0",
["technic:mv_battery_box"] = "technic:mv_battery_box0",
}
for old, new in pairs(technic.legacy_nodenames) do
minetest.register_alias(old, new)
end

View File

@ -1,19 +0,0 @@
-- HV battery box
minetest.register_craft({
output = 'technic:hv_battery_box0',
recipe = {
{'technic:mv_battery_box0', 'technic:mv_battery_box0', 'technic:mv_battery_box0'},
{'technic:mv_battery_box0', 'technic:hv_transformer', 'technic:mv_battery_box0'},
{'', 'technic:hv_cable0', ''},
}
})
technic.register_battery_box({
tier = "HV",
max_charge = 1500000,
charge_rate = 100000,
discharge_rate = 400000,
charge_step = 10000,
discharge_step = 40000,
})

View File

@ -1,12 +0,0 @@
minetest.register_craft({
output = 'technic:hv_cable0 3',
recipe = {
{'technic:rubber', 'technic:rubber', 'technic:rubber'},
{'technic:mv_cable0', 'technic:mv_cable0', 'technic:mv_cable0'},
{'technic:rubber', 'technic:rubber', 'technic:rubber'},
}
})
technic.register_cable("HV", 3/16)

View File

@ -1,206 +0,0 @@
-- Forcefield mod by ShadowNinja
-- Modified by kpoppel
--
-- Forcefields are powerful barriers but they consume huge amounts of power.
-- Forcefield Generator is a HV machine.
-- How expensive is the generator?
-- Leaves room for upgrades lowering the power drain?
local forcefield_power_drain = 10
local forcefield_step_interval = 1
minetest.register_craft({
output = 'technic:forcefield_emitter_off',
recipe = {
{'default:mese', 'technic:deployer_off', 'default:mese' },
{'technic:deployer_off', 'technic:motor', 'technic:deployer_off'},
{'default:mese', 'technic:deployer_off', 'default:mese' },
}
})
-- Idea: Let forcefields have different colors by upgrade slot.
-- Idea: Let forcefields add up by detecting if one hits another.
-- ___ __
-- / \/ \
-- | |
-- \___/\___/
local function update_forcefield(pos, range, active)
local vm = VoxelManip()
local p1 = {x = pos.x-range, y = pos.y-range, z = pos.z-range}
local p2 = {x = pos.x+range, y = pos.y+range, z = pos.z+range}
local MinEdge, MaxEdge = vm:read_from_map(p1, p2)
local area = VoxelArea:new({MinEdge = MinEdge, MaxEdge = MaxEdge})
local data = vm:get_data()
local c_air = minetest.get_content_id("air")
local c_field = minetest.get_content_id("technic:forcefield")
for z=-range, range do
for y=-range, range do
local vi = area:index(pos.x+(-range), pos.y+y, pos.z+z)
for x=-range, range do
if x*x+y*y+z*z <= range * range + range and
x*x+y*y+z*z >= (range-1) * (range-1) + (range-1) then
if active and data[vi] == c_air then
data[vi] = c_field
elseif not active and data[vi] == c_field then
data[vi] = c_air
end
end
vi = vi + 1
end
end
end
vm:set_data(data)
vm:update_liquids()
vm:write_to_map()
vm:update_map()
end
local get_forcefield_formspec = function(range)
return "size[3,1.5]"..
"field[1,0.5;2,1;range;Range;"..range.."]"..
"button[0,1;3,1;toggle;Enable/Disable]"
end
local forcefield_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local range = fields.range
if fields.toggle then
if meta:get_int("enabled") == 1 then
meta:set_int("enabled", 0)
else
meta:set_int("enabled", 1)
end
end
-- Smallest field is 5. Anything less is asking for trouble.
-- Largest is 20. It is a matter of pratical node handling.
-- At the maximim range updating the forcefield takes about 0.2s
range = math.max(range, 5)
range = math.min(range, 20)
if meta:get_int("range") ~= range then
update_forcefield(pos, meta:get_int("range"), false)
meta:set_int("range", range)
meta:set_string("formspec", get_forcefield_formspec(range))
end
end
local mesecons = {
effector = {
action_on = function(pos, node)
minetest.get_meta(pos):set_int("enabled", 0)
end,
action_off = function(pos, node)
minetest.get_meta(pos):set_int("enabled", 1)
end
}
}
minetest.register_node("technic:forcefield_emitter_off", {
description = "Forcefield emitter",
tiles = {"technic_forcefield_emitter_off.png"},
groups = {cracky = 1},
on_receive_fields = forcefield_receive_fields,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("HV_EU_input", 0)
meta:set_int("HV_EU_demand", 0)
meta:set_int("range", 10)
meta:set_int("enabled", 0)
meta:set_string("formspec", get_forcefield_formspec(10))
meta:set_string("infotext", "Forcefield emitter");
end,
mesecons = mesecons
})
minetest.register_node("technic:forcefield_emitter_on", {
description = "Forcefield emitter on (you hacker you)",
tiles = {"technic_forcefield_emitter_on.png"},
groups = {cracky = 1, not_in_creative_inventory=1},
drop = "technic:forcefield_emitter_off",
on_receive_fields = forcefield_receive_fields,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local range = meta:get_int("range")
meta:set_string("formspec", get_forcefield_formspec(range))
end,
on_destruct = function(pos)
local meta = minetest.get_meta(pos)
update_forcefield(pos, meta:get_int("range"), false)
end,
mesecons = mesecons
})
minetest.register_node("technic:forcefield", {
description = "Forcefield (you hacker you)",
sunlight_propagates = true,
drawtype = "glasslike",
groups = {not_in_creative_inventory=1, unbreakable=1},
paramtype = "light",
light_source = 15,
drop = '',
tiles = {{
name = "technic_forcefield_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.0,
},
}},
})
minetest.register_abm({
nodenames = {"technic:forcefield_emitter_on", "technic:forcefield_emitter_off"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local eu_input = meta:get_int("HV_EU_input")
local eu_demand = meta:get_int("HV_EU_demand")
local enabled = meta:get_int("enabled")
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "HV")
local power_requirement = math.floor(
4 * math.pi * math.pow(meta:get_int("range"), 2)
) * forcefield_power_drain
if meta:get_int("enabled") == 0 then
if node.name == "technic:forcefield_emitter_on" then
meta:set_int("HV_EU_demand", 0)
update_forcefield(pos, meta:get_int("range"), false)
hacky_swap_node(pos, "technic:forcefield_emitter_off")
meta:set_string("infotext", "Forcefield Generator Disabled")
return
end
elseif eu_input < power_requirement then
meta:set_string("infotext", "Forcefield Generator Unpowered")
if node.name == "technic:forcefield_emitter_on" then
update_forcefield(pos, meta:get_int("range"), false)
hacky_swap_node(pos, "technic:forcefield_emitter_off")
end
elseif eu_input >= power_requirement then
if node.name == "technic:forcefield_emitter_off" then
hacky_swap_node(pos, "technic:forcefield_emitter_on")
meta:set_string("infotext", "Forcefield Generator Active")
end
update_forcefield(pos, meta:get_int("range"), true)
end
meta:set_int("HV_EU_demand", power_requirement)
end
})
if minetest.get_modpath("mesecons_mvps") then
mesecon:register_mvps_stopper("technic:forcefield")
end
-- TODO: Register a stopper for frames
technic.register_machine("HV", "technic:forcefield_emitter_on", technic.receiver)
technic.register_machine("HV", "technic:forcefield_emitter_off", technic.receiver)

View File

@ -1,12 +0,0 @@
technic.register_tier("HV", "High Voltage")
local path = technic.modpath.."/machines/HV"
dofile(path.."/cables.lua")
dofile(path.."/quarry.lua")
dofile(path.."/forcefield.lua")
dofile(path.."/battery_box.lua")
dofile(path.."/solar_array.lua")
dofile(path.."/nuclear_reactor.lua")

View File

@ -1,200 +0,0 @@
minetest.register_craft({
recipe = {
{"default:steelblock", "pipeworks:filter", "default:steelblock"},
{"default:steelblock", "technic:motor", "default:steelblock"},
{"default:steelblock", "technic:diamond_drill_head", "default:steelblock"}},
output = "technic:quarry",
})
local quarry_dig_above_nodes = 3 -- How far above the quarry we will dig nodes
local quarry_max_depth = 100
local function get_quarry_formspec(size)
return "size[3,1.5]"..
"field[1,0.5;2,1;size;Radius;"..size.."]"..
"button[0,1;3,1;toggle;Enable/Disable]"
end
local function quarry_receive_fields(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local size = tonumber(fields.size)
if fields.toggle then
if meta:get_int("enabled") == 0 then
meta:set_int("enabled", 1)
else
meta:set_int("enabled", 0)
end
end
-- Smallest size is 2. Anything less is asking for trouble.
-- Largest is 8. It is a matter of pratical node handling.
size = math.max(size, 2)
size = math.min(size, 8)
if meta:get_int("size") ~= size then
meta:set_int("size", size)
meta:set_string("formspec", get_quarry_formspec(size))
end
end
local function get_quarry_center(pos, size)
local node = minetest.get_node(pos)
local back_dir = minetest.facedir_to_dir(node.param2)
local relative_center = vector.multiply(back_dir, size + 1)
local center = vector.add(pos, relative_center)
return center
end
local function gen_next_digpos(center, digpos, size)
digpos.x = digpos.x + 1
if digpos.x > center.x + size then
digpos.x = center.x - size
digpos.z = digpos.z + 1
end
if digpos.z > center.z + size then
digpos.x = center.x - size
digpos.z = center.z - size
digpos.y = digpos.y - 1
end
end
local function find_next_digpos(data, area, center, dig_y, size)
local c_air = minetest.get_content_id("air")
for y = center.y + quarry_dig_above_nodes, dig_y - 1, -1 do
for z = center.z - size, center.z + size do
for x = center.x - size, center.x + size do
if data[area:index(x, y, z)] ~= c_air then
return vector.new(x, y, z)
end
end
end
end
end
local function quarry_dig(pos, center, size)
local meta = minetest.get_meta(pos)
local drops = {}
local dig_y = meta:get_int("dig_y")
local owner = meta:get_int("owner")
local vm = VoxelManip()
local p1 = vector.new(
center.x - size,
center.y + quarry_dig_above_nodes,
center.z - size)
local p2 = vector.new(
center.x + size,
dig_y - 1, -- One node lower in case we have finished the current layer
center.z + size)
local e1, e2 = vm:read_from_map(p1, p2)
local area = VoxelArea:new({MinEdge=e1, MaxEdge=e2})
local data = vm:get_data()
local digpos = find_next_digpos(data, area, center, dig_y, size)
if digpos then
if digpos.y < pos.y - quarry_max_depth then
meta:set_int("dig_y", digpos.y)
return drops
end
if minetest.is_protected and minetest.is_protected(digpos, owner) then
meta:set_int("enabled", 0)
return
end
dig_y = digpos.y
local node = minetest.get_node(digpos)
drops = minetest.get_node_drops(node.name, "")
minetest.dig_node(digpos)
if minetest.get_node(digpos).name == node.name then
-- We tried to dig something undigable like a
-- filled chest. Notice that we check for a node
-- change, not for air. This is so that we get drops
-- from things like concrete posts with platforms,
-- which turn into regular concrete posts when dug.
drops = {}
end
elseif not (dig_y < pos.y - quarry_max_depth) then
dig_y = dig_y - 16
end
meta:set_int("dig_y", dig_y)
return drops
end
local function send_items(items, pos, node)
for _, item in pairs(items) do
local tube_item = tube_item(vector.new(pos), item)
tube_item:get_luaentity().start_pos = vector.new(pos)
tube_item:setvelocity(vector.new(0, 1, 0))
tube_item:setacceleration({x=0, y=0, z=0})
end
end
minetest.register_node("technic:quarry", {
description = "Quarry",
tiles = {"default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png",
"default_steel_block.png^default_tool_mesepick.png", "default_steel_block.png"},
paramtype2 = "facedir",
groups = {cracky=2, tubedevice=1},
tube = {
connect_sides = {top = 1},
},
on_construct = function(pos)
local size = 4
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Quarry")
meta:set_string("formspec", get_quarry_formspec(4))
meta:set_int("size", size)
meta:set_int("dig_y", pos.y)
end,
after_place_node = function(pos, placer, itemstack)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name())
tube_scanforobjects(pos)
end,
after_dig_node = tube_scanforobjects,
on_receive_fields = quarry_receive_fields,
})
minetest.register_abm({
nodenames = {"technic:quarry"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local size = meta:get_int("size")
local eu_input = meta:get_int("HV_EU_input")
local demand = 10000
local center = get_quarry_center(pos, size)
local dig_y = meta:get_int("dig_y")
technic.switching_station_timeout_count(pos, "HV")
if meta:get_int("enabled") == 0 then
meta:set_string("infotext", "Quarry Disabled")
meta:set_int("HV_EU_demand", 0)
return
end
if eu_input < demand then
meta:set_string("infotext", "Quarry Unpowered")
elseif eu_input >= demand then
meta:set_string("infotext", "Quarry Active")
local items = quarry_dig(pos, center, size)
send_items(items, pos, node)
if dig_y < pos.y - quarry_max_depth then
meta:set_string("infotext", "Quarry Finished")
end
end
meta:set_int("HV_EU_demand", demand)
end
})
technic.register_machine("HV", "technic:quarry", technic.receiver)

View File

@ -1,14 +0,0 @@
-- The high voltage solar array is an assembly of medium voltage arrays.
-- Solar arrays are not able to store large amounts of energy.
minetest.register_craft({
output = 'technic:solar_array_hv 1',
recipe = {
{'technic:solar_array_mv', 'technic:solar_array_mv', 'technic:solar_array_mv'},
{'default:steel_ingot', 'technic:hv_transformer', 'default:steel_ingot'},
{'', 'technic:hv_cable0', ''},
}
})
technic.register_solar_array({tier="HV", power=100})

View File

@ -1,14 +0,0 @@
-- LV Alloy furnace
-- FIXME: kpoppel: I'd like to introduce an induction heating element here...
minetest.register_craft({
output = 'technic:lv_alloy_furnace',
recipe = {
{'default:brick', 'default:brick', 'default:brick'},
{'default:brick', '', 'default:brick'},
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
}
})
technic.register_alloy_furnace({tier="LV", cook_time=6, demand={300}})

View File

@ -1,46 +0,0 @@
-- LV Battery box and some other nodes...
technic.register_power_tool("technic:battery", 10000)
technic.register_power_tool("technic:red_energy_crystal", 100000)
technic.register_power_tool("technic:green_energy_crystal", 250000)
technic.register_power_tool("technic:blue_energy_crystal", 500000)
minetest.register_craft({
output = 'technic:battery',
recipe = {
{'group:wood', 'default:copper_ingot', 'group:wood'},
{'group:wood', 'moreores:tin_ingot', 'group:wood'},
{'group:wood', 'default:copper_ingot', 'group:wood'},
}
})
minetest.register_tool("technic:battery", {
description = "RE Battery",
inventory_image = "technic_battery.png",
tool_capabilities = {
charge = 0,
max_drop_level = 0,
groupcaps = {
fleshy = {times={}, uses=10000, maxlevel=0}
}
}
})
minetest.register_craft({
output = 'technic:lv_battery_box0',
recipe = {
{'technic:battery', 'group:wood', 'technic:battery'},
{'technic:battery', 'default:copper_ingot', 'technic:battery'},
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
}
})
technic.register_battery_box({
tier = "LV",
max_charge = 50000,
charge_rate = 1000,
discharge_rate = 4000,
charge_step = 500,
discharge_step = 800,
})

View File

@ -1,12 +0,0 @@
minetest.register_alias("lv_cable", "technic:lv_cable0")
minetest.register_craft({
output = 'technic:lv_cable0 6',
recipe = {
{'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
}
})
technic.register_cable("LV", 2/16)

View File

@ -1,254 +0,0 @@
-- Technic CNC v1.0 by kpoppel
-- Based on the NonCubic Blocks MOD v1.4 by yves_de_beck
-- Idea:
-- Somehow have a tabbed/paged panel if the number of shapes should expand
-- beyond what is available in the panel today.
-- I could imagine some form of API allowing modders to come with their own node
-- box definitions and easily stuff it in the this machine for production.
local shape = {}
local onesize_products = {
slope = 2,
slope_edge = 1,
slope_inner_edge = 1,
pyramid = 2,
spike = 1,
cylinder = 2,
sphere = 1,
stick = 8,
slope_upsdown = 2,
slope_edge_upsdown = 1,
slope_inner_edge_upsdown = 1,
cylinder_horizontal = 2,
slope_lying = 2,
onecurvededge = 1,
twocurvededge = 1,
}
local twosize_products = {
element_straight = 4,
element_end = 2,
element_cross = 1,
element_t = 1,
element_edge = 2,
}
local cnc_formspec =
"invsize[9,11;]"..
"label[1,0;Choose Milling Program:]"..
"image_button[1,0.5;1,1;technic_cnc_slope.png;slope; ]"..
"image_button[2,0.5;1,1;technic_cnc_slope_edge.png;slope_edge; ]"..
"image_button[3,0.5;1,1;technic_cnc_slope_inner_edge.png;slope_inner_edge; ]"..
"image_button[4,0.5;1,1;technic_cnc_pyramid.png;pyramid; ]"..
"image_button[5,0.5;1,1;technic_cnc_spike.png;spike; ]"..
"image_button[6,0.5;1,1;technic_cnc_cylinder.png;cylinder; ]"..
"image_button[7,0.5;1,1;technic_cnc_sphere.png;sphere; ]"..
"image_button[8,0.5;1,1;technic_cnc_stick.png;stick; ]"..
"image_button[1,1.5;1,1;technic_cnc_slope_upsdwn.png;slope_upsdown; ]"..
"image_button[2,1.5;1,1;technic_cnc_slope_edge_upsdwn.png;slope_edge_upsdown; ]"..
"image_button[3,1.5;1,1;technic_cnc_slope_inner_edge_upsdwn.png;slope_inner_edge_upsdown; ]"..
"image_button[4,1.5;1,1;technic_cnc_cylinder_horizontal.png;cylinder_horizontal; ]"..
"image_button[1,2.5;1,1;technic_cnc_slope_lying.png;slope_lying; ]"..
"image_button[2,2.5;1,1;technic_cnc_onecurvededge.png;onecurvededge; ]"..
"image_button[3,2.5;1,1;technic_cnc_twocurvededge.png;twocurvededge; ]"..
"label[1,3.5;Slim Elements half / normal height:]"..
"image_button[1,4;1,0.5;technic_cnc_full.png;full; ]"..
"image_button[1,4.5;1,0.5;technic_cnc_half.png;half; ]"..
"image_button[2,4;1,1;technic_cnc_element_straight.png;element_straight; ]"..
"image_button[3,4;1,1;technic_cnc_element_end.png;element_end; ]"..
"image_button[4,4;1,1;technic_cnc_element_cross.png;element_cross; ]"..
"image_button[5,4;1,1;technic_cnc_element_t.png;element_t; ]"..
"image_button[6,4;1,1;technic_cnc_element_edge.png;element_edge; ]"..
"label[0, 5.5;In:]"..
"list[current_name;src;0.5,5.5;1,1;]"..
"label[4, 5.5;Out:]"..
"list[current_name;dst;5,5.5;4,1;]"..
"list[current_player;main;0,7;8,4;]"
local size = 1;
-- The form handler is declared here because we need it in both the inactive and active modes
-- in order to be able to change programs wile it is running.
local function form_handler(pos, formname, fields, sender)
-- REGISTER MILLING PROGRAMS AND OUTPUTS:
------------------------------------------
-- Program for half/full size
if fields["full"] then
size = 1
return
end
if fields["half"] then
size = 2
return
end
-- Resolve the node name and the number of items to make
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local inputstack = inv:get_stack("src", 1)
local inputname = inputstack:get_name()
local multiplier = 0
for k, _ in pairs(fields) do
-- Set a multipier for the half/full size capable blocks
if twosize_products[k] ~= nil then
multiplier = size * twosize_products[k]
else
multiplier = onesize_products[k]
end
if onesize_products[k] ~= nil or twosize_products[k] ~= nil then
meta:set_float( "cnc_multiplier", multiplier)
meta:set_string("cnc_user", sender:get_player_name())
end
if onesize_products[k] ~= nil or (twosize_products[k] ~= nil and size==2) then
meta:set_string("cnc_product", inputname .. "_technic_cnc_" .. k)
--print(inputname .. "_technic_cnc_" .. k)
break
end
if twosize_products[k] ~= nil and size==1 then
meta:set_string("cnc_product", inputname .. "_technic_cnc_" .. k .. "_double")
--print(inputname .. "_technic_cnc_" .. k .. "_double")
break
end
end
return
end
-- The actual block inactive state
minetest.register_node("technic:cnc", {
description = "CNC Milling Machine",
tiles = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
groups = {cracky=2},
legacy_facedir_simple = true,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "CNC Machine")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", cnc_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
on_receive_fields = form_handler,
})
-- Active state block
minetest.register_node("technic:cnc_active", {
description = "CNC Machine",
tiles = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front_active.png"},
paramtype2 = "facedir",
groups = {cracky=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"CNC machine cannot be removed because it is not empty");
return false
end
return true
end,
on_receive_fields = form_handler,
})
-- Action code performing the transformation
minetest.register_abm({
nodenames = {"technic:cnc","technic:cnc_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local eu_input = meta:get_int("LV_EU_input")
local machine_name = "CNC"
local machine_node = "technic:cnc"
local demand = 450
-- Setup meta data if it does not exist. state is used as an indicator of this
if not eu_input then
meta:set_int("LV_EU_demand", demand)
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
local result = meta:get_string("cnc_product")
if inv:is_empty("src") or
(not minetest.registered_nodes[result]) or
(not inv:room_for_item("dst", result)) then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
meta:set_string("cnc_product", "")
return
end
if eu_input < demand then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
elseif eu_input >= demand then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") >= 3 then -- 3 ticks per output
meta:set_int("src_time", 0)
srcstack = inv:get_stack("src", 1)
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
inv:add_item("dst", result.." "..meta:get_int("cnc_multiplier"))
end
end
meta:set_int("LV_EU_demand", demand)
end
})
technic.register_machine("LV", "technic:cnc", technic.receiver)
technic.register_machine("LV", "technic:cnc_active", technic.receiver)
-------------------------
-- CNC Machine Recipe
-------------------------
minetest.register_craft({
output = 'technic:cnc',
recipe = {
{'default:glass', 'technic:diamond_drill_head', 'default:glass'},
{'technic:control_logic_unit', 'technic:motor', 'default:steel_ingot'},
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
},
})

View File

@ -1,354 +0,0 @@
-- API for the technic CNC machine
-- Again code is adapted from the NonCubic Blocks MOD v1.4 by yves_de_beck
technic.cnc = {}
technic.cnc.detail_level = 16
-- REGISTER NONCUBIC FORMS, CREATE MODELS AND RECIPES:
------------------------------------------------------
local function cnc_sphere()
local nodebox = {}
local detail = technic.cnc.detail_level
local sehne
for i = 1, detail - 1 do
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
nodebox[i]={-sehne, (i/detail) - 0.5, -sehne, sehne, (i/detail)+(1/detail)-0.5, sehne}
end
return nodebox
end
local function cnc_cylinder_horizontal()
local nodebox = {}
local detail = technic.cnc.detail_level
local sehne
for i = 1, detail - 1 do
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
nodebox[i]={-0.5, (i/detail)-0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, sehne}
end
return nodebox
end
local function cnc_cylinder()
local nodebox = {}
local detail = technic.cnc.detail_level
local sehne
for i = 1, detail - 1 do
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
nodebox[i]={(i/detail) - 0.5, -0.5, -sehne, (i/detail)+(1/detail)-0.5, 0.5, sehne}
end
return nodebox
end
local function cnc_twocurvededge()
local nodebox = {}
local detail = technic.cnc.detail_level * 2
local sehne
for i = (detail / 2) - 1, detail - 1 do
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
nodebox[i]={-sehne, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
end
return nodebox
end
local function cnc_onecurvededge()
local nodebox = {}
local detail = technic.cnc.detail_level * 2
local sehne
for i = (detail / 2) - 1, detail - 1 do
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
nodebox[i]={-0.5, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
end
return nodebox
end
local function cnc_spike()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail - 1 do
nodebox[i+1] = {(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5,
0.5-(i/detail/2), (i/detail)-0.5+(1/detail), 0.5-(i/detail/2)}
end
return nodebox
end
local function cnc_pyramid()
local nodebox = {}
local detail = technic.cnc.detail_level / 2
for i = 0, detail - 1 do
nodebox[i+1] = {(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5, 0.5-(i/detail/2), (i/detail/2)-0.5+(1/detail), 0.5-(i/detail/2)}
end
return nodebox
end
local function cnc_slope_inner_edge_upsdown()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {0.5-(i/detail)-(1/detail), (i/detail)-0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
nodebox[i+detail+1] = {-0.5, (i/detail)-0.5, 0.5-(i/detail)-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local function cnc_slope_edge_upsdown()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {(-1*(i/detail))+0.5-(1/detail), (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local function cnc_slope_inner_edge()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {(i/detail)-0.5, -0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
nodebox[i+detail+1] = {-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local function cnc_slope_edge()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {(i/detail)-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local function cnc_slope_upsdown()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {-0.5, (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local function cnc_slope_lying()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {(i/detail)-0.5, -0.5, (i/detail)-0.5, (i/detail)-0.5+(1/detail), 0.5 , 0.5}
end
return nodebox
end
local function cnc_slope()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {-0.5, (i/detail)-0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
-- Define slope boxes for the various nodes
-------------------------------------------
technic.cnc.programs = {
{suffix = "technic_cnc_stick",
nodebox = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15},
desc = "Stick"},
{suffix = "technic_cnc_element_end_double",
nodebox = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.5},
desc = "Element End Double"},
{suffix = "technic_cnc_element_cross_double",
nodebox = {
{0.3, -0.5, -0.3, 0.5, 0.5, 0.3},
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
desc = "Element Cross Double"},
{suffix = "technic_cnc_element_t_double",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3},
{0.3, -0.5, -0.3, 0.5, 0.5, 0.3}},
desc = "Element T Double"},
{suffix = "technic_cnc_element_edge_double",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
desc = "Element Edge Double"},
{suffix = "technic_cnc_element_straight_double",
nodebox = {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
desc = "Element Straight Double"},
{suffix = "technic_cnc_element_end",
nodebox = {-0.3, -0.5, -0.3, 0.3, 0, 0.5},
desc = "Element End"},
{suffix = "technic_cnc_element_cross",
nodebox = {
{0.3, -0.5, -0.3, 0.5, 0, 0.3},
{-0.3, -0.5, -0.5, 0.3, 0, 0.5},
{-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
desc = "Element Cross"},
{suffix = "technic_cnc_element_t",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0, 0.3},
{0.3, -0.5, -0.3, 0.5, 0, 0.3}},
desc = "Element T"},
{suffix = "technic_cnc_element_edge",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
desc = "Element Edge"},
{suffix = "technic_cnc_element_straight",
nodebox = {-0.3, -0.5, -0.5, 0.3, 0, 0.5},
desc = "Element Straight"},
{suffix = "technic_cnc_sphere",
nodebox = cnc_sphere(),
desc = "Sphere"},
{suffix = "technic_cnc_cylinder_horizontal",
nodebox = cnc_cylinder_horizontal(),
desc = "Cylinder Horizontal"},
{suffix = "technic_cnc_cylinder",
nodebox = cnc_cylinder(),
desc = ""},
{suffix = "technic_cnc_twocurvededge",
nodebox = cnc_twocurvededge(),
desc = "One Curved Edge Block"},
{suffix = "technic_cnc_onecurvededge",
nodebox = cnc_onecurvededge(),
desc = "Two Curved Edge Block"},
{suffix = "technic_cnc_spike",
nodebox = cnc_spike(),
desc = "Spike"},
{suffix = "technic_cnc_pyramid",
nodebox = cnc_pyramid(),
desc = "Pyramid"},
{suffix = "technic_cnc_slope_inner_edge_upsdown",
nodebox = cnc_slope_inner_edge_upsdown(),
desc = "Slope Upside Down Inner Edge"},
{suffix = "technic_cnc_slope_edge_upsdown",
nodebox = cnc_slope_edge_upsdown(),
desc = "Slope Upside Down Edge"},
{suffix = "technic_cnc_slope_inner_edge",
nodebox = cnc_slope_inner_edge(),
desc = "Slope Inner Edge"},
{suffix = "technic_cnc_slope_edge",
nodebox = cnc_slope_edge(),
desc = "Slope Edge"},
{suffix = "technic_cnc_slope_upsdown",
nodebox = cnc_slope_upsdown(),
desc = "Slope Upside Down"},
{suffix = "technic_cnc_slope_lying",
nodebox = cnc_slope_lying(),
desc = "Slope Lying"},
{suffix = "technic_cnc_slope",
nodebox = cnc_slope(),
desc = "Slope"},
}
-- Allow disabling certain programs for some node. Default is allowing all types for all nodes
technic.cnc.programs_disable = {
-- ["default:brick"] = {"technic_cnc_stick"}, -- Example: Disallow the stick for brick
-- ...
["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown", "technic_cnc_edge",
"technic_cnc_inner_edge", "technic_cnc_slope_edge_upsdown",
"technic_cnc_slope_inner_edge_upsdown", "technic_cnc_stick",
"technic_cnc_cylinder_horizontal"}
}
-- Generic function for registering all the different node types
function technic.cnc.register_program(recipeitem, suffix, nodebox, groups, images, description)
minetest.register_node(":"..recipeitem.."_"..suffix, {
description = description,
drawtype = "nodebox",
tiles = images,
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
node_box = {
type = "fixed",
fixed = nodebox
},
groups = groups,
})
end
-- function to iterate over all the programs the CNC machine knows
function technic.cnc.register_all(recipeitem, groups, images, description)
for _, data in ipairs(technic.cnc.programs) do
-- Disable node creation for disabled node types for some material
local do_register = true
if technic.cnc.programs_disable[recipeitem] ~= nil then
for __, disable in ipairs(technic.cnc.programs_disable[recipeitem]) do
if disable == data.suffix then
do_register = false
end
end
end
-- Create the node if it passes the test
if do_register then
technic.cnc.register_program(recipeitem, data.suffix, data.nodebox, groups, images, description.." "..data.desc)
end
end
end
-- REGISTER NEW TECHNIC_CNC_API's PART 2: technic.cnc..register_element_end(subname, recipeitem, groups, images, desc_element_xyz)
-----------------------------------------------------------------------------------------------------------------------
function technic.cnc.register_slope_edge_etc(recipeitem, groups, images, desc_slope, desc_slope_lying, desc_slope_upsdown, desc_slope_edge, desc_slope_inner_edge, desc_slope_upsdwn_edge, desc_slope_upsdwn_inner_edge, desc_pyramid, desc_spike, desc_onecurvededge, desc_twocurvededge, desc_cylinder, desc_cylinder_horizontal, desc_sphere, desc_element_straight, desc_element_edge, desc_element_t, desc_element_cross, desc_element_end)
technic.cnc.register_slope(recipeitem, groups, images, desc_slope)
technic.cnc.register_slope_lying(recipeitem, groups, images, desc_slope_lying)
technic.cnc.register_slope_upsdown(recipeitem, groups, images, desc_slope_upsdown)
technic.cnc.register_slope_edge(recipeitem, groups, images, desc_slope_edge)
technic.cnc.register_slope_inner_edge(recipeitem, groups, images, desc_slope_inner_edge)
technic.cnc.register_slope_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_edge)
technic.cnc.register_slope_inner_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_inner_edge)
technic.cnc.register_pyramid(recipeitem, groups, images, desc_pyramid)
technic.cnc.register_spike(recipeitem, groups, images, desc_spike)
technic.cnc.register_onecurvededge(recipeitem, groups, images, desc_onecurvededge)
technic.cnc.register_twocurvededge(recipeitem, groups, images, desc_twocurvededge)
technic.cnc.register_cylinder(recipeitem, groups, images, desc_cylinder)
technic.cnc.register_cylinder_horizontal(recipeitem, groups, images, desc_cylinder_horizontal)
technic.cnc.register_sphere(recipeitem, groups, images, desc_sphere)
technic.cnc.register_element_straight(recipeitem, groups, images, desc_element_straight)
technic.cnc.register_element_edge(recipeitem, groups, images, desc_element_edge)
technic.cnc.register_element_t(recipeitem, groups, images, desc_element_t)
technic.cnc.register_element_cross(recipeitem, groups, images, desc_element_cross)
technic.cnc.register_element_end(recipeitem, groups, images, desc_element_end)
end
-- REGISTER STICKS: noncubic.register_xyz(recipeitem, groups, images, desc_element_xyz)
------------------------------------------------------------------------------------------------------------
function technic.cnc.register_stick_etc(recipeitem, groups, images, desc_stick)
technic.cnc.register_stick(recipeitem, groups, images, desc_stick)
end
function technic.cnc.register_elements(recipeitem, groups, images, desc_element_straight_double, desc_element_edge_double, desc_element_t_double, desc_element_cross_double, desc_element_end_double)
technic.cnc.register_element_straight_double(recipeitem, groups, images, desc_element_straight_double)
technic.cnc.register_element_edge_double(recipeitem, groups, images, desc_element_edge_double)
technic.cnc.register_element_t_double(recipeitem, groups, images, desc_element_t_double)
technic.cnc.register_element_cross_double(recipeitem, groups, images, desc_element_cross_double)
technic.cnc.register_element_end_double(recipeitem, groups, images, desc_element_end_double)
end

View File

@ -1,71 +0,0 @@
-- REGISTER MATERIALS AND PROPERTIES FOR NONCUBIC ELEMENTS:
-----------------------------------------------------------
-- DIRT
-------
technic.cnc.register_all("default:dirt",
{snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
{"default_grass.png", "default_dirt.png", "default_grass.png"},
"Dirt")
technic.cnc.programs_disable["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown",
"technic_cnc_edge", "technic_cnc_inner_edge",
"technic_cnc_slope_edge_upsdown", "technic_cnc_slope_inner_edge_upsdown",
"technic_cnc_stick", "technic_cnc_cylinder_horizontal"}
-- TREE
-------
technic.cnc.register_all("default:tree",
{snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
{"default_tree.png"},
"Wooden")
-- WOOD
-------
technic.cnc.register_all("default:wood",
{snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
{"default_wood.png"},
"Wooden")
-- STONE
--------
technic.cnc.register_all("default:stone",
{cracky=3, not_in_creative_inventory=1},
{"default_stone.png"},
"Stone")
-- COBBLE
---------
technic.cnc.register_all("default:cobble",
{cracky=3, not_in_creative_inventory=1},
{"default_cobble.png"},
"Cobble")
-- BRICK
--------
technic.cnc.register_all("default:brick",
{cracky=3, not_in_creative_inventory=1},
{"default_brick.png"},
"Brick")
-- SANDSTONE
------------
technic.cnc.register_all("default:sandstone",
{crumbly=2, cracky=2, not_in_creative_inventory=1},
{"default_sandstone.png"},
"Sandstone")
-- LEAVES
---------
technic.cnc.register_all("default:leaves",
{snappy=2, choppy=2, oddly_breakable_by_hand=3, not_in_creative_inventory=1},
{"default_leaves.png"},
"Leaves")
-- TREE
-------
technic.cnc.register_all("default:tree",
{snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3, wood=1, not_in_creative_inventory=1},
{"default_tree.png"},
"Tree")
-- STEEL
--------
technic.cnc.register_all("default:steel",
{snappy=1, bendy=2, cracky=1, melty=2, level=2, not_in_creative_inventory=1},
{"default_steel_block.png"},
"Steel")

View File

@ -1,181 +0,0 @@
-- Coal driven alloy furnace. This uses no EUs:
minetest.register_craft({
output = 'technic:coal_alloy_furnace',
recipe = {
{'default:brick', 'default:brick', 'default:brick'},
{'default:brick', '', 'default:brick'},
{'default:brick', 'default:brick', 'default:brick'},
}
})
minetest.register_node("technic:coal_alloy_furnace", {
description = "Alloy Furnace",
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png",
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", coal_alloy_furnace_formspec)
meta:set_string("infotext", "Alloy Furnace")
local inv = meta:get_inventory()
inv:set_size("fuel", 1)
inv:set_size("src", 1)
inv:set_size("src2", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not (inv:is_empty("fuel") or inv:is_empty("dst") or inv:is_empty("src") or inv:is_empty("src2") )then
return false
end
return true
end,
})
minetest.register_node("technic:coal_alloy_furnace_active", {
description = "Alloy Furnace",
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png",
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "technic:coal_alloy_furnace",
groups = {cracky=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not (inv:is_empty("fuel") or inv:is_empty("dst") or
inv:is_empty("src") or inv:is_empty("src2")) then
return false
end
return true
end,
})
minetest.register_abm({
nodenames = {"technic:coal_alloy_furnace", "technic:coal_alloy_furnace_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local recipe = nil
local formspec =
"size[8,9]"..
"label[0,0;Alloy Furnace]"..
"image[2,2;1,1;default_furnace_fire_bg.png]"..
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;src;2,1;1,1;]"..
"list[current_name;src2;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
for i, name in pairs({
"fuel_totaltime",
"fuel_time",
"src_totaltime",
"src_time"}) do
if not meta:get_float(name) then
meta:set_float(name, 0.0)
end
end
-- Get what to cook if anything
local srcstack = inv:get_stack("src", 1)
local src2stack = inv:get_stack("src2", 1)
local recipe = technic.get_alloy_recipe(srcstack, src2stack)
if srcstack:get_name() > src2stack:get_name() then
local temp = srcstack
srcstack = src2stack
src2stack = temp
end
local was_active = false
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
was_active = true
meta:set_int("fuel_time", meta:get_int("fuel_time") + 1)
if recipe then
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") == 6 then
-- check if there's room for output in "dst" list
local dst_stack = ItemStack(recipe.output)
if inv:room_for_item("dst", dst_stack) then
srcstack:take_item(recipe.input[1].count)
inv:set_stack("src", 1, srcstack)
src2stack:take_item(recipe.input[2].count)
inv:set_stack("src2", 1, src2stack)
inv:add_item("dst", dst_stack)
end
meta:set_int("src_time", 0)
end
else
meta:set_int("src_time", 0)
end
end
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100)
meta:set_string("infotext","Furnace active: "..percent.."%")
hacky_swap_node(pos, "technic:coal_alloy_furnace_active")
meta:set_string("formspec",
"size[8,9]"..
"label[0,0;Electric Alloy Furnace]"..
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
(100-percent)..":default_furnace_fire_fg.png]"..
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;src;2,1;1,1;]"..
"list[current_name;src2;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]")
return
end
-- FIXME: Make this look more like the electrical version.
-- This code refetches the recipe to see if it can be done again after the iteration
srcstack = inv:get_stack("src", 1)
srcstack = inv:get_stack("src2", 1)
local recipe = technic.get_alloy_recipe(srcstack, src2stack)
if recipe then
if was_active then
meta:set_string("infotext", "Furnace is empty")
hacky_swap_node(pos, "technic:coal_alloy_furnace")
meta:set_string("formspec", formspec)
end
return
end
-- Next take a hard look at the fuel situation
local fuel = nil
local fuellist = inv:get_list("fuel")
if fuellist then
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
end
if fuel.time <= 0 then
meta:set_string("infotext", "Furnace out of fuel")
hacky_swap_node(pos, "technic:coal_alloy_furnace")
meta:set_string("formspec", formspec)
return
end
meta:set_string("fuel_totaltime", fuel.time)
meta:set_string("fuel_time", 0)
local stack = inv:get_stack("fuel", 1)
stack:take_item()
inv:set_stack("fuel", 1, stack)
end,
})

View File

@ -1,169 +0,0 @@
technic.compressor_recipes ={}
technic.register_compressor_recipe = function(src, src_count, dst, dst_count)
technic.compressor_recipes[src] = {src_count = src_count, dst_name = dst, dst_count = dst_count}
if unified_inventory then
unified_inventory.register_craft(
{
type = "compressing",
output = dst.." "..dst_count,
items = {src.." "..src_count},
width = 0,
})
end
end
technic.get_compressor_recipe = function(item)
if technic.compressor_recipes[item.name] and
item.count >= technic.compressor_recipes[item.name].src_count then
return technic.compressor_recipes[item.name]
else
return nil
end
end
technic.register_compressor_recipe("default:snowblock", 1, "default:ice", 1)
technic.register_compressor_recipe("default:sand", 1, "default:sandstone", 1)
technic.register_compressor_recipe("default:desert_sand", 1, "default:desert_stone", 1)
technic.register_compressor_recipe("technic:mixed_metal_ingot", 1, "technic:composite_plate", 1)
technic.register_compressor_recipe("default:copper_ingot", 5, "technic:copper_plate", 1)
technic.register_compressor_recipe("technic:coal_dust", 4, "technic:graphite", 1)
technic.register_compressor_recipe("technic:carbon_cloth", 1, "technic:carbon_plate", 1)
technic.register_compressor_recipe("technic:enriched_uranium", 4, "technic:uranium_fuel", 1)
minetest.register_alias("compressor", "technic:compressor")
minetest.register_craft({
output = 'technic:compressor',
recipe = {
{'default:stone', 'default:stone', 'default:stone'},
{'mesecons:piston', 'technic:motor', 'mesecons:piston'},
{'default:stone', 'technic:lv_cable0', 'default:stone'},
}
})
local compressor_formspec =
"invsize[8,9;]"..
"label[0,0;Compressor]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node("technic:compressor", {
description = "Compressor",
tiles = {"technic_compressor_top.png", "technic_compressor_bottom.png",
"technic_compressor_side.png", "technic_compressor_side.png",
"technic_compressor_back.png", "technic_compressor_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Compressor")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", compressor_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty")
return false
else
return true
end
end,
})
minetest.register_node("technic:compressor_active", {
description = "Compressor",
tiles = {"technic_compressor_top.png", "technic_compressor_bottom.png",
"technic_compressor_side.png", "technic_compressor_side.png",
"technic_compressor_back.png", "technic_compressor_front_active.png"},
paramtype2 = "facedir",
groups = {cracky=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_abm({
nodenames = {"technic:compressor","technic:compressor_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local machine_name = "Compressor"
local machine_node = "technic:compressor"
local demand = 300
-- Setup meta data if it does not exist.
if not eu_input then
meta:set_int("LV_EU_demand", demand)
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
local inv = meta:get_inventory()
local empty = inv:is_empty("src")
local srcstack = inv:get_stack("src", 1)
local src_item, recipe, result = nil, nil, nil
if srcstack then
src_item = srcstack:to_table()
end
if src_item then
recipe = technic.get_compressor_recipe(src_item)
end
if recipe then
result = {name=recipe.dst_name, count=recipe.dst_count}
end
if empty or (not result) or
(not inv:room_for_item("dst", result)) then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
meta:set_int("LV_EU_demand", 0)
meta:set_int("src_time", 0)
return
end
if eu_input < demand then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
elseif eu_input >= demand then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") >= 4 then
meta:set_int("src_time", 0)
srcstack:take_item(recipe.src_count)
inv:set_stack("src", 1, srcstack)
inv:add_item("dst", result)
end
end
meta:set_int("LV_EU_demand", demand)
end
})
technic.register_machine("LV", "technic:compressor", technic.receiver)
technic.register_machine("LV", "technic:compressor_active", technic.receiver)

View File

@ -1,16 +0,0 @@
-- LV Electric Furnace
-- This is a faster version of the stone furnace which runs on EUs
-- FIXME: kpoppel I'd like to introduce an induction heating element here also
minetest.register_craft({
output = 'technic:electric_furnace',
recipe = {
{'default:cobble', 'default:cobble', 'default:cobble'},
{'default:cobble', '', 'default:cobble'},
{'default:steel_ingot', 'moreores:copper_ingot', 'default:steel_ingot'},
}
})
technic.register_electric_furnace({tier="LV", demand={300}, speed = 2})

View File

@ -1,175 +0,0 @@
technic.extractor_recipes ={}
technic.register_extractor_recipe = function(src, src_count, dst, dst_count)
technic.extractor_recipes[src] = {src_count = src_count, dst_name = dst, dst_count = dst_count}
if unified_inventory then
unified_inventory.register_craft({
type = "extracting",
output = dst.." "..dst_count,
items = {src.." "..src_count},
width = 0,
})
end
end
-- Receive an ItemStack of result by an ItemStack input
technic.get_extractor_recipe = function(item)
if technic.extractor_recipes[item.name] and
item.count >= technic.extractor_recipes[item.name].src_count then
return technic.extractor_recipes[item.name]
else
return nil
end
end
technic.register_extractor_recipe("technic:coal_dust", 1, "dye:black", 2)
technic.register_extractor_recipe("default:cactus", 1, "dye:green", 2)
technic.register_extractor_recipe("default:dry_shrub", 1, "dye:brown", 2)
technic.register_extractor_recipe("flowers:geranium", 1, "dye:blue", 2)
technic.register_extractor_recipe("flowers:dandelion_white", 1, "dye:white", 2)
technic.register_extractor_recipe("flowers:dandelion_yellow", 1, "dye:yellow", 2)
technic.register_extractor_recipe("flowers:tulip", 1, "dye:orange", 2)
technic.register_extractor_recipe("flowers:rose", 1, "dye:red", 2)
technic.register_extractor_recipe("flowers:viola", 1, "dye:violet", 2)
technic.register_extractor_recipe("technic:raw_latex", 1, "technic:rubber", 3)
technic.register_extractor_recipe("moretrees:rubber_tree_trunk_empty", 1, "technic:rubber", 1)
technic.register_extractor_recipe("moretrees:rubber_tree_trunk", 1, "technic:rubber", 1)
technic.register_extractor_recipe("technic:uranium", 5, "technic:enriched_uranium", 1)
minetest.register_alias("extractor", "technic:extractor")
minetest.register_craft({
output = 'technic:extractor',
recipe = {
{'technic:treetap', 'technic:motor', 'technic:treetap'},
{'technic:treetap', 'technic:lv_cable0', 'technic:treetap'},
{'', '', ''},
}
})
local extractor_formspec =
"invsize[8,9;]"..
"label[0,0;Extractor]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node("technic:extractor", {
description = "Extractor",
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Extractor")
meta:set_string("formspec", extractor_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node("technic:extractor_active", {
description = "Extractor",
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
paramtype2 = "facedir",
groups = {cracky=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_abm({
nodenames = {"technic:extractor", "technic:extractor_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
-- The machine will automatically shut down if disconnected from power in some fashion.
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local srcstack = inv:get_stack("src", 1)
local eu_input = meta:get_int("LV_EU_input")
-- Machine information
local machine_name = "Extractor"
local machine_node = "technic:extractor"
local demand = 300
-- Setup meta data if it does not exist.
if not eu_input then
meta:set_int("LV_EU_demand", demand)
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
if srcstack then
src_item = srcstack:to_table()
end
if src_item then
recipe = technic.get_extractor_recipe(src_item)
end
if recipe then
result = {name=recipe.dst_name, count=recipe.dst_count}
end
if inv:is_empty("src") or (not recipe) or (not result) or
(not inv:room_for_item("dst", result)) then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
meta:set_int("LV_EU_demand", 0)
return
end
if eu_input < demand then
-- unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
elseif eu_input >= demand then
-- Powered
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") >= 4 then -- 4 ticks per output
meta:set_int("src_time", 0)
srcstack:take_item(recipe.src_count)
inv:set_stack("src", 1, srcstack)
inv:add_item("dst", result)
end
end
meta:set_int("LV_EU_demand", demand)
end
})
technic.register_machine("LV", "technic:extractor", technic.receiver)
technic.register_machine("LV", "technic:extractor_active", technic.receiver)

View File

@ -1,139 +0,0 @@
-- The electric generator.
-- A simple device to get started on the electric machines.
-- Inefficient and expensive in fuel (200EU per tick)
-- Also only allows for LV machinery to run.
minetest.register_alias("generator", "technic:generator")
minetest.register_alias("generator", "technic:generator_active")
minetest.register_craft({
output = 'technic:generator',
recipe = {
{'default:stone', 'default:stone', 'default:stone'},
{'default:stone', '', 'default:stone'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
local generator_formspec =
"invsize[8,9;]"..
"label[0,0;Generator]"..
"list[current_name;src;3,1;1,1;]"..
"image[4,1;1,1;default_furnace_fire_bg.png]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node("technic:generator", {
description = "Electric Generator",
tiles = {"technic_generator_top.png", "technic_machine_bottom.png", "technic_generator_side.png",
"technic_generator_side.png", "technic_generator_side.png", "technic_generator_front.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Electric Generator")
meta:set_int("LV_EU_supply", 0)
-- Signal to the switching station that this device burns some
-- sort of fuel and needs special handling
meta:set_int("LV_EU_from_fuel", 1)
meta:set_int("burn_time", 0)
meta:set_string("formspec", generator_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node("technic:generator_active", {
description = "Electric Generator",
tiles = {"technic_generator_top.png", "technic_machine_bottom.png",
"technic_generator_side.png", "technic_generator_side.png",
"technic_generator_side.png", "technic_generator_front_active.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop = "technic:generator",
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_abm({
nodenames = {"technic:generator", "technic:generator_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local burn_time = meta:get_int("burn_time")
local burn_totaltime = meta:get_int("burn_totaltime")
-- If more to burn and the energy produced was used: produce some more
if burn_time > 0 then
meta:set_int("LV_EU_supply", 200) -- Give 200EUs
burn_time = burn_time - 1
meta:set_int("burn_time", burn_time)
end
-- Burn another piece of fuel
if burn_time == 0 then
local inv = meta:get_inventory()
if not inv:is_empty("src") then
local fuellist = inv:get_list("src")
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
if not fuel or fuel.time == 0 then
meta:set_string("infotext", "Generator out of fuel")
hacky_swap_node(pos, "technic:generator")
return
end
meta:set_int("burn_time", fuel.time)
meta:set_int("burn_totaltime", fuel.time)
local stack = inv:get_stack("src", 1)
stack:take_item()
inv:set_stack("src", 1, stack)
hacky_swap_node(pos, "technic:generator_active")
meta:set_int("LV_EU_supply", 200) -- Give 200EUs
else
hacky_swap_node(pos, "technic:generator")
meta:set_int("LV_EU_supply", 0)
end
end
local percent = math.floor((burn_time / burn_totaltime) * 100)
meta:set_string("infotext", "Electric Generator ("..percent.."%)")
meta:set_string("formspec",
"size[8,9]"..
"label[0,0;Generator]"..
"list[current_name;src;3,1;1,1;]"..
"image[4,1;1,1;default_furnace_fire_bg.png^[lowpart:"..
(percent)..":default_furnace_fire_fg.png]"..
"list[current_player;main;0,5;8,4;]")
end
})
technic.register_machine("LV", "technic:generator", technic.producer)
technic.register_machine("LV", "technic:generator_active", technic.producer)

View File

@ -1,123 +0,0 @@
-- A geothermal EU generator
-- Using hot lava and water this device can create energy from steam
-- The machine is only producing LV EUs and can thus not drive more advanced equipment
-- The output is a little more than the coal burning generator (max 300EUs)
minetest.register_alias("geothermal", "technic:geothermal")
minetest.register_craft({
output = 'technic:geothermal',
recipe = {
{'default:stone', 'default:stone', 'default:stone'},
{'default:copper_ingot', 'default:diamond', 'default:copper_ingot'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
minetest.register_craftitem("technic:geothermal", {
description = "Geothermal Generator",
stack_max = 99,
})
local geothermal_formspec =
"invsize[8,4;]"..
"label[0,0;Geothermal Generator]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node("technic:geothermal", {
description = "Geothermal Generator",
tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Geothermal Generator")
meta:set_float("technic_power_machine", 1)
meta:set_int("LV_EU_supply", 0)
meta:set_string("formspec", geothermal_formspec)
end,
})
minetest.register_node("technic:geothermal_active", {
description = "Geothermal Generator",
tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop = "technic:geothermal",
})
local check_node_around = function(pos)
local node = minetest.get_node(pos)
if node.name == "default:water_source" or node.name == "default:water_flowing" then return 1 end
if node.name == "default:lava_source" or node.name == "default:lava_flowing" then return 2 end
return 0
end
minetest.register_abm({
nodenames = {"technic:geothermal","technic:geothermal_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local water_nodes = 0
local lava_nodes = 0
local production_level = 0
local eu_supply = 0
-- Correct positioning is water on one side and lava on the other.
-- The two cannot be adjacent because the lava the turns into obsidian or rock.
-- To get to 100% production stack the water and lava one extra block down as well:
-- WGL (W=Water, L=Lava, G=the generator, |=an LV cable)
-- W|L
local positions = {
{x=pos.x+1, y=pos.y, z=pos.z},
{x=pos.x+1, y=pos.y-1, z=pos.z},
{x=pos.x-1, y=pos.y, z=pos.z},
{x=pos.x-1, y=pos.y-1, z=pos.z},
{x=pos.x, y=pos.y, z=pos.z+1},
{x=pos.x, y=pos.y-1, z=pos.z+1},
{x=pos.x, y=pos.y, z=pos.z-1},
{x=pos.x, y=pos.y-1, z=pos.z-1},
}
for _, p in pairs(positions) do
local check = check_node_around(p)
if check == 1 then water_nodes = water_nodes + 1 end
if check == 2 then lava_nodes = lava_nodes + 1 end
end
if water_nodes == 1 and lava_nodes == 1 then production_level = 25; eu_supply = 50 end
if water_nodes == 2 and lava_nodes == 1 then production_level = 50; eu_supply = 100 end
if water_nodes == 1 and lava_nodes == 2 then production_level = 75; eu_supply = 200 end
if water_nodes == 2 and lava_nodes == 2 then production_level = 100; eu_supply = 300 end
if production_level > 0 then
meta:set_int("LV_EU_supply", eu_supply)
end
meta:set_string("formspec",
"invsize[8,4;]"..
"label[0,0;Geothermal Generator]"..
"label[4,0;Production at "..tostring(production_level).."%]")
if production_level > 0 and minetest.get_node(pos).name == "technic:geothermal" then
hacky_swap_node (pos, "technic:geothermal_active")
return
end
if production_level == 0 then
hacky_swap_node(pos, "technic:geothermal")
meta:set_int("LV_EU_supply", 0)
end
end
})
technic.register_machine("LV", "technic:geothermal", technic.producer)
technic.register_machine("LV", "technic:geothermal_active", technic.producer)

View File

@ -1,13 +0,0 @@
minetest.register_alias("grinder", "technic:grinder")
minetest.register_craft({
output = 'technic:grinder',
recipe = {
{'default:desert_stone', 'default:desert_stone', 'default:desert_stone'},
{'default:desert_stone', 'default:diamond', 'default:desert_stone'},
{'default:stone', 'moreores:copper_ingot', 'default:stone'},
}
})
technic.register_grinder({tier="LV", demand={200}, speed=1})

View File

@ -1,138 +0,0 @@
-- LV Music player.
-- The player can play music. But it is high ampage!
minetest.register_alias("music_player", "technic:music_player")
minetest.register_craft({
output = 'technic:music_player',
recipe = {
{'group:wood', 'group:wood', 'group:wood'},
{'default:diamond', 'default:diamond', 'default:diamond'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
local music_player_formspec =
"invsize[8,9;]"..
"label[0,0;Music Player]"..
"button[4,1;1,1;track1;1]"..
"button[5,1;1,1;track2;2]"..
"button[6,1;1,1;track3;3]"..
"button[4,2;1,1;track4;4]"..
"button[5,2;1,1;track5;5]"..
"button[6,2;1,1;track6;6]"..
"button[4,3;1,1;track7;7]"..
"button[5,3;1,1;track8;8]"..
"button[6,3;1,1;track9;9]"..
"button[4,4;1,2;play;Play]"..
"button[6,4;1,2;stop;Stop]"..
"label[4,0;Current track --]"
minetest.register_node("technic:music_player", {
description = "Music Player",
tiles = {"technic_music_player_top.png", "technic_machine_bottom.png", "technic_music_player_side.png",
"technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Music Player")
meta:set_int("active", 0)
meta:set_int("current_track", 1)
meta:set_string("formspec", music_player_formspec)
end,
on_receive_fields = function(pos, formanme, fields, sender)
local meta = minetest.get_meta(pos)
local music_handle = meta:get_int("music_handle")
local current_track = meta:get_int("current_track")
if fields.track1 then current_track = 1 end
if fields.track2 then current_track = 2 end
if fields.track3 then current_track = 3 end
if fields.track4 then current_track = 4 end
if fields.track5 then current_track = 5 end
if fields.track6 then current_track = 6 end
if fields.track7 then current_track = 7 end
if fields.track8 then current_track = 8 end
if fields.track9 then current_track = 9 end
meta:set_int("current_track", current_track)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Music Player]"..
"button[4,1;1,1;track1;1]"..
"button[5,1;1,1;track2;2]"..
"button[6,1;1,1;track3;3]"..
"button[4,2;1,1;track4;4]"..
"button[5,2;1,1;track5;5]"..
"button[6,2;1,1;track6;6]"..
"button[4,3;1,1;track7;7]"..
"button[5,3;1,1;track8;8]"..
"button[6,3;1,1;track9;9]"..
"button[4,4;1,2;play;Play]"..
"button[6,4;1,2;stop;Stop]"..
"label[4,0;Current track "
..current_track.."]")
if fields.play then
if music_handle then
minetest.sound_stop(music_handle)
end
meta:set_int("active", 1)
end
if fields.stop then
meta:set_int("active", 0)
if music_handle then
minetest.sound_stop(music_handle)
end
end
meta:set_int("music_handle", music_handle)
end,
})
minetest.register_abm({
nodenames = {"technic:music_player"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local machine_name = "Music Player"
local machine_node = "technic:music_player"
local demand = 150
local music_handle = meta:get_int("music_handle")
local current_track = meta:get_int("current_track")
-- Setup meta data if it does not exist.
if not eu_input then
meta:set_int("LV_EU_demand", demand)
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
if meta:get_int("active") == 0 then
meta:set_string("infotext", machine_name.." Idle")
meta:set_int("LV_EU_demand", 0)
if music_handle then
minetest.sound_stop(music_handle)
end
return
end
if eu_input < demand then
meta:set_string("infotext", machine_name.." Unpowered")
if music_handle then
minetest.sound_stop(music_handle)
end
elseif eu_input >= demand then
meta:set_string("infotext", machine_name.." Active")
music_handle = minetest.sound_play("technic_track"..current_track,
{pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,})
meta:set_int("music_handle", music_handle)
end
meta:set_int("LV_EU_demand", demand)
end
})
technic.register_machine("LV", "technic:music_player", technic.receiver)

View File

@ -1,18 +0,0 @@
-- The solar array is an assembly of panels into a powerful array
-- The assembly can deliver more energy than the individual panel because
-- of the transformer unit which converts the panel output variations into
-- a stable supply.
-- Solar arrays are not able to store large amounts of energy.
-- The LV arrays are used to make medium voltage arrays.
minetest.register_craft({
output = 'technic:solar_array_lv 1',
recipe = {
{'technic:solar_panel', 'technic:solar_panel', 'technic:solar_panel'},
{'default:steel_ingot', 'technic:lv_transformer', 'default:steel_ingot'},
{'', 'technic:lv_cable0', ''},
}
})
technic.register_solar_array({tier="LV", power=10})

View File

@ -1,70 +0,0 @@
-- Solar panels are the building blocks of LV solar arrays
-- They can however also be used separately but with reduced efficiency due to the missing transformer.
-- Individual panels are less efficient than when the panels are combined into full arrays.
minetest.register_node("technic:solar_panel", {
tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.png", "technic_solar_panel_side.png",
"technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
description="Solar Panel",
active = false,
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("LV_EU_supply", 0)
meta:set_string("infotext", "LV Solar Panel")
end,
})
minetest.register_craft({
output = 'technic:solar_panel',
recipe = {
{'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'},
{'default:steel_ingot', 'technic:lv_cable0', 'default:steel_ingot'},
}
})
minetest.register_abm({
nodenames = {"technic:solar_panel"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
-- The action here is to make the solar panel prodice power
-- Power is dependent on the light level and the height above ground
-- 130m and above is optimal as it would be above cloud level.
-- Height gives 1/4 of the effect, light 3/4. Max. effect is 26EU.
-- There are many ways to cheat by using other light sources like lamps.
-- As there is no way to determine if light is sunlight that is just a shame.
-- To take care of some of it solar panels do not work outside daylight hours or if
-- built below -10m
local pos1 = {x=pos.x, y=pos.y+1, z=pos.z}
local light = minetest.get_node_light(pos1, nil)
local time_of_day = minetest.get_timeofday()
local meta = minetest.get_meta(pos)
if light == nil then light = 0 end
-- turn on panel only during day time and if sufficient light
-- I know this is counter intuitive when cheating by using other light sources underground.
if light >= 12 and time_of_day >= 0.24 and time_of_day <= 0.76 and pos.y > -10 then
local charge_to_give = math.floor((light + pos1.y) * 3)
charge_to_give = math.max(charge_to_give, 0)
charge_to_give = math.min(charge_to_give, 200)
meta:set_string("infotext", "Solar Panel is active ("..charge_to_give.."EU)")
meta:set_int("LV_EU_supply", charge_to_give)
else
meta:set_string("infotext", "Solar Panel is inactive");
meta:set_int("LV_EU_supply", 0)
end
end,
})
technic.register_machine("LV", "technic:solar_panel", technic.producer)

View File

@ -1,101 +0,0 @@
-- A water mill produces LV EUs by exploiting flowing water across it
-- It is a LV EU supplyer and fairly low yield (max 120EUs)
-- It is a little under half as good as the thermal generator.
minetest.register_alias("water_mill", "technic:water_mill")
minetest.register_craft({
output = 'technic:water_mill',
recipe = {
{'default:stone', 'default:stone', 'default:stone'},
{'group:wood', 'default:diamond', 'group:wood'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
minetest.register_node("technic:water_mill", {
description = "Water Mill",
tiles = {"technic_water_mill_top.png", "technic_machine_bottom.png",
"technic_water_mill_side.png", "technic_water_mill_side.png",
"technic_water_mill_side.png", "technic_water_mill_side.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Water Mill")
meta:set_int("LV_EU_supply", 0)
end,
})
minetest.register_node("technic:water_mill_active", {
description = "Water Mill",
tiles = {"technic_water_mill_top_active.png", "technic_machine_bottom.png",
"technic_water_mill_side.png", "technic_water_mill_side.png",
"technic_water_mill_side.png", "technic_water_mill_side.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop = "technic:water_mill",
})
local function check_node_around_mill(pos)
local node = minetest.get_node(pos)
if node.name == "default:water_flowing" or
node.name == "default:water_source" then
return true
end
return false
end
minetest.register_abm({
nodenames = {"technic:water_mill", "technic:water_mill_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local water_nodes = 0
local lava_nodes = 0
local production_level = 0
local eu_supply = 0
local positions = {
{x=pos.x+1, y=pos.y, z=pos.z},
{x=pos.x-1, y=pos.y, z=pos.z},
{x=pos.x, y=pos.y, z=pos.z+1},
{x=pos.x, y=pos.y, z=pos.z-1},
}
for _, p in pairs(positions) do
local check = check_node_around_mill(p)
if check then
water_nodes = water_nodes + 1
end
end
production_level = 25 * water_nodes
eu_supply = 30 * water_nodes
if production_level > 0 then
meta:set_int("LV_EU_supply", eu_supply)
end
meta:set_string("infotext",
"Water Mill ("..production_level.."%)")
if production_level > 0 and
minetest.get_node(pos).name == "technic:water_mill" then
hacky_swap_node (pos, "technic:water_mill_active")
meta:set_int("LV_EU_supply", 0)
return
end
if production_level == 0 then
hacky_swap_node(pos, "technic:water_mill")
end
end
})
technic.register_machine("LV", "technic:water_mill", technic.producer)
technic.register_machine("LV", "technic:water_mill_active", technic.producer)

View File

@ -1,14 +0,0 @@
-- MV alloy furnace
minetest.register_craft({
output = 'technic:mv_alloy_furnace',
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_alloy_furnace', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
{'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
}
})
technic.register_alloy_furnace({tier="MV", cook_time=4, upgrade=1, tube=1, demand={3000, 2000, 1000}})

View File

@ -1,20 +0,0 @@
-- MV Battery box
minetest.register_craft({
output = 'technic:mv_battery_box0',
recipe = {
{'technic:lv_battery_box0', 'technic:lv_battery_box0', 'technic:lv_battery_box0'},
{'technic:lv_battery_box0', 'technic:mv_transformer', 'technic:lv_battery_box0'},
{'', 'technic:mv_cable0', ''},
}
})
technic.register_battery_box({
tier = "MV",
max_charge = 300000,
charge_rate = 20000,
discharge_rate = 80000,
charge_step = 2000,
discharge_step = 8000,
})

View File

@ -1,14 +0,0 @@
minetest.register_alias("mv_cable", "technic:mv_cable0")
minetest.register_craft({
output = 'technic:mv_cable0 3',
recipe ={
{'technic:rubber', 'technic:rubber', 'technic:rubber'},
{'technic:lv_cable0', 'technic:lv_cable0', 'technic:lv_cable0'},
{'technic:rubber', 'technic:rubber', 'technic:rubber'},
}
})
technic.register_cable("MV", 2.5/16)

View File

@ -1,18 +0,0 @@
-- MV Electric Furnace
-- This is a faster version of the stone furnace which runs on EUs
-- In addition to this it can be upgraded with microcontrollers and batteries
-- This new version uses the batteries to lower the power consumption of the machine
-- Also in addition this furnace can be attached to the pipe system from the pipeworks mod.
-- FIXME: kpoppel I'd like to introduce an induction heating element here also
minetest.register_craft({
output = 'technic:mv_electric_furnace',
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_electric_furnace', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
{'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
}
})
technic.register_electric_furnace({tier="MV", upgrade=1, tube=1, demand={2000, 1000, 500}, speed=4})

View File

@ -1,13 +0,0 @@
-- MV grinder
minetest.register_craft({
output = 'technic:mv_grinder',
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_grinder', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
{'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
}
})
technic.register_grinder({tier="MV", demand={600, 450, 300}, speed=2, upgrade=1, tube=1})

View File

@ -1,220 +0,0 @@
-- The power radiator fuctions like an inductive charger
-- only better in the game setting.
-- The purpose is to allow small appliances to receive power
-- without the overhead of the wiring needed for larger machines.
--
-- The power radiator will consume power corresponding to the
-- sum(power rating of the attached appliances)/0.06
-- Using inductive power transfer is very inefficient so this is
-- set to the factor 0.06.
--
-- Punching the radiator will toggle the power state of all attached appliances.
local power_radius = 12
------------------------------------------------------------------
-- API for inductive powered nodes:
-- Use the functions below to set the corresponding callbacks
-- Also two nodes are needed: The inactive and the active one. The active must be called <name>_active .
------------------------------------------------------------------
-- Register a new appliance using this function
technic.inductive_nodes = {}
technic.register_inductive_machine = function(name)
table.insert(technic.inductive_nodes, name)
table.insert(technic.inductive_nodes, name.."_active")
end
-- Appliances:
-- has_supply: pos of supply node if the appliance has a power radiator near with sufficient power for the demand else ""
-- EU_demand: The power demand of the device.
-- EU_charge: Actual use. set to EU_demand if active==1
-- active: set to 1 if the device is on
technic.inductive_on_construct = function(pos, eu_demand, infotext)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", infotext)
meta:set_int("technic_inductive_power_machine", 1)
meta:set_int("EU_demand", eu_demand) -- The power demand of this appliance
meta:set_int("EU_charge", 0) -- The actual power draw of this appliance
meta:set_string("has_supply", "") -- Register whether we are powered or not. For use with several radiators.
meta:set_int("active", 0) -- If the appliance can be turned on and off by using it use this.
end
technic.inductive_on_punch_off = function(pos, eu_charge, swapnode)
local meta = minetest.get_meta(pos)
if meta:get_string("has_supply") ~= "" then
hacky_swap_node(pos, swapnode)
meta:set_int("active", 1)
meta:set_int("EU_charge",eu_charge)
--print("-----------")
--print("Turn on:")
--print("EU_charge: "..meta:get_int("EU_charge"))
--print("has_supply: "..meta:get_string("has_supply"))
--print("<----------->")
end
end
technic.inductive_on_punch_on = function(pos, eu_charge, swapnode)
local meta = minetest.get_meta(pos)
hacky_swap_node(pos, swapnode)
meta:set_int("active", 0)
meta:set_int("EU_charge",eu_charge)
--print("-----------")
--print("Turn off:")
--print("EU_charge: "..meta:get_int("EU_charge"))
--print("has_supply: "..meta:get_string("has_supply"))
--print("<---------->")
end
local shutdown_inductive_appliances = function(pos)
-- The supply radius
local rad = power_radius
-- If the radiator is removed. turn off all appliances in region
-- If another radiator is near it will turn on the appliances again
local positions = minetest.find_nodes_in_area(
{x=pos.x-rad, y=pos.y-rad, z=pos.z-rad},
{x=pos.x+rad, y=pos.y+rad, z=pos.z+rad},
technic.inductive_nodes)
for _, pos1 in pairs(positions) do
local meta1 = minetest.get_meta(pos1)
-- If the appliance is belonging to this node
if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
local nodename = minetest.get_node(pos1).name
-- Swap the node and make sure it is off and unpowered
if string.sub(nodename, -7) == "_active" then
hacky_swap_node(pos1, string.sub(nodename, 1, -8))
meta1:set_int("active", 0)
meta1:set_int("EU_charge", 0)
end
meta1:set_string("has_supply", "")
end
end
end
local toggle_on_off_inductive_appliances = function(pos, node, puncher)
if pos == nil then return end
-- The supply radius
local rad = power_radius
local positions = minetest.find_nodes_in_area(
{x=pos.x-rad, y=pos.y-rad, z=pos.z-rad},
{x=pos.x+rad, y=pos.y+rad, z=pos.z+rad},
technic.inductive_nodes)
for _, pos1 in pairs(positions) do
local meta1 = minetest.get_meta(pos1)
if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
minetest.punch_node(pos1)
end
end
end
minetest.register_node("technic:power_radiator", {
description = "Power Radiator",
tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("MV_EU_demand",1) -- Demand on the primary side when idle
meta:set_int("connected_EU_demand",0) -- Potential demand of connected appliances
meta:set_string("infotext", "Power Radiator")
end,
on_dig = function(pos, node, digger)
shutdown_inductive_appliances(pos)
return minetest.node_dig(pos, node, digger)
end,
on_punch = function(pos, node, puncher)
toggle_on_off_inductive_appliances(pos, node, puncher)
end
})
minetest.register_craft({
output = 'technic:power_radiator 1',
recipe = {
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
{'technic:copper_coil', 'technic:mv_transformer', 'technic:copper_coil'},
{'technic:rubber', 'technic:mv_cable0', 'technic:rubber'},
}
})
minetest.register_abm({
nodenames = {"technic:power_radiator"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("MV_EU_input")
local eu_demand = meta:get_int("MV_EU_demand")
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "MV")
if eu_input == 0 then
-- No power
meta:set_string("infotext", "Power Radiator is unpowered");
-- meta:set_int("active", 1) -- used for setting textures someday maybe
shutdown_inductive_appliances(pos)
meta:set_int("connected_EU_demand", 0)
meta:set_int("MV_EU_demand",1)
elseif eu_input == eu_demand then
-- Powered and ready
-- The maximum EU sourcing a single radiator can provide.
local max_charge = 30000 -- == the max EU demand of the radiator
local connected_EU_demand = meta:get_int("connected_EU_demand")
-- Efficiency factor
local eff_factor = 0.06
-- The supply radius
local rad = power_radius
local meta1 = nil
local pos1 = {}
local used_charge = 0
-- Index all nodes within supply range
local positions = minetest.find_nodes_in_area(
{x=pos.x-rad, y=pos.y-rad, z=pos.z-rad},
{x=pos.x+rad, y=pos.y+rad, z=pos.z+rad},
technic.inductive_nodes)
for _, pos1 in pairs(positions) do
local meta1 = minetest.get_meta(pos1)
-- If not supplied see if this node can handle it.
if meta1:get_string("has_supply") == "" then
-- if demand surpasses the capacity of this node, don't bother adding it.
local app_eu_demand = math.floor(meta1:get_int("EU_demand") / eff_factor)
if connected_EU_demand + app_eu_demand <= max_charge then
-- We can power the appliance. Register, and spend power if it is on.
connected_EU_demand = connected_EU_demand + app_eu_demand
meta1:set_string("has_supply", pos.x..pos.y..pos.z)
--Always 0: used_charge = math.floor(used_charge + meta1:get_int("EU_charge") / eff_factor)
end
elseif meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
-- The appliance has power from this node. Spend power if it is on.
used_charge = used_charge + math.floor(meta1:get_int("EU_charge") / eff_factor)
end
meta:set_string("infotext", "Power Radiator is powered ("
..math.floor(used_charge / max_charge * 100)
.."% of maximum power)");
if used_charge == 0 then
meta:set_int("MV_EU_demand", 1) -- Still idle
else
meta:set_int("MV_EU_demand", used_charge)
end
end
-- Save state
meta:set_int("connected_EU_demand", connected_EU_demand)
end
end,
})
technic.register_machine("MV", "technic:power_radiator", technic.receiver)

View File

@ -1,12 +0,0 @@
minetest.register_craft({
output = 'technic:solar_array_mv 1',
recipe = {
{'technic:solar_array_lv', 'technic:solar_array_lv', 'technic:solar_array_lv'},
{'default:steel_ingot', 'technic:mv_transformer', 'default:steel_ingot'},
{'', 'technic:mv_cable0', ''},
}
})
technic.register_solar_array({tier="MV", power=30})

View File

@ -1,90 +0,0 @@
-- LV Tool workshop
-- This machine repairs tools.
minetest.register_alias("tool_workshop", "technic:tool_workshop")
minetest.register_craft({
output = 'technic:tool_workshop',
recipe = {
{'group:wood', 'group:wood', 'group:wood'},
{'group:wood', 'default:diamond', 'group:wood'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
local workshop_formspec =
"invsize[8,9;]"..
"list[current_name;src;3,1;1,1;]"..
"label[0,0;Tool Workshop]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node("technic:tool_workshop", {
description = "Tool Workshop",
tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
"technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Tool Workshop")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", workshop_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
end
return true
end,
})
minetest.register_abm({
nodenames = {"technic:tool_workshop"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local eu_input = meta:get_int("MV_EU_input")
local machine_name = "Tool Workshop"
local machine_node = "technic:tool_workshop"
local demand = 5000
-- Setup meta data if it does not exist.
if not eu_input then
meta:set_int("MV_EU_demand", demand)
meta:set_int("MV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "MV")
srcstack = inv:get_stack("src", 1)
if inv:is_empty("src") or
srcstack:get_wear() == 0 or
srcstack:get_name() == "technic:water_can" or
srcstack:get_name() == "technic:lava_can" then
meta:set_string("infotext", machine_name.." Idle")
meta:set_int("MV_EU_demand", 0)
return
end
if eu_input < demand then
meta:set_string("infotext", machine_name.." Unpowered")
elseif eu_input >= demand then
meta:set_string("infotext", machine_name.." Active")
srcstack:add_wear(-1000)
inv:set_stack("src", 1, srcstack)
end
meta:set_int("MV_EU_demand", demand)
end
})
technic.register_machine("MV", "technic:tool_workshop", technic.receiver)

View File

@ -1,88 +0,0 @@
minetest.register_craft({
output = 'technic:wind_mill_frame 5',
recipe = {
{'default:steel_ingot', '', 'default:steel_ingot'},
{'', 'default:steel_ingot', ''},
{'default:steel_ingot', '', 'default:steel_ingot'},
}
})
minetest.register_craft({
output = 'technic:wind_mill',
recipe = {
{'', 'default:steel_ingot', ''},
{'default:steel_ingot', 'technic:motor', 'default:steel_ingot'},
{'', 'default:steelblock', ''},
}
})
minetest.register_node("technic:wind_mill_frame", {
description = "Wind Mill Frame",
drawtype = "glasslike_framed",
tiles = {"default_steel_block.png", "default_glass.png"},
sunlight_propagates = true,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
paramtype = "light",
})
minetest.register_node("technic:wind_mill", {
description = "Wind Mill",
tiles = {"default_steel_block.png"},
paramtype2 = "facedir",
groups = {cracky=1},
sounds = default.node_sound_stone_defaults(),
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Main box
{-0.1, -0.1, -0.5, 0.1, 0.1, -0.6}, -- Shaft
{-0.1, -1, -0.6, 0.1, 1, -0.7}, -- Vertical blades
{-1, -0.1, -0.6, 1, 0.1, -0.7}, -- Horizontal blades
}
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Wind Mill")
meta:set_int("MV_EU_supply", 0)
end,
})
local function check_wind_mill(pos)
if pos.y < 30 then
return false
end
for i = 1, 20 do
local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z})
if node.name ~= "technic:wind_mill_frame" then
return false
end
end
return true
end
minetest.register_abm({
nodenames = {"technic:wind_mill"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local power = math.min(pos.y * 100, 5000)
if not check_wind_mill(pos) then
meta:set_int("MV_EU_supply", 0)
meta:set_string("infotext", "Wind Mill Inproperly Placed")
return
else
meta:set_int("MV_EU_supply", power)
end
meta:set_string("infotext", "Wind Mill ("..power.."EU)")
end
})
technic.register_machine("MV", "technic:wind_mill", technic.producer)

View File

@ -0,0 +1,85 @@
-- Register alloy recipes
technic.alloy_recipes = {}
-- Register recipe in a table
technic.register_alloy_recipe = function(metal1, count1, metal2, count2, result, count3)
technic.alloy_recipes[metal1..metal2] = { src1_count = count1, src2_count = count2, dst_name = result, dst_count = count3 }
if unified_inventory then
unified_inventory.register_craft(
{
type = "alloy",
output = result.." "..count3,
items = {metal1.." "..count1,metal2.." "..count2},
width = 2,
})
end
end
-- Retrieve a recipe given the input metals.
-- Input parameters are a table from a StackItem
technic.get_alloy_recipe = function(metal1, metal2)
-- Check for both combinations of metals and for the right amount in both
if technic.alloy_recipes[metal1.name..metal2.name]
and metal1.count >= technic.alloy_recipes[metal1.name..metal2.name].src1_count
and metal2.count >= technic.alloy_recipes[metal1.name..metal2.name].src2_count then
return technic.alloy_recipes[metal1.name..metal2.name]
elseif technic.alloy_recipes[metal2.name..metal1.name]
and metal2.count >= technic.alloy_recipes[metal2.name..metal1.name].src1_count
and metal1.count >= technic.alloy_recipes[metal2.name..metal1.name].src2_count then
return technic.alloy_recipes[metal2.name..metal1.name]
else
return nil
end
end
technic.register_alloy_recipe("technic:copper_dust", 3, "technic:tin_dust", 1, "technic:bronze_dust", 4)
technic.register_alloy_recipe("moreores:copper_ingot",3, "moreores:tin_ingot", 1, "moreores:bronze_ingot", 4)
technic.register_alloy_recipe("technic:iron_dust", 3, "technic:chromium_dust", 1, "technic:stainless_steel_dust", 4)
technic.register_alloy_recipe("default:steel_ingot", 3, "technic:chromium_ingot",1, "technic:stainless_steel_ingot",4)
technic.register_alloy_recipe("technic:copper_dust", 2, "technic:zinc_dust", 1, "technic:brass_dust", 3)
technic.register_alloy_recipe("moreores:copper_ingot",2, "technic:zinc_ingot", 1, "technic:brass_ingot", 3)
technic.register_alloy_recipe("default:sand", 2, "technic:coal_dust", 2, "technic:silicon_wafer", 1)
technic.register_alloy_recipe("technic:silicon_wafer",1, "technic:gold_dust", 1, "technic:doped_silicon_wafer", 1)
--------------------------------------
-- LEGACY CODE - some other mods might depend on this - Register the same recipes as above...
--------------------------------------
alloy_recipes = {}
registered_recipes_count = 1
function register_alloy_recipe (string1,count1, string2,count2, string3,count3)
alloy_recipes[registered_recipes_count]={}
alloy_recipes[registered_recipes_count].src1_name=string1
alloy_recipes[registered_recipes_count].src1_count=count1
alloy_recipes[registered_recipes_count].src2_name=string2
alloy_recipes[registered_recipes_count].src2_count=count2
alloy_recipes[registered_recipes_count].dst_name=string3
alloy_recipes[registered_recipes_count].dst_count=count3
registered_recipes_count=registered_recipes_count+1
alloy_recipes[registered_recipes_count]={}
alloy_recipes[registered_recipes_count].src1_name=string2
alloy_recipes[registered_recipes_count].src1_count=count2
alloy_recipes[registered_recipes_count].src2_name=string1
alloy_recipes[registered_recipes_count].src2_count=count1
alloy_recipes[registered_recipes_count].dst_name=string3
alloy_recipes[registered_recipes_count].dst_count=count3
registered_recipes_count=registered_recipes_count+1
if unified_inventory then
unified_inventory.register_craft({
type = "alloy",
output = string3.." "..count3,
items = {string1.." "..count1,string2.." "..count2},
width = 2,
})
end
end
register_alloy_recipe ("technic:copper_dust",3, "technic:tin_dust",1, "technic:bronze_dust",4)
register_alloy_recipe ("default:copper_ingot",3, "moreores:tin_ingot",1, "default:bronze_ingot",4)
register_alloy_recipe ("technic:iron_dust",3, "technic:chromium_dust",1, "technic:stainless_steel_dust",4)
register_alloy_recipe ("default:steel_ingot",3, "technic:chromium_ingot",1, "technic:stainless_steel_ingot",4)
register_alloy_recipe ("technic:copper_dust",2, "technic:zinc_dust",1, "technic:brass_dust",3)
register_alloy_recipe ("default:copper_ingot",2, "technic:zinc_ingot",1, "technic:brass_ingot",3)
register_alloy_recipe ("default:sand",2, "technic:coal_dust",2, "technic:silicon_wafer",1)
register_alloy_recipe ("technic:silicon_wafer",1, "technic:gold_dust",1, "technic:doped_silicon_wafer",1)

View File

@ -0,0 +1,80 @@
charge_tools = function(meta, charge, step)
--charge registered power tools
local inv = meta:get_inventory()
if inv:is_empty("src")==false then
local srcstack = inv:get_stack("src", 1)
local src_item=srcstack:to_table()
local src_meta=get_item_meta(src_item["metadata"])
local toolname = src_item["name"]
if technic.power_tools[toolname] ~= nil then
-- Set meta data for the tool if it didn't do it itself :-(
src_meta=get_item_meta(src_item["metadata"])
if src_meta==nil then
src_meta={}
src_meta["technic_power_tool"]=true
src_meta["charge"]=0
else
if src_meta["technic_power_tool"]==nil then
src_meta["technic_power_tool"]=true
src_meta["charge"]=0
end
end
-- Do the charging
local item_max_charge = technic.power_tools[toolname]
local load = src_meta["charge"]
local load_step = step -- how much to charge per tick
if load<item_max_charge and charge>0 then
if charge-load_step<0 then load_step=charge end
if load+load_step>item_max_charge then load_step=item_max_charge-load end
load=load+load_step
charge=charge-load_step
technic.set_RE_wear(src_item,load,item_max_charge)
src_meta["charge"] = load
src_item["metadata"] = set_item_meta(src_meta)
inv:set_stack("src", 1, src_item)
end
end
end
return charge -- return the remaining charge in the battery
end
discharge_tools = function(meta, charge, max_charge, step)
-- discharging registered power tools
local inv = meta:get_inventory()
if inv:is_empty("dst") == false then
srcstack = inv:get_stack("dst", 1)
src_item=srcstack:to_table()
local src_meta=get_item_meta(src_item["metadata"])
local toolname = src_item["name"]
if technic.power_tools[toolname] ~= nil then
-- Set meta data for the tool if it didn't do it itself :-(
src_meta=get_item_meta(src_item["metadata"])
if src_meta==nil then
src_meta={}
src_meta["technic_power_tool"]=true
src_meta["charge"]=0
else
if src_meta["technic_power_tool"]==nil then
src_meta["technic_power_tool"]=true
src_meta["charge"]=0
end
end
-- Do the discharging
local item_max_charge = technic.power_tools[toolname]
local load = src_meta["charge"]
local load_step = step -- how much to discharge per tick
if load>0 and charge<max_charge then
if charge+load_step>max_charge then load_step=max_charge-charge end
if load-load_step<0 then load_step=load end
load=load-load_step
charge=charge+load_step
technic.set_RE_wear(src_item,load,item_max_charge)
src_meta["charge"]=load
src_item["metadata"]=set_item_meta(src_meta)
inv:set_stack("dst", 1, src_item)
end
end
end
return charge -- return the remaining charge in the battery
end

View File

@ -0,0 +1,55 @@
technic.register_grinder_recipe("glooptest:alatro_lump","technic:alatro_dust 2")
technic.register_grinder_recipe("glooptest:kalite_lump","technic:kalite_dust 2")
technic.register_grinder_recipe("glooptest:arol_lump","technic:arol_dust 2")
technic.register_grinder_recipe("glooptest:talinite_lump","technic:talinite_dust 2")
technic.register_grinder_recipe("glooptest:akalin_lump","technic:akalin_dust 2")
 
minetest.register_craftitem("technic:alatro_dust", {
        description = "Alatro Dust",
        inventory_image = "technic_alatro_dust.png",
})
 
minetest.register_craft({
    type = "cooking",
    output = "glooptest:alatro_ingot",
    recipe = "technic:alatro_dust",
})
 
minetest.register_craftitem("technic:arol_dust", {
        description = "Arol Dust",
        inventory_image = "technic_arol_dust.png",
})
 
minetest.register_craft({
    type = "cooking",
    output = "glooptest:arol_ingot",
    recipe = "technic:arol_dust",
})
 
minetest.register_craftitem("technic:talinite_dust", {
        description = "Talinite Dust",
        inventory_image = "technic_talinite_dust.png",
})
 
minetest.register_craft({
    type = "cooking",
    output = "glooptest:talinite_ingot",
    recipe = "technic:talinite_dust",
})
 
minetest.register_craftitem("technic:akalin_dust", {
        description = "Akalin Dust",
        inventory_image = "technic_akalin_dust.png",
})
 
minetest.register_craft({
    type = "cooking",
    output = "glooptest:akalin_ingot",
    recipe = "technic:akalin_dust",
})
 
minetest.register_craftitem("technic:kalite_dust", {
        description = "Kalite Dust",
        inventory_image = "technic_kalite_dust.png",
        on_use = minetest.item_eat(2)
})

View File

@ -1,19 +1,157 @@
local max_charge = 1500000
local max_charge_rate = 3000
local max_discharge_rate = 5000
-- HV battery box
minetest.register_craft({
output = 'technic:hv_battery_box0',
output = 'technic:hv_battery_box 1',
recipe = {
{'technic:mv_battery_box0', 'technic:mv_battery_box0', 'technic:mv_battery_box0'},
{'technic:mv_battery_box0', 'technic:hv_transformer', 'technic:mv_battery_box0'},
{'', 'technic:hv_cable0', ''},
{'technic:mv_battery_box', 'technic:mv_battery_box', 'technic:mv_battery_box'},
{'technic:mv_battery_box', 'technic:hv_transformer', 'technic:mv_battery_box'},
{'', 'technic:hv_cable', ''},
}
})
technic.register_battery_box({
tier = "HV",
max_charge = 1500000,
charge_rate = 100000,
discharge_rate = 400000,
charge_step = 10000,
discharge_step = 40000,
local battery_box_formspec =
"invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;1,1;]"..
"label[0,0;HV Battery Box]"..
"label[3,0;Charge]"..
"label[5,0;Discharge]"..
"label[1,3;Power level]"..
"list[current_player;main;0,5;8,4;]"..
"background[-0.19,-0.25;8.4,9.75;ui_form_bg.png]"..
"background[0,0;8,4;ui_hv_battery_box.png]"..
"background[0,5;8,4;ui_main_inventory.png]"
minetest.register_node("technic:hv_battery_box", {
description = "HV Battery Box",
tiles = {"technic_hv_battery_box_top.png", "technic_hv_battery_box_bottom.png",
"technic_hv_battery_box_side0.png", "technic_hv_battery_box_side0.png",
"technic_hv_battery_box_side0.png", "technic_hv_battery_box_side0.png"},
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
drop = "technic:hv_battery_box",
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
meta:set_string("infotext", "HV Battery Box")
meta:set_float("technic_hv_power_machine", 1)
meta:set_string("formspec", battery_box_formspec)
meta:set_int("HV_EU_demand", 0) -- How much this node can charge
meta:set_int("HV_EU_supply", 0) -- How much this node can discharge
meta:set_int("HV_EU_input", 0) -- How much power this machine is getting.
meta:set_float("internal_EU_charge", 0)
inv:set_size("src", 1)
inv:set_size("dst", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
for i = 1,8,1 do
minetest.register_node("technic:hv_battery_box"..i, {
description = "HV Battery Box",
tiles = {"technic_hv_battery_box_top.png", "technic_hv_battery_box_bottom.png",
"technic_hv_battery_box_side0.png^technic_power_meter"..i..".png",
"technic_hv_battery_box_side0.png^technic_power_meter"..i..".png",
"technic_hv_battery_box_side0.png^technic_power_meter"..i..".png",
"technic_hv_battery_box_side0.png^technic_power_meter"..i..".png"},
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
paramtype="light",
light_source=9,
drop="technic:hv_battery_box",
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
end
minetest.register_abm({
nodenames = {"technic:hv_battery_box", "technic:hv_battery_box1", "technic:hv_battery_box2",
"technic:hv_battery_box3", "technic:hv_battery_box4", "technic:hv_battery_box5",
"technic:hv_battery_box6", "technic:hv_battery_box7", "technic:hv_battery_box8"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("HV_EU_input")
local current_charge = meta:get_int("internal_EU_charge") -- Battery charge right now
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "HV")
-- Charge/discharge the battery with the input EUs
if eu_input >= 0 then
current_charge = math.min(current_charge + eu_input, max_charge)
else
current_charge = math.max(current_charge + eu_input, 0)
end
-- Charging/discharging tools here
current_charge = charge_tools(meta, current_charge, 16000)
current_charge = discharge_tools(meta, current_charge, max_charge, 16000)
-- Set a demand (we allow batteries to charge on less than the demand though)
meta:set_int("HV_EU_demand", math.min(max_charge_rate, max_charge-current_charge))
-- Set how much we can supply
meta:set_int("HV_EU_supply", math.min(max_discharge_rate, current_charge))
meta:set_int("internal_EU_charge", current_charge)
-- Select node textures
local charge_count = math.ceil((current_charge / max_charge) * 8)
if charge_count > 8 then
charge_count = 8
end
local last_count = meta:get_float("last_side_shown")
if charge_count ~= last_count then
if charge_count > 0 then
hacky_swap_node(pos,"technic:hv_battery_box"..charge_count)
else
hacky_swap_node(pos,"technic:hv_battery_box")
end
meta:set_float("last_side_shown", charge_count)
end
local charge_percent = math.floor(current_charge / max_charge * 100)
meta:set_string("formspec",
battery_box_formspec..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"
..charge_percent..":technic_power_meter_fg.png]")
if eu_input == 0 then
meta:set_string("infotext", "HV Battery box: "..current_charge.."/"..max_charge.." (idle)")
else
meta:set_string("infotext", "HV Battery box: "..current_charge.."/"..max_charge)
end
end
})
-- Register as a battery type
-- Battery type machines function as power reservoirs and can both receive and give back power
technic.register_HV_machine("technic:hv_battery_box","BA")
for i=1,8,1 do
technic.register_HV_machine("technic:hv_battery_box"..i,"BA")
end

View File

@ -4,9 +4,8 @@
-- Forcefields are powerful barriers but they consume huge amounts of power.
-- Forcefield Generator is a HV machine.
-- How expensive is the generator?
-- Leaves room for upgrades lowering the power drain?
local forcefield_power_drain = 10
-- How expensive is the generator? Leaves room for upgrades lowering the power drain?
local forcefield_power_drain = 10
local forcefield_step_interval = 1
minetest.register_craft({
@ -42,10 +41,11 @@ local function update_forcefield(pos, range, active)
local vi = area:index(pos.x+(-range), pos.y+y, pos.z+z)
for x=-range, range do
if x*x+y*y+z*z <= range * range + range and
x*x+y*y+z*z >= (range-1) * (range-1) + (range-1) then
if active and data[vi] == c_air then
x*x+y*y+z*z >= (range-1) * (range-1) + (range-1) and
((active and data[vi] == c_air) or ((not active) and data[vi] == c_field)) then
if active then
data[vi] = c_field
elseif not active and data[vi] == c_field then
else
data[vi] = c_air
end
end
@ -61,15 +61,21 @@ local function update_forcefield(pos, range, active)
end
local get_forcefield_formspec = function(range)
return "size[3,1.5]"..
"field[1,0.5;2,1;range;Range;"..range.."]"..
"button[0,1;3,1;toggle;Enable/Disable]"
return "invsize[3,4;]"..
"label[0,0;Forcefield emitter]"..
"label[1,1;Range]"..
"label[1,2;"..range.."]"..
"button[0,2;1,1;subtract;-]"..
"button[2,2;1,1;add;+]"..
"button[0,3;3,1;toggle;Enable/Disable]"
end
local forcefield_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local range = fields.range
local meta = minetest.env:get_meta(pos)
local range = meta:get_int("range")
if fields.add then range = range + 1 end
if fields.subtract then range = range - 1 end
if fields.toggle then
if meta:get_int("enabled") == 1 then
meta:set_int("enabled", 0)
@ -80,40 +86,87 @@ local forcefield_receive_fields = function(pos, formname, fields, sender)
-- Smallest field is 5. Anything less is asking for trouble.
-- Largest is 20. It is a matter of pratical node handling.
-- At the maximim range updating the forcefield takes about 0.2s
range = math.max(range, 5)
range = math.min(range, 20)
if range < 5 then range = 5 end
if range > 20 then range = 20 end
if meta:get_int("range") ~= range then
if range <= 20 and range >= 5 and meta:get_int("range") ~= range then
update_forcefield(pos, meta:get_int("range"), false)
meta:set_int("range", range)
meta:set_string("formspec", get_forcefield_formspec(range))
end
end
local function forcefield_step(pos)
local meta = minetest.env:get_meta(pos)
local node = minetest.env:get_node(pos)
local eu_input = meta:get_int("HV_EU_input")
local eu_demand = meta:get_int("HV_EU_demand")
local enabled = meta:get_int("enabled")
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "HV")
local power_requirement = 0
if enabled == 1 then
power_requirement = math.floor(
4 * math.pi * math.pow(meta:get_int("range"), 2)
) * forcefield_power_drain
else
power_requirement = eu_demand
end
if meta:get_int("enabled") == 0 then
if node.name == "technic:forcefield_emitter_on" then
update_forcefield(pos, meta:get_int("range"), false)
hacky_swap_node(pos, "technic:forcefield_emitter_off")
meta:set_int("HV_EU_demand", 100)
meta:set_string("infotext", "Forcefield Generator Disabled")
end
elseif eu_input < power_requirement then
meta:set_string("infotext", "Forcefield Generator Unpowered")
if node.name == "technic:forcefield_emitter_on" then
update_forcefield(pos, meta:get_int("range"), false)
hacky_swap_node(pos, "technic:forcefield_emitter_off")
end
elseif eu_input >= power_requirement then
if node.name == "technic:forcefield_emitter_off" then
hacky_swap_node(pos, "technic:forcefield_emitter_on")
meta:set_string("infotext", "Forcefield Generator Active")
end
update_forcefield(pos, meta:get_int("range"), true)
end
meta:set_int("HV_EU_demand", power_requirement)
return true
end
local mesecons = {
effector = {
action_on = function(pos, node)
minetest.get_meta(pos):set_int("enabled", 0)
minetest.env:get_meta(pos):set_int("enabled", 0)
end,
action_off = function(pos, node)
minetest.get_meta(pos):set_int("enabled", 1)
minetest.env:get_meta(pos):set_int("enabled", 1)
end
}
}
minetest.register_node("technic:forcefield_emitter_off", {
description = "Forcefield emitter",
inventory_image = minetest.inventorycube("technic_forcefield_emitter_off.png"),
tiles = {"technic_forcefield_emitter_off.png"},
is_ground_content = true,
groups = {cracky = 1},
on_timer = forcefield_step,
on_receive_fields = forcefield_receive_fields,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
minetest.env:get_node_timer(pos):start(forcefield_step_interval)
local meta = minetest.env:get_meta(pos)
meta:set_float("technic_hv_power_machine", 1)
meta:set_int("HV_EU_input", 0)
meta:set_int("HV_EU_demand", 0)
meta:set_int("range", 10)
meta:set_int("enabled", 0)
meta:set_string("formspec", get_forcefield_formspec(10))
meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range")))
meta:set_string("infotext", "Forcefield emitter");
end,
mesecons = mesecons
@ -122,17 +175,25 @@ minetest.register_node("technic:forcefield_emitter_off", {
minetest.register_node("technic:forcefield_emitter_on", {
description = "Forcefield emitter on (you hacker you)",
tiles = {"technic_forcefield_emitter_on.png"},
is_ground_content = true,
groups = {cracky = 1, not_in_creative_inventory=1},
drop = "technic:forcefield_emitter_off",
drop='"technic:forcefield_emitter_off" 1',
on_timer = forcefield_step,
on_receive_fields = forcefield_receive_fields,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local range = meta:get_int("range")
meta:set_string("formspec", get_forcefield_formspec(range))
minetest.env:get_node_timer(pos):start(forcefield_step_interval)
local meta = minetest.env:get_meta(pos)
-- meta:set_float("technic_hv_power_machine", 1)
-- meta:set_float("HV_EU_input", 0)
-- meta:set_float("HV_EU_demand", 0)
-- meta:set_int("range", 10)
-- meta:set_int("enabled", 1)
meta:set_string("formspec", get_forcefield_formspec(meta:get_int("range")))
-- meta:set_string("infotext", "Forcefield emitter");
end,
on_destruct = function(pos)
local meta = minetest.get_meta(pos)
update_forcefield(pos, meta:get_int("range"), false)
on_dig = function(pos, node, digger)
update_forcefield(pos, minetest.env:get_meta(pos):get_int("range"), false)
return minetest.node_dig(pos, node, digger)
end,
mesecons = mesecons
})
@ -140,67 +201,28 @@ minetest.register_node("technic:forcefield_emitter_on", {
minetest.register_node("technic:forcefield", {
description = "Forcefield (you hacker you)",
sunlight_propagates = true,
drawtype = "glasslike",
groups = {not_in_creative_inventory=1, unbreakable=1},
paramtype = "light",
light_source = 15,
drop = '',
light_source = 8,
tiles = {{
name = "technic_forcefield_animated.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.0,
aspect_w=16,
aspect_h=16,
length=2.0,
},
}},
})
minetest.register_abm({
nodenames = {"technic:forcefield_emitter_on", "technic:forcefield_emitter_off"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local eu_input = meta:get_int("HV_EU_input")
local eu_demand = meta:get_int("HV_EU_demand")
local enabled = meta:get_int("enabled")
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "HV")
local power_requirement = math.floor(
4 * math.pi * math.pow(meta:get_int("range"), 2)
) * forcefield_power_drain
if meta:get_int("enabled") == 0 then
if node.name == "technic:forcefield_emitter_on" then
meta:set_int("HV_EU_demand", 0)
update_forcefield(pos, meta:get_int("range"), false)
hacky_swap_node(pos, "technic:forcefield_emitter_off")
meta:set_string("infotext", "Forcefield Generator Disabled")
return
end
elseif eu_input < power_requirement then
meta:set_string("infotext", "Forcefield Generator Unpowered")
if node.name == "technic:forcefield_emitter_on" then
update_forcefield(pos, meta:get_int("range"), false)
hacky_swap_node(pos, "technic:forcefield_emitter_off")
end
elseif eu_input >= power_requirement then
if node.name == "technic:forcefield_emitter_off" then
hacky_swap_node(pos, "technic:forcefield_emitter_on")
meta:set_string("infotext", "Forcefield Generator Active")
end
update_forcefield(pos, meta:get_int("range"), true)
end
meta:set_int("HV_EU_demand", power_requirement)
end
is_ground_content = true,
groups = { not_in_creative_inventory=1, unbreakable=1 },
paramtype = "light",
drawtype = "nodebox",
node_box = { --hacky way to get the field blue and not see through the ground
type = "fixed",
fixed={
{-.5,-.5,-.5,.5,.5,.5},
},
},
})
if minetest.get_modpath("mesecons_mvps") then
mesecon:register_mvps_stopper("technic:forcefield")
end
-- TODO: Register a stopper for frames
technic.register_machine("HV", "technic:forcefield_emitter_on", technic.receiver)
technic.register_machine("HV", "technic:forcefield_emitter_off", technic.receiver)
technic.register_HV_machine("technic:forcefield_emitter_on", "RE")
technic.register_HV_machine("technic:forcefield_emitter_off", "RE")

View File

@ -1,11 +1,7 @@
local path = technic.modpath.."/machines/hv"
technic.register_tier("HV", "High Voltage")
local path = technic.modpath.."/machines/HV"
dofile(path.."/cables.lua")
dofile(path.."/quarry.lua")
dofile(path.."/forcefield.lua")
dofile(path.."/wires.lua")
dofile(path.."/battery_box.lua")
dofile(path.."/solar_array.lua")
dofile(path.."/nuclear_reactor.lua")

View File

@ -6,9 +6,9 @@
-- The nuclear reactor core needs water and a protective shield to work.
-- This is checked now and then and if the machine is tampered with... BOOM!
local burn_ticks = 7 * 24 * 60 * 60 -- (seconds).
local power_supply = 100000 -- EUs
local fuel_type = "technic:uranium_fuel" -- The reactor burns this stuff
local burn_ticks = 24*60 -- [minutes]. How many minutes does the power plant burn per serving?
local power_supply = 10000 -- [HV] EUs
local fuel_type = "technic:enriched_uranium" -- The reactor burns this stuff
-- FIXME: recipe must make more sense like a rod recepticle, steam chamber, HV generator?
@ -21,8 +21,14 @@ minetest.register_craft({
}
})
minetest.register_craftitem("technic:hv_nuclear_reactor_core",{
description = "Uranium Rod Driven HV Reactor",
stack_max = 1,
})
local generator_formspec =
"invsize[8,9;]"..
--"image[0,0;5,5;technic_generator_menu.png]"..
"label[0,0;Nuclear Reactor Rod Compartment]"..
"list[current_name;src;2,1;3,2;]"..
"list[current_player;main;0,5;8,4;]"
@ -57,29 +63,26 @@ minetest.register_node("technic:hv_nuclear_reactor_core", {
sounds = default.node_sound_wood_defaults(),
drawtype="nodebox",
paramtype = "light",
stack_max = 1,
node_box = {
type = "fixed",
fixed = nodebox
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Nuclear Reactor Core")
meta:set_float("technic_hv_power_machine", 1)
meta:set_int("HV_EU_supply", 0)
-- Signal to the switching station that this device burns some
-- sort of fuel and needs special handling
meta:set_int("HV_EU_from_fuel", 1)
meta:set_int("HV_EU_from_fuel", 1) -- Signal to the switching station that this device burns some sort of fuel and needs special handling
meta:set_int("burn_time", 0)
meta:set_string("formspec", generator_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 6)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
@ -88,7 +91,7 @@ minetest.register_node("technic:hv_nuclear_reactor_core", {
})
minetest.register_node("technic:hv_nuclear_reactor_core_active", {
description = "HV Uranium Reactor",
description = "Uranium Rod Driven HV Reactor",
tiles = {"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png",
"technic_hv_nuclear_reactor_core.png", "technic_hv_nuclear_reactor_core.png"},
@ -104,11 +107,10 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", {
fixed = nodebox
},
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
@ -117,89 +119,62 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", {
})
local check_reactor_structure = function(pos)
-- The reactor consists of a 9x9x9 cube structure
-- The reactor consists of an 11x11x11 cube structure
-- A cross section through the middle:
-- CCCC CCCC
-- CBBB BBBC
-- CBSS SSBC
-- CBSWWWSBC
-- CBSW#WSBC
-- CBSW|WSBC
-- CBSS|SSBC
-- CBBB|BBBC
-- CCCC|CCCC
-- C = Concrete, B = Blast resistant concrete, S = Stainless Steel,
-- W = water node, # = reactor core, | = HV cable
-- CCCCC CCCCC
-- CCCCC CCCCC
-- CCSSS SSSCC
-- CCSCC CCSCC
-- CCSCWWWCSCC
-- CCSCW#WCSCC
-- CCSCW|WCSCC
-- CCSCC|CCSCC
-- CCSSS|SSSCC
-- CCCCC|CCCCC
-- C = Concrete, S = Stainless Steel, W = water node (not floating), #=reactor core, |=HV cable
-- The man-hole and the HV cable is only in the middle
-- The man-hole is optional
local vm = VoxelManip()
local pos1 = vector.subtract(pos, 4)
local pos2 = vector.add(pos, 4)
local MinEdge, MaxEdge = vm:read_from_map(pos1, pos2)
local data = vm:get_data()
local area = VoxelArea:new({MinEdge=MinEdge, MaxEdge=MaxEdge})
local source_water_nodes = minetest.find_nodes_in_area(
{x=pos.x-1, y=pos.y-1, z=pos.z-1},
{x=pos.x+1, y=pos.y+1, z=pos.z+1},
"default:water_source")
local flowing_water_nodes = minetest.find_nodes_in_area(
{x=pos.x-1, y=pos.y-1, z=pos.z-1},
{x=pos.x+1, y=pos.y+1, z=pos.z+1},
"default:water_flowing")
if not ((#source_water_nodes + #flowing_water_nodes) >= 25) then
return false
end
local c_concrete = minetest.get_content_id("technic:concrete")
local c_blast_concrete = minetest.get_content_id("technic:blast_resistant_concrete")
local c_stainless_steel = minetest.get_content_id("technic:stainless_steel_block")
local c_water_source = minetest.get_content_id("default:water_source")
local c_water_flowing = minetest.get_content_id("default:water_flowing")
local inner_shield_nodes = minetest.find_nodes_in_area(
{x=pos.x-2, y=pos.y-2, z=pos.z-2},
{x=pos.x+2, y=pos.y+2, z=pos.z+2},
"technic:concrete")
if not (#inner_shield_nodes >= 96) then
return false
end
local concretelayer, blastlayer, steellayer, waterlayer = 0, 0, 0, 0
local steel_shield_nodes = minetest.find_nodes_in_area(
{x=pos.x-3, y=pos.y-3, z=pos.z-3},
{x=pos.x+3, y=pos.y+3, z=pos.z+3},
"default:steelblock")
if not (#steel_shield_nodes >= 216) then
return false
end
for z = pos1.z, pos2.z do
for y = pos1.y, pos2.y do
for x = pos1.x, pos2.x do
-- If the position is in the outer layer
if x == pos1.x or x == pos2.x or
y == pos1.y or y == pos2.y or
z == pos1.z or z == pos2.z then
if data[area:index(x, y, z)] == c_concrete then
concretelayer = concretelayer + 1
end
elseif x == pos1.x+1 or x == pos2.x-1 or
y == pos1.y+1 or y == pos2.y-1 or
z == pos1.z+1 or z == pos2.z-1 then
if data[area:index(x, y, z)] == c_blast_concrete then
blastlayer = blastlayer + 1
end
elseif x == pos1.x+2 or x == pos2.x-2 or
y == pos1.y+2 or y == pos2.y-2 or
z == pos1.z+2 or z == pos2.z-2 then
if data[area:index(x, y, z)] == c_stainless_steel then
steellayer = steellayer + 1
end
elseif x == pos1.x+3 or x == pos2.x-3 or
y == pos1.y+3 or y == pos2.y-3 or
z == pos1.z+3 or z == pos2.z-3 then
local cid = data[area:index(x, y, z)]
if cid == c_water_source or cid == c_water_flowing then
waterlayer = waterlayer + 1
end
end
end
end
end
if waterlayer >= 25 and
steellayer >= 96 and
blastlayer >= 216 and
concretelayer >= 384 then
return true
local outer_shield_nodes = minetest.find_nodes_in_area(
{x=pos.x-5, y=pos.y-5, z=pos.z-5},
{x=pos.x+5, y=pos.y+5, z=pos.z+5},
"technic:concrete")
if not (#outer_shield_nodes >= (984 + #inner_shield_nodes)) then
return false
end
return true
end
local explode_reactor = function(pos)
print("A reactor exploded at "..minetest.pos_to_string(pos))
end
local function damage_nearby_players(pos)
local objs = minetest.get_objects_inside_radius(pos, 4)
for _, o in pairs(objs) do
if o:is_player() then
o:set_hp(math.max(o:get_hp() - 2, 0))
end
end
print("BOOM A reactor exploded!")
end
minetest.register_abm({
@ -207,53 +182,64 @@ minetest.register_abm({
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local burn_time = meta:get_int("burn_time") or 0
local meta = minetest.env:get_meta(pos)
local burn_time = meta:get_int("burn_time")
if burn_time >= burn_ticks or burn_time == 0 then
-- If more to burn and the energy produced was used: produce some more
if burn_time > 0 then
if not check_reactor_structure(pos) then
explode_reactor(pos)
end
if meta:get_int("HV_EU_supply") == 0 then
-- We did not use the power
meta:set_int("HV_EU_supply", power_supply)
else
burn_time = burn_time - 1
meta:set_int("burn_time", burn_time)
local percent = math.floor(burn_time / (burn_ticks * 60) * 100)
meta:set_string("infotext", "Nuclear Reactor Core ("..percent.."%)")
end
end
-- Burn another piece of coal
if burn_time <= 0 then
local inv = meta:get_inventory()
local correct_fuel_count = 0
if not inv:is_empty("src") then
local srclist = inv:get_list("src")
local correct_fuel_count = 0
for _, srcstack in pairs(srclist) do
if srcstack then
if srcstack:get_name() == fuel_type then
local src_item=srcstack:to_table()
if src_item and src_item["name"] == fuel_type then
correct_fuel_count = correct_fuel_count + 1
end
end
end
-- Check that the reactor is complete as well
-- as the correct number of correct fuel
if correct_fuel_count == 6 and
check_reactor_structure(pos) then
meta:set_int("burn_time", 1)
hacky_swap_node(pos, "technic:hv_nuclear_reactor_core_active")
meta:set_int("HV_EU_supply", power_supply)
for idx, srcstack in pairs(srclist) do
srcstack:take_item()
inv:set_stack("src", idx, srcstack)
-- Check that the reactor is complete as well as the correct number of correct fuel
if correct_fuel_count == 6 then
if not check_reactor_structure(pos) then
burn_time = burn_ticks * 60
meta:set_int("burn_time", burn_time)
hacky_swap_node (pos,"technic:hv_nuclear_reactor_core_active")
meta:set_int("HV_EU_supply", power_supply)
for idx, srcstack in pairs(srclist) do
srcstack:take_item()
inv:set_stack("src", idx, srcstack)
end
end
return
else
meta:set_int("HV_EU_supply", 0)
end
end
meta:set_int("HV_EU_supply", 0)
meta:set_int("burn_time", 0)
end
-- Nothing left to burn
if burn_time == 0 then
meta:set_string("infotext", "Nuclear Reactor Core (idle)")
hacky_swap_node(pos, "technic:hv_nuclear_reactor_core")
elseif burn_time > 0 then
damage_nearby_players(pos)
if not check_reactor_structure(pos) then
explode_reactor(pos)
end
burn_time = burn_time + 1
meta:set_int("burn_time", burn_time)
local percent = math.floor(burn_time / burn_ticks * 100)
meta:set_string("infotext", "Nuclear Reactor Core ("..percent.."%)")
meta:set_int("HV_EU_supply", power_supply)
hacky_swap_node(pos,"technic:hv_nuclear_reactor_core")
end
end
})
technic.register_machine("HV", "technic:hv_nuclear_reactor_core", technic.producer)
technic.register_machine("HV", "technic:hv_nuclear_reactor_core_active", technic.producer)
technic.register_HV_machine ("technic:hv_nuclear_reactor_core","PR")
technic.register_HV_machine ("technic:hv_nuclear_reactor_core_active","PR")

View File

@ -1,14 +1,78 @@
-- The high voltage solar array is an assembly of medium voltage arrays.
-- The assembly can deliver high voltage levels and is a 20% less efficient
-- compared to 5 individual medium voltage arrays due to losses in the transformer.
-- However high voltage is supplied.
-- Solar arrays are not able to store large amounts of energy.
minetest.register_craft({
output = 'technic:solar_array_hv 1',
recipe = {
{'technic:solar_array_mv', 'technic:solar_array_mv', 'technic:solar_array_mv'},
{'default:steel_ingot', 'technic:hv_transformer', 'default:steel_ingot'},
{'', 'technic:hv_cable0', ''},
}
minetest.register_node("technic:solar_array_hv", {
tiles = {"technic_hv_solar_array_top.png", "technic_hv_solar_array_bottom.png", "technic_hv_solar_array_side.png",
"technic_hv_solar_array_side.png", "technic_hv_solar_array_side.png", "technic_hv_solar_array_side.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
description="HV Solar Array",
active = false,
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_float("technic_hv_power_machine", 1)
meta:set_int("HV_EU_supply", 0)
meta:set_string("infotext", "HV Solar Array")
end,
})
technic.register_solar_array({tier="HV", power=100})
minetest.register_craft(
{output = 'technic:solar_array_hv 1',
recipe = {
{'technic:solar_array_mv', 'technic:solar_array_mv','technic:solar_array_mv'},
{'technic:solar_array_mv', 'technic:hv_transformer','technic:solar_array_mv'},
{'default:steel_ingot', 'technic:hv_cable', 'default:steel_ingot'},
}
})
minetest.register_abm(
{nodenames = {"technic:solar_array_hv"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
-- The action here is to make the solar array produce power
-- Power is dependent on the light level and the height above ground
-- 130m and above is optimal as it would be above cloud level.
-- Height gives 1/4 of the effect, light 3/4. Max. effect is 2880EU for the array.
-- There are many ways to cheat by using other light sources like lamps.
-- As there is no way to determine if light is sunlight that is just a shame.
-- To take care of some of it solar panels do not work outside daylight hours or if
-- built below -10m
local pos1={}
pos1.y=pos.y+1
pos1.x=pos.x
pos1.z=pos.z
local light = minetest.env:get_node_light(pos1, nil)
local time_of_day = minetest.env:get_timeofday()
local meta = minetest.env:get_meta(pos)
if light == nil then light = 0 end
-- turn on array only during day time and if sufficient light
-- I know this is counter intuitive when cheating by using other light sources.
if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
local charge_to_give = math.floor(light*(light*9.6+pos1.y/130*48))
if charge_to_give<0 then charge_to_give=0 end
if charge_to_give>2880 then charge_to_give=2880 end
meta:set_string("infotext", "Solar Array is active ("..charge_to_give.."EU)")
meta:set_int("HV_EU_supply", charge_to_give)
else
meta:set_string("infotext", "Solar Array is inactive");
meta:set_int("HV_EU_supply", 0)
end
end,
})
technic.register_HV_machine ("technic:solar_array_hv","PR")

View File

@ -0,0 +1,398 @@
--HV cable node boxes
minetest.register_craft({
output = 'technic:hv_cable 3',
recipe ={
{'technic:rubber','technic:rubber','technic:rubber'},
{'technic:mv_cable','technic:mv_cable','technic:mv_cable'},
{'technic:rubber','technic:rubber','technic:rubber'},
}
})
minetest.register_craftitem("technic:hv_cable", {
description = "Gigh Voltage Copper Cable",
stack_max = 99,
})
minetest.register_node("technic:hv_cable", {
description = "High Voltage Copper Cable",
tiles = {"technic_hv_cable.png"},
inventory_image = "technic_hv_cable_wield.png",
wield_image = "technic_hv_cable_wield.png",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
drop = "technic:hv_cable",
hv_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.125 , -0.125 , -0.125 , 0.125 , 0.125 , 0.125 },
}},
on_construct = function(pos)
meta=minetest.env:get_meta(pos)
meta:set_float("hv_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)
HV_check_connections (pos)
end,
after_dig_node = function (pos, oldnode, oldmetadata, digger)
HV_check_connections_on_destroy (pos)
end,
})
str_y1= { -0.125 , -0.125 , -0.125 , 0.125 , 0.5, 0.125 } --0 y+
str_x1= { -0.125 , -0.125 , -0.125 , 0.5, 0.125 , 0.125 } --0 x+
str_z1= { -0.125 , -0.125 , 0.125 , 0.125 , 0.125 , 0.5 } --0 z+
str_z2= { -0.125 , -0.125, -0.5 , 0.125 , 0.125 , 0.125 } --0 z-
str_y2= { -0.125 , -0.5, -0.125 , 0.125 , 0.125 , 0.125 } --0 y-
str_x2= { -0.5 , -0.125, -0.125 , 0.125 , 0.125 , 0.125 } --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:hv_cable"..count, {
description = "High Voltage Copper Cable",
tiles = {"technic_hv_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:hv_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)
HV_check_connections_on_destroy (pos)
end,
})
count=count+1 end end end end end end
HV_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("hv_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:hv_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:hv_cable"..rule)
end
pos1.x=pos1.x-2
if minetest.env:get_meta(pos1):get_float("hv_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:hv_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:hv_cable"..rule)
end
pos1.x=pos1.x+1
pos1.y=pos1.y+1
if minetest.env:get_meta(pos1):get_float("hv_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:hv_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:hv_cable"..rule)
end
if minetest.env:get_meta(pos1):get_float("technic_hv_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:hv_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("hv_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:hv_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:hv_cable"..rule)
end
pos1.y=pos1.y+1
pos1.z=pos1.z+1
if minetest.env:get_meta(pos1):get_float("hv_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:hv_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:hv_cable"..rule)
end
pos1.z=pos1.z-2
if minetest.env:get_meta(pos1):get_float("hv_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:hv_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:hv_cable"..rule)
end
pos1.z=pos1.z+1
end
HV_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("hv_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:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_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("hv_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:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_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("hv_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:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_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("hv_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:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_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("hv_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:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_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("hv_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:hv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:hv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("z1",z1)
end
pos1.y=pos1.y+1
end

View File

@ -1,14 +1,11 @@
local path = technic.modpath.."/machines"
dofile(path.."/register/init.lua")
-- Tiers
dofile(path.."/LV/init.lua")
dofile(path.."/MV/init.lua")
dofile(path.."/HV/init.lua")
dofile(path.."/switching_station.lua")
dofile(path.."/supply_converter.lua")
dofile(path.."/alloy_furnaces_commons.lua")
dofile(path.."/battery_boxes_commons.lua")
dofile(path.."/lv/init.lua")
dofile(path.."/mv/init.lua")
dofile(path.."/hv/init.lua")
dofile(path.."/other/init.lua")

View File

@ -1,14 +1,367 @@
-- LV Alloy furnace
minetest.register_craft({
output = 'technic:coal_alloy_furnace',
recipe = {
{'default:brick', 'default:brick', 'default:brick'},
{'default:brick', '', 'default:brick'},
{'default:brick', 'default:brick', 'default:brick'},
}
})
-- FIXME: kpoppel: I'd like to introduce an induction heating element here...
minetest.register_craft({
output = 'technic:lv_alloy_furnace',
output = 'technic:alloy_furnace',
recipe = {
{'default:brick', 'default:brick', 'default:brick'},
{'default:brick', '', 'default:brick'},
{'default:brick', 'default:brick', 'default:brick'},
{'default:brick', '', 'default:brick'},
{'default:steel_ingot', 'default:copper_ingot', 'default:steel_ingot'},
}
})
technic.register_alloy_furnace({tier="LV", cook_time=6, demand={300}})
local alloy_furnace_formspec =
"invsize[8,9;]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;src2;3,2;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"..
"label[0,0;Electric Alloy Furnace]"
minetest.register_node(
"technic:alloy_furnace",
{
description = "Electric alloy furnace",
tiles = {"technic_alloy_furnace_top.png", "technic_machine_bottom.png", "technic_alloy_furnace_side.png",
"technic_alloy_furnace_side.png", "technic_alloy_furnace_side.png", "technic_alloy_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Electric Alloy furnace")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", alloy_furnace_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("src2", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("src2") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node(
"technic:alloy_furnace_active",
{
description = "Alloy Furnace",
tiles = {"technic_alloy_furnace_top.png", "technic_machine_bottom.png", "technic_alloy_furnace_side.png",
"technic_alloy_furnace_side.png", "technic_alloy_furnace_side.png", "technic_alloy_furnace_front_active.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "technic:alloy_furnace",
groups = {cracky=2,not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("src2") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_abm(
{ nodenames = {"technic:alloy_furnace","technic:alloy_furnace_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local state = meta:get_int("state")
local next_state = state
-- Machine information
local machine_name = "Electric Alloy Furnace"
local machine_node = "technic:alloy_furnace"
local machine_state_demand = { 50, 600 }
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("LV_EU_demand", machine_state_demand[1])
meta:set_int("LV_EU_input", 0)
meta:set_int("tube_time", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
-- State machine
if eu_input == 0 then
-- Unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
-- Execute always if powered logic
local inv = meta:get_inventory()
local empty = 1
local recipe = nil
local result = nil
-- Get what to cook if anything
local srcstack = inv:get_stack("src", 1)
local src2stack = inv:get_stack("src2", 1)
local src_item1 = nil
local src_item2 = nil
if srcstack and src2stack then
src_item1 = srcstack:to_table()
src_item2 = src2stack:to_table()
empty = 0
end
if src_item1 and src_item2 then
recipe = technic.get_alloy_recipe(src_item1,src_item2)
end
if recipe then
result = { name=recipe.dst_name, count=recipe.dst_count}
end
if recipe then
print("recipe "..recipe.dst_name.." : result "..result.name.." : empty "..empty.." : src_item1 "..src_item1.name.." : src_item2 "..src_item2.name)
end
if state == 1 then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
if empty == 0 and recipe and inv:room_for_item("dst", result) then
meta:set_string("infotext", machine_name.." Active")
meta:set_string("src_time", 0)
next_state = 2
end
elseif state == 2 then
hacky_swap_node(pos, machine_node.."_active")
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") == 4 then -- 4 ticks per output
meta:set_string("src_time", 0)
-- check if there's room for output in "dst" list and that we have the materials
if recipe and inv:room_for_item("dst", result) then
-- Take stuff from "src" list
srcstack:take_item(recipe.src1_count)
inv:set_stack("src", 1, srcstack)
src2stack:take_item(recipe.src2_count)
inv:set_stack("src2", 1, src2stack)
-- Put result in "dst" list
inv:add_item("dst",result)
else
next_state = 1
end
end
end
-- Change state?
if next_state ~= state then
meta:set_int("LV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
end
end,
})
technic.register_LV_machine ("technic:alloy_furnace","RE")
technic.register_LV_machine ("technic:alloy_furnace_active","RE")
--------------------------------------------------
-- coal driven alloy furnace. This uses no EUs:
--------------------------------------------------
coal_alloy_furnace_formspec =
"size[8,9]"..
"label[0,0;Alloy Furnace]"..
"image[2,2;1,1;default_furnace_fire_bg.png]"..
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;src;2,1;1,1;]"..
"list[current_name;src2;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node("technic:coal_alloy_furnace", {
description = "Alloy Furnace",
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png",
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", coal_alloy_furnace_formspec)
meta:set_string("infotext", "Alloy Furnace")
local inv = meta:get_inventory()
inv:set_size("fuel", 1)
inv:set_size("src", 1)
inv:set_size("src2", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not (inv:is_empty("fuel") or inv:is_empty("dst") or inv:is_empty("src") or inv:is_empty("src2") )then
return false
end
return true
end,
})
minetest.register_node("technic:coal_alloy_furnace_active", {
description = "Alloy Furnace",
tiles = {"technic_coal_alloy_furnace_top.png", "technic_coal_alloy_furnace_bottom.png", "technic_coal_alloy_furnace_side.png",
"technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_side.png", "technic_coal_alloy_furnace_front_active.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "technic:coal_alloy_furnace",
groups = {cracky=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not (inv:is_empty("fuel") or inv:is_empty("dst") or inv:is_empty("src") or inv:is_empty("src2") )then
return false
end
return true
end,
})
minetest.register_abm({
nodenames = {"technic:coal_alloy_furnace","technic:coal_alloy_furnace_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
for i, name in pairs({
"fuel_totaltime",
"fuel_time",
"src_totaltime",
"src_time"
}) do
if meta:get_string(name) == "" then
meta:set_float(name, 0.0)
end
end
local inv = meta:get_inventory()
local recipe = nil
-- Get what to cook if anything
local srcstack = inv:get_stack("src", 1)
if srcstack then src_item1=srcstack:to_table() end
local src2stack = inv:get_stack("src2", 1)
if src2stack then src_item2=src2stack:to_table() end
if src_item1 and src_item2 then
recipe = technic.get_alloy_recipe(src_item1,src_item2)
end
local was_active = false
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
was_active = true
meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
meta:set_float("src_time", meta:get_float("src_time") + 1)
if recipe and meta:get_float("src_time") == 6 then
-- check if there's room for output in "dst" list
local dst_stack = { name=recipe.dst_name, count=recipe.dst_count}
if inv:room_for_item("dst",dst_stack) then
-- Take stuff from "src" list
srcstack:take_item(recipe.src1_count)
inv:set_stack("src", 1, srcstack)
src2stack:take_item(recipe.src2_count)
inv:set_stack("src2", 1, src2stack)
-- Put result in "dst" list
inv:add_item("dst",dst_stack)
else
print("Furnace inventory full!") -- Silly code...
end
meta:set_string("src_time", 0)
end
end
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
local percent = math.floor(meta:get_float("fuel_time") /
meta:get_float("fuel_totaltime") * 100)
meta:set_string("infotext","Furnace active: "..percent.."%")
hacky_swap_node(pos,"technic:coal_alloy_furnace_active")
meta:set_string("formspec",
"size[8,9]"..
"label[0,0;Electric Alloy Furnace]"..
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
(100-percent)..":default_furnace_fire_fg.png]"..
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;src;2,1;1,1;]"..
"list[current_name;src2;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]")
return
end
-- FIXME: Make this look more like the electrical version.
-- This code refetches the recipe to see if it can be done again after the iteration
srcstack = inv:get_stack("src", 1)
if srcstack then src_item1=srcstack:to_table() end
srcstack = inv:get_stack("src2", 1)
if srcstack then src_item2=srcstack:to_table() end
if src_item1 and src_item2 then
recipe = technic.get_alloy_recipe(src_item1,src_item2)
end
if recipe==nil then
if was_active then
meta:set_string("infotext","Furnace is empty")
hacky_swap_node(pos,"technic:coal_alloy_furnace")
meta:set_string("formspec", coal_alloy_furnace_formspec)
end
return
end
-- Next take a hard look at the fuel situation
local fuel = nil
local fuellist = inv:get_list("fuel")
if fuellist then
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
end
if fuel.time <= 0 then
meta:set_string("infotext","Furnace out of fuel")
hacky_swap_node(pos,"technic:coal_alloy_furnace")
meta:set_string("formspec", coal_alloy_furnace_formspec)
return
end
meta:set_string("fuel_totaltime", fuel.time)
meta:set_string("fuel_time", 0)
local stack = inv:get_stack("fuel", 1)
stack:take_item()
inv:set_stack("fuel", 1, stack)
end,
})

View File

@ -1,16 +1,15 @@
-- LV Battery box and some other nodes...
technic.register_power_tool("technic:battery", 10000)
technic.register_power_tool("technic:red_energy_crystal", 100000)
technic.register_power_tool("technic:green_energy_crystal", 250000)
technic.register_power_tool("technic:blue_energy_crystal", 500000)
technic.register_power_tool("technic:battery",10000)
technic.register_power_tool("technic:red_energy_crystal",100000)
technic.register_power_tool("technic:green_energy_crystal",250000)
technic.register_power_tool("technic:blue_energy_crystal",500000)
minetest.register_craft({
output = 'technic:battery',
output = 'technic:battery 1',
recipe = {
{'group:wood', 'default:copper_ingot', 'group:wood'},
{'group:wood', 'moreores:tin_ingot', 'group:wood'},
{'group:wood', 'default:copper_ingot', 'group:wood'},
{'default:wood', 'default:copper_ingot', 'default:wood'},
{'default:wood', 'moreores:tin_ingot', 'default:wood'},
{'default:wood', 'default:copper_ingot', 'default:wood'},
}
})
@ -18,29 +17,172 @@ minetest.register_tool("technic:battery", {
description = "RE Battery",
inventory_image = "technic_battery.png",
tool_capabilities = {
charge = 0,
max_drop_level = 0,
groupcaps = {
fleshy = {times={}, uses=10000, maxlevel=0}
load=0,
max_drop_level=0,
groupcaps={
fleshy={times={}, uses=10000, maxlevel=0}
}
}
})
--------------------------------------------
-- The Battery box
--------------------------------------------
minetest.register_craftitem("technic:battery_box", {
description = "Battery box",
stack_max = 99,
})
minetest.register_craft({
output = 'technic:lv_battery_box0',
output = 'technic:battery_box 1',
recipe = {
{'technic:battery', 'group:wood', 'technic:battery'},
{'technic:battery', 'default:wood', 'technic:battery'},
{'technic:battery', 'default:copper_ingot', 'technic:battery'},
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
}
})
technic.register_battery_box({
tier = "LV",
max_charge = 50000,
charge_rate = 1000,
discharge_rate = 4000,
charge_step = 500,
discharge_step = 800,
local battery_box_formspec =
"invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;1,1;]"..
"label[0,0;LV Battery Box]"..
"label[3,0;Charge]"..
"label[5,0;Discharge]"..
"label[1,3;Power level]"..
"list[current_player;main;0,5;8,4;]"..
"background[-0.19,-0.25;8.4,9.75;ui_form_bg.png]"..
"background[0,0;8,4;ui_lv_battery_box.png]"..
"background[0,5;8,4;ui_main_inventory.png]"
minetest.register_node("technic:battery_box", {
description = "LV Battery Box",
tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png",
"technic_battery_box_side0.png", "technic_battery_box_side0.png",
"technic_battery_box_side0.png", "technic_battery_box_side0.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
drop="technic:battery_box",
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
meta:set_string("infotext", "Battery box")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", battery_box_formspec)
meta:set_int("LV_EU_demand", 0) -- How much can this node charge
meta:set_int("LV_EU_supply", 0) -- How much can this node discharge
meta:set_int("LV_EU_input", 0) -- How much power is this machine getting.
meta:set_float("internal_EU_charge", 0)
inv:set_size("src", 1)
inv:set_size("dst", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
for i=1,8,1 do
minetest.register_node(
"technic:battery_box"..i, {
description = "LV Battery Box",
tiles = {"technic_battery_box_top.png", "technic_battery_box_bottom.png",
"technic_battery_box_side0.png^technic_power_meter"..i..".png",
"technic_battery_box_side0.png^technic_power_meter"..i..".png",
"technic_battery_box_side0.png^technic_power_meter"..i..".png",
"technic_battery_box_side0.png^technic_power_meter"..i..".png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
drop="technic:battery_box",
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
end
minetest.register_abm(
{nodenames = {"technic:battery_box","technic:battery_box1","technic:battery_box2","technic:battery_box3","technic:battery_box4",
"technic:battery_box5","technic:battery_box6","technic:battery_box7","technic:battery_box8"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local max_charge = 60000 -- Set maximum charge for the device here
local max_charge_rate = 1000 -- Set maximum rate of charging
local max_discharge_rate = 2000 -- Set maximum rate of discharging
local eu_input = meta:get_int("LV_EU_input")
local current_charge = meta:get_int("internal_EU_charge") -- Battery charge right now
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
-- Charge/discharge the battery with the input EUs
if eu_input >=0 then
current_charge = math.min(current_charge+eu_input, max_charge)
else
current_charge = math.max(current_charge+eu_input, 0)
end
-- Charging/discharging tools here
current_charge = charge_tools(meta, current_charge, 1000)
current_charge = discharge_tools(meta, current_charge, max_charge, 1000)
-- Set a demand (we allow batteries to charge on less than the demand though)
meta:set_int("LV_EU_demand", math.min(max_charge_rate, max_charge-current_charge))
--print("BA:"..max_charge_rate.."|"..max_charge-current_charge.."|"..math.min(max_charge_rate, max_charge-current_charge))
-- Set how much we can supply
meta:set_int("LV_EU_supply", math.min(max_discharge_rate, current_charge))
meta:set_int("internal_EU_charge", current_charge)
--dprint("BA: input:"..eu_input.." supply="..meta:get_int("LV_EU_supply").." demand="..meta:get_int("LV_EU_demand").." current:"..current_charge)
-- Select node textures
local i=math.ceil((current_charge/max_charge)*8)
if i > 8 then i = 8 end
local j = meta:get_float("last_side_shown")
if i~=j then
if i>0 then hacky_swap_node(pos,"technic:battery_box"..i)
elseif i==0 then hacky_swap_node(pos,"technic:battery_box") end
meta:set_float("last_side_shown",i)
end
local load = math.floor(current_charge/max_charge * 100)
meta:set_string("formspec",
battery_box_formspec..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
(load)..":technic_power_meter_fg.png]"
)
if eu_input == 0 then
meta:set_string("infotext", "LV Battery box: "..current_charge.."/"..max_charge.." (idle)")
else
meta:set_string("infotext", "LV Battery box: "..current_charge.."/"..max_charge)
end
end
})
-- Register as a battery type
-- Battery type machines function as power reservoirs and can both receive and give back power
technic.register_LV_machine("technic:battery_box","BA")
for i=1,8,1 do
technic.register_LV_machine("technic:battery_box"..i,"BA")
end

View File

@ -10,235 +10,274 @@
local shape = {}
local onesize_products = {
slope = 2,
slope_edge = 1,
slope_inner_edge = 1,
pyramid = 2,
spike = 1,
cylinder = 2,
sphere = 1,
stick = 8,
slope_upsdown = 2,
slope_edge_upsdown = 1,
slope_inner_edge_upsdown = 1,
cylinder_horizontal = 2,
slope_lying = 2,
onecurvededge = 1,
twocurvededge = 1,
slope = 2,
slope_edge = 1,
slope_inner_edge = 1,
pyramid = 2,
spike = 1,
cylinder = 2,
sphere = 1,
stick = 8,
slope_upsdown = 2,
slope_edge_upsdown = 1,
slope_inner_edge_upsdown = 1,
cylinder_horizontal = 2,
slope_lying = 2,
onecurvededge = 1,
twocurvededge = 1,
}
local twosize_products = {
element_straight = 4,
element_end = 2,
element_cross = 1,
element_t = 1,
element_edge = 2,
element_straight = 4,
element_end = 2,
element_cross = 1,
element_t = 1,
element_edge = 2,
}
local cnc_formspec =
"invsize[9,11;]"..
"label[1,0;Choose Milling Program:]"..
"image_button[1,0.5;1,1;technic_cnc_slope.png;slope; ]"..
"image_button[2,0.5;1,1;technic_cnc_slope_edge.png;slope_edge; ]"..
"image_button[3,0.5;1,1;technic_cnc_slope_inner_edge.png;slope_inner_edge; ]"..
"image_button[4,0.5;1,1;technic_cnc_pyramid.png;pyramid; ]"..
"image_button[5,0.5;1,1;technic_cnc_spike.png;spike; ]"..
"image_button[6,0.5;1,1;technic_cnc_cylinder.png;cylinder; ]"..
"image_button[7,0.5;1,1;technic_cnc_sphere.png;sphere; ]"..
"image_button[8,0.5;1,1;technic_cnc_stick.png;stick; ]"..
"invsize[9,11;]"..
"label[1,0;Choose Milling Program:]"..
"image_button[1,0.5;1,1;technic_cnc_slope.png;slope; ]"..
"image_button[2,0.5;1,1;technic_cnc_slope_edge.png;slope_edge; ]"..
"image_button[3,0.5;1,1;technic_cnc_slope_inner_edge.png;slope_inner_edge; ]"..
"image_button[4,0.5;1,1;technic_cnc_pyramid.png;pyramid; ]"..
"image_button[5,0.5;1,1;technic_cnc_spike.png;spike; ]"..
"image_button[6,0.5;1,1;technic_cnc_cylinder.png;cylinder; ]"..
"image_button[7,0.5;1,1;technic_cnc_sphere.png;sphere; ]"..
"image_button[8,0.5;1,1;technic_cnc_stick.png;stick; ]"..
"image_button[1,1.5;1,1;technic_cnc_slope_upsdwn.png;slope_upsdown; ]"..
"image_button[2,1.5;1,1;technic_cnc_slope_edge_upsdwn.png;slope_edge_upsdown; ]"..
"image_button[3,1.5;1,1;technic_cnc_slope_inner_edge_upsdwn.png;slope_inner_edge_upsdown; ]"..
"image_button[4,1.5;1,1;technic_cnc_cylinder_horizontal.png;cylinder_horizontal; ]"..
"image_button[1,2.5;1,1;technic_cnc_slope_lying.png;slope_lying; ]"..
"image_button[2,2.5;1,1;technic_cnc_onecurvededge.png;onecurvededge; ]"..
"image_button[3,2.5;1,1;technic_cnc_twocurvededge.png;twocurvededge; ]"..
"label[1,3.5;Slim Elements half / normal height:]"..
"image_button[1,4;1,0.5;technic_cnc_full.png;full; ]"..
"image_button[1,4.5;1,0.5;technic_cnc_half.png;half; ]"..
"image_button[2,4;1,1;technic_cnc_element_straight.png;element_straight; ]"..
"image_button[3,4;1,1;technic_cnc_element_end.png;element_end; ]"..
"image_button[4,4;1,1;technic_cnc_element_cross.png;element_cross; ]"..
"image_button[5,4;1,1;technic_cnc_element_t.png;element_t; ]"..
"image_button[6,4;1,1;technic_cnc_element_edge.png;element_edge; ]"..
"label[0, 5.5;In:]"..
"list[current_name;src;0.5,5.5;1,1;]"..
"label[4, 5.5;Out:]"..
"list[current_name;dst;5,5.5;4,1;]"..
"list[current_player;main;0,7;8,4;]"
"image_button[1,1.5;1,1;technic_cnc_slope_upsdwn.png;slope_upsdown; ]"..
"image_button[2,1.5;1,1;technic_cnc_slope_edge_upsdwn.png;slope_edge_upsdown; ]"..
"image_button[3,1.5;1,1;technic_cnc_slope_inner_edge_upsdwn.png;slope_inner_edge_upsdown; ]"..
"image_button[4,1.5;1,1;technic_cnc_cylinder_horizontal.png;cylinder_horizontal; ]"..
"image_button[1,2.5;1,1;technic_cnc_slope_lying.png;slope_lying; ]"..
"image_button[2,2.5;1,1;technic_cnc_onecurvededge.png;onecurvededge; ]"..
"image_button[3,2.5;1,1;technic_cnc_twocurvededge.png;twocurvededge; ]"..
"label[1,3.5;Slim Elements half / normal height:]"..
"image_button[1,4;1,0.5;technic_cnc_full.png;full; ]"..
"image_button[1,4.5;1,0.5;technic_cnc_half.png;half; ]"..
"image_button[2,4;1,1;technic_cnc_element_straight.png;element_straight; ]"..
"image_button[3,4;1,1;technic_cnc_element_end.png;element_end; ]"..
"image_button[4,4;1,1;technic_cnc_element_cross.png;element_cross; ]"..
"image_button[5,4;1,1;technic_cnc_element_t.png;element_t; ]"..
"image_button[6,4;1,1;technic_cnc_element_edge.png;element_edge; ]"..
"label[0, 5.5;In:]"..
"list[current_name;src;0.5,5.5;1,1;]"..
"label[4, 5.5;Out:]"..
"list[current_name;dst;5,5.5;4,1;]"..
"list[current_player;main;0,7;8,4;]"
local size = 1;
local size = 1;
-- The form handler is declared here because we need it in both the inactive and active modes
-- in order to be able to change programs wile it is running.
local function form_handler(pos, formname, fields, sender)
-- REGISTER MILLING PROGRAMS AND OUTPUTS:
------------------------------------------
-- Program for half/full size
if fields["full"] then
size = 1
return
end
if fields["half"] then
size = 2
return
end
-- Resolve the node name and the number of items to make
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local inputstack = inv:get_stack("src", 1)
local inputname = inputstack:get_name()
local multiplier = 0
for k, _ in pairs(fields) do
-- Set a multipier for the half/full size capable blocks
if twosize_products[k] ~= nil then
multiplier = size * twosize_products[k]
else
multiplier = onesize_products[k]
end
if onesize_products[k] ~= nil or twosize_products[k] ~= nil then
meta:set_float( "cnc_multiplier", multiplier)
meta:set_string("cnc_user", sender:get_player_name())
end
if onesize_products[k] ~= nil or (twosize_products[k] ~= nil and size==2) then
meta:set_string("cnc_product", inputname .. "_technic_cnc_" .. k)
--print(inputname .. "_technic_cnc_" .. k)
break
end
if twosize_products[k] ~= nil and size==1 then
meta:set_string("cnc_product", inputname .. "_technic_cnc_" .. k .. "_double")
--print(inputname .. "_technic_cnc_" .. k .. "_double")
break
end
end
return
end
local form_handler = function(pos, formname, fields, sender)
-- REGISTER MILLING PROGRAMS AND OUTPUTS:
------------------------------------------
-- Program for half/full size
if fields["full"] then
size = 1
return
end
if fields["half"] then
size = 2
return
end
-- Resolve the node name and the number of items to make
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local inputstack = inv:get_stack("src", 1)
local inputname = inputstack:get_name()
local multiplier = 0
for k, _ in pairs(fields) do
-- Set a multipier for the half/full size capable blocks
if twosize_products[k] ~= nil then
multiplier = size*twosize_products[k]
else
multiplier = onesize_products[k]
end
if onesize_products[k] ~= nil or twosize_products[k] ~= nil then
meta:set_float( "cnc_multiplier", multiplier)
meta:set_string("cnc_user", sender:get_player_name())
end
if onesize_products[k] ~= nil or (twosize_products[k] ~= nil and size==2) then
meta:set_string("cnc_product", inputname .. "_technic_cnc_" .. k)
--print(inputname .. "_technic_cnc_" .. k)
break
end
if twosize_products[k] ~= nil and size==1 then
meta:set_string("cnc_product", inputname .. "_technic_cnc_" .. k .. "_double")
--print(inputname .. "_technic_cnc_" .. k .. "_double")
break
end
end
return
end -- callback function
-- The actual block inactive state
minetest.register_node("technic:cnc", {
description = "CNC Milling Machine",
tiles = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
groups = {cracky=2},
legacy_facedir_simple = true,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "CNC Machine")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", cnc_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
on_receive_fields = form_handler,
})
minetest.register_node(
"technic:cnc",
{
description = "CNC Milling Machine",
tiles = {"technic_cnc_top.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front.png"},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
groups = {cracky=2},
legacy_facedir_simple = true,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "CNC Machine")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", cnc_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
on_receive_fields = form_handler,
})
-- Active state block
minetest.register_node("technic:cnc_active", {
description = "CNC Machine",
tiles = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front_active.png"},
paramtype2 = "facedir",
groups = {cracky=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"CNC machine cannot be removed because it is not empty");
return false
end
return true
end,
on_receive_fields = form_handler,
})
description = "CNC Machine",
tiles = {"technic_cnc_top_active.png", "technic_cnc_bottom.png", "technic_cnc_side.png",
"technic_cnc_side.png", "technic_cnc_side.png", "technic_cnc_front_active.png"},
paramtype2 = "facedir",
groups = {cracky=2,not_in_creative_inventory=1},
legacy_facedir_simple = true,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "CNC machine cannot be removed because it is not empty");
return false
end
return true
end,
on_receive_fields = form_handler,
})
-- Action code performing the transformation
minetest.register_abm({
nodenames = {"technic:cnc","technic:cnc_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local eu_input = meta:get_int("LV_EU_input")
local machine_name = "CNC"
local machine_node = "technic:cnc"
local demand = 450
minetest.register_abm(
{ nodenames = {"technic:cnc","technic:cnc_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local state = meta:get_int("state")
local next_state = state
-- Setup meta data if it does not exist. state is used as an indicator of this
if not eu_input then
meta:set_int("LV_EU_demand", demand)
meta:set_int("LV_EU_input", 0)
return
end
-- Machine information
local machine_name = "CNC"
local machine_node = "technic:cnc"
local machine_state_demand = { 50, 450 }
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("LV_EU_demand", machine_state_demand[1])
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
-- State machine
if eu_input == 0 then
-- Unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
local inv = meta:get_inventory()
local empty = inv:is_empty("src")
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
if state == 1 then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
local result = meta:get_string("cnc_product")
if inv:is_empty("src") or
(not minetest.registered_nodes[result]) or
(not inv:room_for_item("dst", result)) then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
meta:set_string("cnc_product", "")
return
end
local result = meta:get_string("cnc_product")
if not empty and minetest.registered_nodes[result] ~= nil and inv:room_for_item("dst",result) then
next_state = 2
else
meta:set_string("cnc_product", "") -- Reset the program
end
--minetest.chat_send_player(meta:get_string("cnc_user"), "CNC machine does not know how to handle this material. Please remove it.");
if eu_input < demand then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
elseif eu_input >= demand then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") >= 3 then -- 3 ticks per output
elseif state == 2 then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
if empty then
next_state = 1
else
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") >= 3 then -- 3 ticks per output
local result = meta:get_string("cnc_product")
-- check if there's room for output in "dst" list
if inv:room_for_item("dst",result) then
-- CNC does the transformation
------------------------------
meta:set_int("src_time", 0)
-- take stuff from "src" list
srcstack = inv:get_stack("src", 1)
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
inv:add_item("dst", result.." "..meta:get_int("cnc_multiplier"))
end
end
meta:set_int("LV_EU_demand", demand)
end
})
-- Put result in "dst" list
inv:add_item("dst",result .. " " .. meta:get_int("cnc_multiplier"))
else
next_state = 1
end
end
end
end
end
-- Change state?
if next_state ~= state then
meta:set_int("LV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
end
})
technic.register_machine("LV", "technic:cnc", technic.receiver)
technic.register_machine("LV", "technic:cnc_active", technic.receiver)
technic.register_LV_machine ("technic:cnc","RE")
technic.register_LV_machine ("technic:cnc_active","RE")
-------------------------
-- CNC Machine Recipe

View File

@ -1,354 +1,372 @@
-- API for the technic CNC machine
-- Again code is adapted from the NonCubic Blocks MOD v1.4 by yves_de_beck
technic.cnc = {}
technic_cnc_api = {}
technic.cnc.detail_level = 16
-- HERE YOU CAN CHANGE THE DETAIL-LEVEL:
----------------------------------------
technic_cnc_api.detail_level = 16 -- 16; 1-32
-- REGISTER NONCUBIC FORMS, CREATE MODELS AND RECIPES:
------------------------------------------------------
local function cnc_sphere()
local nodebox = {}
local detail = technic.cnc.detail_level
local sehne
for i = 1, detail - 1 do
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
nodebox[i]={-sehne, (i/detail) - 0.5, -sehne, sehne, (i/detail)+(1/detail)-0.5, sehne}
end
return nodebox
end
local cnc_sphere =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
local sehne
for i = 1, detail-1 do
sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
nodebox[i]={-sehne, (i/detail)-0.5, -sehne, sehne, (i/detail)+(1/detail)-0.5, sehne}
end
return nodebox
end
local function cnc_cylinder_horizontal()
local nodebox = {}
local detail = technic.cnc.detail_level
local sehne
for i = 1, detail - 1 do
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
nodebox[i]={-0.5, (i/detail)-0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, sehne}
end
return nodebox
end
local cnc_cylinder_horizontal =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
local sehne
for i = 1, detail-1 do
sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
nodebox[i]={-0.5, (i/detail)-0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, sehne}
end
return nodebox
end
local function cnc_cylinder()
local nodebox = {}
local detail = technic.cnc.detail_level
local sehne
for i = 1, detail - 1 do
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
nodebox[i]={(i/detail) - 0.5, -0.5, -sehne, (i/detail)+(1/detail)-0.5, 0.5, sehne}
end
return nodebox
end
local cnc_cylinder =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
local sehne
for i = 1, detail-1 do
sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
nodebox[i]={(i/detail)-0.5, -0.5, -sehne, (i/detail)+(1/detail)-0.5, 0.5, sehne}
end
return nodebox
end
local function cnc_twocurvededge()
local nodebox = {}
local detail = technic.cnc.detail_level * 2
local sehne
for i = (detail / 2) - 1, detail - 1 do
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
nodebox[i]={-sehne, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
end
return nodebox
end
local cnc_twocurvededge =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level*2
local sehne
for i = (detail/2)-1, detail-1 do
sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
nodebox[i]={-sehne, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
end
return nodebox
end
local function cnc_onecurvededge()
local nodebox = {}
local detail = technic.cnc.detail_level * 2
local sehne
for i = (detail / 2) - 1, detail - 1 do
sehne = math.sqrt(0.25 - (((i / detail) - 0.5) ^ 2))
nodebox[i]={-0.5, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
end
return nodebox
end
local cnc_onecurvededge =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level*2
local sehne
for i = (detail/2)-1, detail-1 do
sehne = math.sqrt(0.25 - (((i/detail)-0.5)^2))
nodebox[i]={-0.5, -0.5, -sehne, 0.5, (i/detail)+(1/detail)-0.5, 0.5}
end
return nodebox
end
local function cnc_spike()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail - 1 do
nodebox[i+1] = {(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5,
0.5-(i/detail/2), (i/detail)-0.5+(1/detail), 0.5-(i/detail/2)}
end
return nodebox
local cnc_spike =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
for i = 0, detail-1 do
nodebox[i+1]={(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5, 0.5-(i/detail/2), (i/detail)-0.5+(1/detail), 0.5-(i/detail/2)}
end
return nodebox
end
local function cnc_pyramid()
local nodebox = {}
local detail = technic.cnc.detail_level / 2
for i = 0, detail - 1 do
nodebox[i+1] = {(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5, 0.5-(i/detail/2), (i/detail/2)-0.5+(1/detail), 0.5-(i/detail/2)}
end
return nodebox
end
local cnc_pyramid =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level/2
for i = 0, detail-1 do
nodebox[i+1]={(i/detail/2)-0.5, (i/detail/2)-0.5, (i/detail/2)-0.5, 0.5-(i/detail/2), (i/detail/2)-0.5+(1/detail), 0.5-(i/detail/2)}
end
return nodebox
end
local function cnc_slope_inner_edge_upsdown()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {0.5-(i/detail)-(1/detail), (i/detail)-0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
nodebox[i+detail+1] = {-0.5, (i/detail)-0.5, 0.5-(i/detail)-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local cnc_slope_inner_edge_upsdown =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
for i = 0, detail-1 do
nodebox[i+1]={0.5-(i/detail)-(1/detail), (i/detail)-0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
nodebox[i+detail+1]={-0.5, (i/detail)-0.5, 0.5-(i/detail)-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local function cnc_slope_edge_upsdown()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {(-1*(i/detail))+0.5-(1/detail), (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local cnc_slope_edge_upsdown =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
for i = 0, detail-1 do
nodebox[i+1]={(-1*(i/detail))+0.5-(1/detail), (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local function cnc_slope_inner_edge()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {(i/detail)-0.5, -0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
nodebox[i+detail+1] = {-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local cnc_slope_inner_edge =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
for i = 0, detail-1 do
nodebox[i+1]={(i/detail)-0.5, -0.5, -0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
nodebox[i+detail+1]={-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local function cnc_slope_edge()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {(i/detail)-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local cnc_slope_edge =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
for i = 0, detail-1 do
nodebox[i+1]={(i/detail)-0.5, -0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local function cnc_slope_upsdown()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {-0.5, (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local cnc_slope_upsdown =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
for i = 0, detail-1 do
nodebox[i+1]={-0.5, (i/detail)-0.5, (-1*(i/detail))+0.5-(1/detail), 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local function cnc_slope_lying()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {(i/detail)-0.5, -0.5, (i/detail)-0.5, (i/detail)-0.5+(1/detail), 0.5 , 0.5}
end
return nodebox
end
local cnc_slope_lying =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
for i = 0, detail-1 do
nodebox[i+1]={(i/detail)-0.5, -0.5, (i/detail)-0.5, (i/detail)-0.5+(1/detail), 0.5 , 0.5}
end
return nodebox
end
local function cnc_slope()
local nodebox = {}
local detail = technic.cnc.detail_level
for i = 0, detail-1 do
nodebox[i+1] = {-0.5, (i/detail)-0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
local cnc_slope =
function()
local nodebox = {}
local detail = technic_cnc_api.detail_level
for i = 0, detail-1 do
nodebox[i+1]={-0.5, (i/detail)-0.5, (i/detail)-0.5, 0.5, (i/detail)-0.5+(1/detail), 0.5}
end
return nodebox
end
-- Define slope boxes for the various nodes
-------------------------------------------
technic.cnc.programs = {
{suffix = "technic_cnc_stick",
nodebox = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15},
desc = "Stick"},
technic_cnc_api.cnc_programs = {
{suffix = "technic_cnc_stick",
nodebox = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15},
desc = "Stick"},
{suffix = "technic_cnc_element_end_double",
nodebox = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.5},
desc = "Element End Double"},
{suffix = "technic_cnc_element_end_double",
nodebox = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.5},
desc = "Element End Double"},
{suffix = "technic_cnc_element_cross_double",
nodebox = {
{0.3, -0.5, -0.3, 0.5, 0.5, 0.3},
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
desc = "Element Cross Double"},
{suffix = "technic_cnc_element_cross_double",
nodebox = {
{0.3, -0.5, -0.3, 0.5, 0.5, 0.3},
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
desc = "Element Cross Double"},
{suffix = "technic_cnc_element_t_double",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3},
{0.3, -0.5, -0.3, 0.5, 0.5, 0.3}},
desc = "Element T Double"},
{suffix = "technic_cnc_element_t_double",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3},
{0.3, -0.5, -0.3, 0.5, 0.5, 0.3}},
desc = "Element T Double"},
{suffix = "technic_cnc_element_edge_double",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
desc = "Element Edge Double"},
{suffix = "technic_cnc_element_edge_double",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0.5, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0.5, 0.3}},
desc = "Element Edge Double"},
{suffix = "technic_cnc_element_straight_double",
nodebox = {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
desc = "Element Straight Double"},
{suffix = "technic_cnc_element_straight_double",
nodebox = {-0.3, -0.5, -0.5, 0.3, 0.5, 0.5},
desc = "Element Straight Double"},
{suffix = "technic_cnc_element_end",
nodebox = {-0.3, -0.5, -0.3, 0.3, 0, 0.5},
desc = "Element End"},
{suffix = "technic_cnc_element_end",
nodebox = {-0.3, -0.5, -0.3, 0.3, 0, 0.5},
desc = "Element End"},
{suffix = "technic_cnc_element_cross",
nodebox = {
{0.3, -0.5, -0.3, 0.5, 0, 0.3},
{-0.3, -0.5, -0.5, 0.3, 0, 0.5},
{-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
desc = "Element Cross"},
{suffix = "technic_cnc_element_cross",
nodebox = {
{0.3, -0.5, -0.3, 0.5, 0, 0.3},
{-0.3, -0.5, -0.5, 0.3, 0, 0.5},
{-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
desc = "Element Cross"},
{suffix = "technic_cnc_element_t",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0, 0.3},
{0.3, -0.5, -0.3, 0.5, 0, 0.3}},
desc = "Element T"},
{suffix = "technic_cnc_element_t",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0, 0.3},
{0.3, -0.5, -0.3, 0.5, 0, 0.3}},
desc = "Element T"},
{suffix = "technic_cnc_element_edge",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
desc = "Element Edge"},
{suffix = "technic_cnc_element_edge",
nodebox = {
{-0.3, -0.5, -0.5, 0.3, 0, 0.3},
{-0.5, -0.5, -0.3, -0.3, 0, 0.3}},
desc = "Element Edge"},
{suffix = "technic_cnc_element_straight",
nodebox = {-0.3, -0.5, -0.5, 0.3, 0, 0.5},
desc = "Element Straight"},
{suffix = "technic_cnc_element_straight",
nodebox = {-0.3, -0.5, -0.5, 0.3, 0, 0.5},
desc = "Element Straight"},
{suffix = "technic_cnc_sphere",
nodebox = cnc_sphere(),
desc = "Sphere"},
{suffix = "technic_cnc_sphere",
nodebox = cnc_sphere(),
desc = "Sphere"},
{suffix = "technic_cnc_cylinder_horizontal",
nodebox = cnc_cylinder_horizontal(),
desc = "Cylinder Horizontal"},
{suffix = "technic_cnc_cylinder_horizontal",
nodebox = cnc_cylinder_horizontal(),
desc = "Cylinder Horizontal"},
{suffix = "technic_cnc_cylinder",
nodebox = cnc_cylinder(),
desc = ""},
{suffix = "technic_cnc_cylinder",
nodebox = cnc_cylinder(),
desc = ""},
{suffix = "technic_cnc_twocurvededge",
nodebox = cnc_twocurvededge(),
desc = "One Curved Edge Block"},
{suffix = "technic_cnc_twocurvededge",
nodebox = cnc_twocurvededge(),
desc = "One Curved Edge Block"},
{suffix = "technic_cnc_onecurvededge",
nodebox = cnc_onecurvededge(),
desc = "Two Curved Edge Block"},
{suffix = "technic_cnc_onecurvededge",
nodebox = cnc_onecurvededge(),
desc = "Two Curved Edge Block"},
{suffix = "technic_cnc_spike",
nodebox = cnc_spike(),
desc = "Spike"},
{suffix = "technic_cnc_spike",
nodebox = cnc_spike(),
desc = "Spike"},
{suffix = "technic_cnc_pyramid",
nodebox = cnc_pyramid(),
desc = "Pyramid"},
{suffix = "technic_cnc_pyramid",
nodebox = cnc_pyramid(),
desc = "Pyramid"},
{suffix = "technic_cnc_slope_inner_edge_upsdown",
nodebox = cnc_slope_inner_edge_upsdown(),
desc = "Slope Upside Down Inner Edge"},
{suffix = "technic_cnc_slope_inner_edge_upsdown",
nodebox = cnc_slope_inner_edge_upsdown(),
desc = "Slope Upside Down Inner Edge"},
{suffix = "technic_cnc_slope_edge_upsdown",
nodebox = cnc_slope_edge_upsdown(),
desc = "Slope Upside Down Edge"},
{suffix = "technic_cnc_slope_edge_upsdown",
nodebox = cnc_slope_edge_upsdown(),
desc = "Slope Upside Down Edge"},
{suffix = "technic_cnc_slope_inner_edge",
nodebox = cnc_slope_inner_edge(),
desc = "Slope Inner Edge"},
{suffix = "technic_cnc_slope_inner_edge",
nodebox = cnc_slope_inner_edge(),
desc = "Slope Inner Edge"},
{suffix = "technic_cnc_slope_edge",
nodebox = cnc_slope_edge(),
desc = "Slope Edge"},
{suffix = "technic_cnc_slope_edge",
nodebox = cnc_slope_edge(),
desc = "Slope Edge"},
{suffix = "technic_cnc_slope_upsdown",
nodebox = cnc_slope_upsdown(),
desc = "Slope Upside Down"},
{suffix = "technic_cnc_slope_upsdown",
nodebox = cnc_slope_upsdown(),
desc = "Slope Upside Down"},
{suffix = "technic_cnc_slope_lying",
nodebox = cnc_slope_lying(),
desc = "Slope Lying"},
{suffix = "technic_cnc_slope_lying",
nodebox = cnc_slope_lying(),
desc = "Slope Lying"},
{suffix = "technic_cnc_slope",
nodebox = cnc_slope(),
desc = "Slope"},
{suffix = "technic_cnc_slope",
nodebox = cnc_slope(),
desc = "Slope"},
-- {suffix = "",
-- nodebox =},
}
-- Allow disabling certain programs for some node. Default is allowing all types for all nodes
technic.cnc.programs_disable = {
-- ["default:brick"] = {"technic_cnc_stick"}, -- Example: Disallow the stick for brick
-- ...
["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown", "technic_cnc_edge",
"technic_cnc_inner_edge", "technic_cnc_slope_edge_upsdown",
"technic_cnc_slope_inner_edge_upsdown", "technic_cnc_stick",
"technic_cnc_cylinder_horizontal"}
technic_cnc_api.cnc_programs_disable = {
-- ["default:brick"] = {"technic_cnc_stick"}, -- Example: Disallow the stick for brick
-- ...
["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown", "technic_cnc_edge",
"technic_cnc_inner_edge", "technic_cnc_slope_edge_upsdown", "technic_cnc_slope_inner_edge_upsdown",
"technic_cnc_stick", "technic_cnc_cylinder_horizontal"}
}
-- Generic function for registering all the different node types
function technic.cnc.register_program(recipeitem, suffix, nodebox, groups, images, description)
minetest.register_node(":"..recipeitem.."_"..suffix, {
description = description,
drawtype = "nodebox",
tiles = images,
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
node_box = {
type = "fixed",
fixed = nodebox
},
groups = groups,
})
function technic_cnc_api.register_cnc_program(recipeitem, suffix, nodebox, groups, images, description)
minetest.register_node(":" .. recipeitem .. "_" .. suffix, {
description = description,
drawtype = "nodebox",
tiles = images,
paramtype = "light",
paramtype2 = "facedir",
walkable = true,
selection_box = {
type = "fixed",
fixed = nodebox
},
node_box = {
type = "fixed",
fixed = nodebox
},
groups = groups,
})
end
-- function to iterate over all the programs the CNC machine knows
function technic.cnc.register_all(recipeitem, groups, images, description)
for _, data in ipairs(technic.cnc.programs) do
-- Disable node creation for disabled node types for some material
local do_register = true
if technic.cnc.programs_disable[recipeitem] ~= nil then
for __, disable in ipairs(technic.cnc.programs_disable[recipeitem]) do
if disable == data.suffix then
do_register = false
end
end
end
-- Create the node if it passes the test
if do_register then
technic.cnc.register_program(recipeitem, data.suffix, data.nodebox, groups, images, description.." "..data.desc)
end
end
function technic_cnc_api.register_all(recipeitem, groups, images, description)
for _, data in ipairs(technic_cnc_api.cnc_programs) do
-- Disable node creation for disabled node types for some material
local do_register = true
if technic_cnc_api.cnc_programs_disable[recipeitem] ~= nil then
for __, disable in ipairs(technic_cnc_api.cnc_programs_disable[recipeitem]) do
if disable == data.suffix then
do_register = false
end
end
end
-- Create the node if it passes the test
if do_register then
technic_cnc_api.register_cnc_program(recipeitem, data.suffix, data.nodebox, groups, images, description.." "..data.desc)
end
end
end
-- REGISTER NEW TECHNIC_CNC_API's PART 2: technic.cnc..register_element_end(subname, recipeitem, groups, images, desc_element_xyz)
-- REGISTER NEW TECHNIC_CNC_API's PART 2: technic_cnc_api.register_element_end(subname, recipeitem, groups, images, desc_element_xyz)
-----------------------------------------------------------------------------------------------------------------------
function technic.cnc.register_slope_edge_etc(recipeitem, groups, images, desc_slope, desc_slope_lying, desc_slope_upsdown, desc_slope_edge, desc_slope_inner_edge, desc_slope_upsdwn_edge, desc_slope_upsdwn_inner_edge, desc_pyramid, desc_spike, desc_onecurvededge, desc_twocurvededge, desc_cylinder, desc_cylinder_horizontal, desc_sphere, desc_element_straight, desc_element_edge, desc_element_t, desc_element_cross, desc_element_end)
function technic_cnc_api.register_slope_edge_etc(recipeitem, groups, images, desc_slope, desc_slope_lying, desc_slope_upsdown, desc_slope_edge, desc_slope_inner_edge, desc_slope_upsdwn_edge, desc_slope_upsdwn_inner_edge, desc_pyramid, desc_spike, desc_onecurvededge, desc_twocurvededge, desc_cylinder, desc_cylinder_horizontal, desc_sphere, desc_element_straight, desc_element_edge, desc_element_t, desc_element_cross, desc_element_end)
technic.cnc.register_slope(recipeitem, groups, images, desc_slope)
technic.cnc.register_slope_lying(recipeitem, groups, images, desc_slope_lying)
technic.cnc.register_slope_upsdown(recipeitem, groups, images, desc_slope_upsdown)
technic.cnc.register_slope_edge(recipeitem, groups, images, desc_slope_edge)
technic.cnc.register_slope_inner_edge(recipeitem, groups, images, desc_slope_inner_edge)
technic.cnc.register_slope_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_edge)
technic.cnc.register_slope_inner_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_inner_edge)
technic.cnc.register_pyramid(recipeitem, groups, images, desc_pyramid)
technic.cnc.register_spike(recipeitem, groups, images, desc_spike)
technic.cnc.register_onecurvededge(recipeitem, groups, images, desc_onecurvededge)
technic.cnc.register_twocurvededge(recipeitem, groups, images, desc_twocurvededge)
technic.cnc.register_cylinder(recipeitem, groups, images, desc_cylinder)
technic.cnc.register_cylinder_horizontal(recipeitem, groups, images, desc_cylinder_horizontal)
technic.cnc.register_sphere(recipeitem, groups, images, desc_sphere)
technic.cnc.register_element_straight(recipeitem, groups, images, desc_element_straight)
technic.cnc.register_element_edge(recipeitem, groups, images, desc_element_edge)
technic.cnc.register_element_t(recipeitem, groups, images, desc_element_t)
technic.cnc.register_element_cross(recipeitem, groups, images, desc_element_cross)
technic.cnc.register_element_end(recipeitem, groups, images, desc_element_end)
technic_cnc_api.register_slope(recipeitem, groups, images, desc_slope)
technic_cnc_api.register_slope_lying(recipeitem, groups, images, desc_slope_lying)
technic_cnc_api.register_slope_upsdown(recipeitem, groups, images, desc_slope_upsdown)
technic_cnc_api.register_slope_edge(recipeitem, groups, images, desc_slope_edge)
technic_cnc_api.register_slope_inner_edge(recipeitem, groups, images, desc_slope_inner_edge)
technic_cnc_api.register_slope_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_edge)
technic_cnc_api.register_slope_inner_edge_upsdown(recipeitem, groups, images, desc_slope_upsdwn_inner_edge)
technic_cnc_api.register_pyramid(recipeitem, groups, images, desc_pyramid)
technic_cnc_api.register_spike(recipeitem, groups, images, desc_spike)
technic_cnc_api.register_onecurvededge(recipeitem, groups, images, desc_onecurvededge)
technic_cnc_api.register_twocurvededge(recipeitem, groups, images, desc_twocurvededge)
technic_cnc_api.register_cylinder(recipeitem, groups, images, desc_cylinder)
technic_cnc_api.register_cylinder_horizontal(recipeitem, groups, images, desc_cylinder_horizontal)
technic_cnc_api.register_sphere(recipeitem, groups, images, desc_sphere)
technic_cnc_api.register_element_straight(recipeitem, groups, images, desc_element_straight)
technic_cnc_api.register_element_edge(recipeitem, groups, images, desc_element_edge)
technic_cnc_api.register_element_t(recipeitem, groups, images, desc_element_t)
technic_cnc_api.register_element_cross(recipeitem, groups, images, desc_element_cross)
technic_cnc_api.register_element_end(recipeitem, groups, images, desc_element_end)
end
-- REGISTER STICKS: noncubic.register_xyz(recipeitem, groups, images, desc_element_xyz)
------------------------------------------------------------------------------------------------------------
function technic.cnc.register_stick_etc(recipeitem, groups, images, desc_stick)
technic.cnc.register_stick(recipeitem, groups, images, desc_stick)
function technic_cnc_api.register_stick_etc(recipeitem, groups, images, desc_stick)
technic_cnc_api.register_stick(recipeitem, groups, images, desc_stick)
end
function technic.cnc.register_elements(recipeitem, groups, images, desc_element_straight_double, desc_element_edge_double, desc_element_t_double, desc_element_cross_double, desc_element_end_double)
technic.cnc.register_element_straight_double(recipeitem, groups, images, desc_element_straight_double)
technic.cnc.register_element_edge_double(recipeitem, groups, images, desc_element_edge_double)
technic.cnc.register_element_t_double(recipeitem, groups, images, desc_element_t_double)
technic.cnc.register_element_cross_double(recipeitem, groups, images, desc_element_cross_double)
technic.cnc.register_element_end_double(recipeitem, groups, images, desc_element_end_double)
function technic_cnc_api.register_elements(recipeitem, groups, images, desc_element_straight_double, desc_element_edge_double, desc_element_t_double, desc_element_cross_double, desc_element_end_double)
technic_cnc_api.register_element_straight_double(recipeitem, groups, images, desc_element_straight_double)
technic_cnc_api.register_element_edge_double(recipeitem, groups, images, desc_element_edge_double)
technic_cnc_api.register_element_t_double(recipeitem, groups, images, desc_element_t_double)
technic_cnc_api.register_element_cross_double(recipeitem, groups, images, desc_element_cross_double)
technic_cnc_api.register_element_end_double(recipeitem, groups, images, desc_element_end_double)
end

View File

@ -2,70 +2,69 @@
-----------------------------------------------------------
-- DIRT
-------
technic.cnc.register_all("default:dirt",
technic_cnc_api.register_all("default:dirt",
{snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
{"default_grass.png", "default_dirt.png", "default_grass.png"},
"Dirt")
technic.cnc.programs_disable["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown",
"technic_cnc_edge", "technic_cnc_inner_edge",
"technic_cnc_slope_edge_upsdown", "technic_cnc_slope_inner_edge_upsdown",
"technic_cnc_stick", "technic_cnc_cylinder_horizontal"}
technic_cnc_api.cnc_programs_disable["default:dirt"] = {"technic_cnc_sphere", "technic_cnc_slope_upsdown",
"technic_cnc_edge", "technic_cnc_inner_edge",
"technic_cnc_slope_edge_upsdown", "technic_cnc_slope_inner_edge_upsdown",
"technic_cnc_stick", "technic_cnc_cylinder_horizontal"}
-- TREE
-------
technic.cnc.register_all("default:tree",
{snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
technic_cnc_api.register_all("default:tree",
{snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
{"default_tree.png"},
"Wooden")
-- WOOD
-------
technic.cnc.register_all("default:wood",
{snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
technic_cnc_api.register_all("default:wood",
{snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
{"default_wood.png"},
"Wooden")
-- STONE
--------
technic.cnc.register_all("default:stone",
{cracky=3, not_in_creative_inventory=1},
technic_cnc_api.register_all("default:stone",
{cracky=3,not_in_creative_inventory=1},
{"default_stone.png"},
"Stone")
-- COBBLE
---------
technic.cnc.register_all("default:cobble",
{cracky=3, not_in_creative_inventory=1},
technic_cnc_api.register_all("default:cobble",
{cracky=3,not_in_creative_inventory=1},
{"default_cobble.png"},
"Cobble")
-- BRICK
--------
technic.cnc.register_all("default:brick",
{cracky=3, not_in_creative_inventory=1},
technic_cnc_api.register_all("default:brick",
{cracky=3,not_in_creative_inventory=1},
{"default_brick.png"},
"Brick")
-- SANDSTONE
------------
technic.cnc.register_all("default:sandstone",
{crumbly=2, cracky=2, not_in_creative_inventory=1},
technic_cnc_api.register_all("default:sandstone",
{crumbly=2,cracky=2,not_in_creative_inventory=1},
{"default_sandstone.png"},
"Sandstone")
-- LEAVES
---------
technic.cnc.register_all("default:leaves",
{snappy=2, choppy=2, oddly_breakable_by_hand=3, not_in_creative_inventory=1},
technic_cnc_api.register_all("default:leaves",
{snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1},
{"default_leaves.png"},
"Leaves")
-- TREE
-------
technic.cnc.register_all("default:tree",
{snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3, wood=1, not_in_creative_inventory=1},
technic_cnc_api.register_all("default:tree",
{snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1,not_in_creative_inventory=1},
{"default_tree.png"},
"Tree")
-- STEEL
--------
technic.cnc.register_all("default:steel",
{snappy=1, bendy=2, cracky=1, melty=2, level=2, not_in_creative_inventory=1},
technic_cnc_api.register_all("default:steel",
{snappy=1,bendy=2,cracky=1,melty=2,level=2,not_in_creative_inventory=1},
{"default_steel_block.png"},
"Steel")

View File

@ -22,14 +22,13 @@ technic.get_compressor_recipe = function(item)
end
end
technic.register_compressor_recipe("default:snowblock", 1, "default:ice", 1)
technic.register_compressor_recipe("default:sand", 1, "default:sandstone", 1)
technic.register_compressor_recipe("default:desert_sand", 1, "default:desert_stone", 1)
technic.register_compressor_recipe("technic:mixed_metal_ingot", 1, "technic:composite_plate", 1)
technic.register_compressor_recipe("default:copper_ingot", 5, "technic:copper_plate", 1)
technic.register_compressor_recipe("technic:coal_dust", 4, "technic:graphite", 1)
technic.register_compressor_recipe("technic:carbon_cloth", 1, "technic:carbon_plate", 1)
technic.register_compressor_recipe("technic:enriched_uranium", 4, "technic:uranium_fuel", 1)
technic.register_compressor_recipe("default:snowblock", 1, "default:ice", 1)
technic.register_compressor_recipe("default:sand", 1, "default:sandstone", 1)
technic.register_compressor_recipe("default:desert_sand", 1, "default:desert_stone", 1)
technic.register_compressor_recipe("technic:mixed_metal_ingot", 1, "technic:composite_plate", 1)
technic.register_compressor_recipe("default:copper_ingot", 5, "technic:copper_plate", 1)
technic.register_compressor_recipe("technic:coal_dust", 4, "technic:graphite", 1)
technic.register_compressor_recipe("technic:carbon_cloth", 1, "technic:carbon_plate", 1)
minetest.register_alias("compressor", "technic:compressor")
@ -38,10 +37,15 @@ minetest.register_craft({
recipe = {
{'default:stone', 'default:stone', 'default:stone'},
{'mesecons:piston', 'technic:motor', 'mesecons:piston'},
{'default:stone', 'technic:lv_cable0', 'default:stone'},
{'default:stone', 'technic:lv_cable', 'default:stone'},
}
})
minetest.register_craftitem("technic:compressor", {
description = "Compressor",
stack_max = 99,
})
local compressor_formspec =
"invsize[8,9;]"..
"label[0,0;Compressor]"..
@ -51,15 +55,14 @@ local compressor_formspec =
minetest.register_node("technic:compressor", {
description = "Compressor",
tiles = {"technic_compressor_top.png", "technic_compressor_bottom.png",
"technic_compressor_side.png", "technic_compressor_side.png",
"technic_compressor_back.png", "technic_compressor_front.png"},
tiles = {"technic_compressor_top.png", "technic_compressor_bottom.png", "technic_compressor_side.png",
"technic_compressor_side.png", "technic_compressor_back.png", "technic_compressor_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Compressor")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", compressor_formspec)
@ -68,11 +71,10 @@ minetest.register_node("technic:compressor", {
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty")
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
@ -82,19 +84,17 @@ minetest.register_node("technic:compressor", {
minetest.register_node("technic:compressor_active", {
description = "Compressor",
tiles = {"technic_compressor_top.png", "technic_compressor_bottom.png",
"technic_compressor_side.png", "technic_compressor_side.png",
"technic_compressor_back.png", "technic_compressor_front_active.png"},
tiles = {"technic_compressor_top.png", "technic_compressor_bottom.png", "technic_compressor_side.png",
"technic_compressor_side.png", "technic_compressor_back.png", "technic_compressor_front_active.png"},
paramtype2 = "facedir",
groups = {cracky=2, not_in_creative_inventory=1},
groups = {cracky=2,not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
@ -107,63 +107,101 @@ minetest.register_abm({
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
-- Run a machine through its states. Takes the same arguments as the ABM action
-- and adds the machine's states and any extra data which is needed by the machine.
-- A machine is characterized by running through a set number of states (usually 2:
-- Idle and active) in some order. A state decides when to move to the next one
-- and the machine only changes state if it is powered correctly.
-- The machine will automatically shut down if disconnected from power in some fashion.
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local machine_name = "Compressor"
local machine_node = "technic:compressor"
local demand = 300
local state = meta:get_int("state")
local next_state = state
-- Machine information
local machine_name = "Compressor"
local machine_node = "technic:compressor"
local machine_state_demand = { 50, 300 }
-- Setup meta data if it does not exist.
if not eu_input then
meta:set_int("LV_EU_demand", demand)
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("LV_EU_demand", machine_state_demand[1])
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
local inv = meta:get_inventory()
local empty = inv:is_empty("src")
local srcstack = inv:get_stack("src", 1)
local src_item, recipe, result = nil, nil, nil
if srcstack then
src_item = srcstack:to_table()
end
if src_item then
recipe = technic.get_compressor_recipe(src_item)
end
if recipe then
result = {name=recipe.dst_name, count=recipe.dst_count}
end
if empty or (not result) or
(not inv:room_for_item("dst", result)) then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
meta:set_int("LV_EU_demand", 0)
meta:set_int("src_time", 0)
return
end
if eu_input < demand then
-- State machine
if eu_input == 0 then
-- unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
elseif eu_input >= demand then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
local inv = meta:get_inventory()
local empty = inv:is_empty("src")
local srcstack = inv:get_stack("src", 1)
local src_item = nil
local recipe = nil
local result = nil
if srcstack then
src_item = srcstack:to_table()
end
if src_item then
recipe = technic.get_compressor_recipe(src_item)
end
if recipe then
result = {name=recipe.dst_name, count=recipe.dst_count}
end
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") >= 4 then
meta:set_int("src_time", 0)
srcstack:take_item(recipe.src_count)
inv:set_stack("src", 1, srcstack)
inv:add_item("dst", result)
if state == 1 then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
if not empty and result and inv:room_for_item("dst",result) then
meta:set_int("src_time", 0)
next_state = 2
end
elseif state == 2 then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
if empty then
next_state = 1
else
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") == 4 then
-- 4 ticks per output
-- check if there's room for output in "dst" list
meta:set_int("src_time", 0)
if recipe and inv:room_for_item("dst",result) then
-- take stuff from "src" list
srcstack:take_item(recipe.src_count)
inv:set_stack("src", 1, srcstack)
-- Put result in "dst" list
inv:add_item("dst", result)
else
-- all full: go idle
next_state = 1
end
end
end
end
end
meta:set_int("LV_EU_demand", demand)
-- Change state?
if next_state ~= state then
meta:set_int("LV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
end
})
technic.register_machine("LV", "technic:compressor", technic.receiver)
technic.register_machine("LV", "technic:compressor_active", technic.receiver)
technic.register_LV_machine ("technic:compressor","RE")
technic.register_LV_machine ("technic:compressor_active","RE")

View File

@ -2,15 +2,159 @@
-- This is a faster version of the stone furnace which runs on EUs
-- FIXME: kpoppel I'd like to introduce an induction heating element here also
minetest.register_craft({
output = 'technic:electric_furnace',
recipe = {
{'default:cobble', 'default:cobble', 'default:cobble'},
{'default:cobble', '', 'default:cobble'},
{'default:steel_ingot', 'moreores:copper_ingot', 'default:steel_ingot'},
}
})
minetest.register_craft(
{output = 'technic:electric_furnace',
recipe = {
{'default:cobble', 'default:cobble', 'default:cobble'},
{'default:cobble', '', 'default:cobble'},
{'default:steel_ingot', 'moreores:copper_ingot', 'default:steel_ingot'},
}
})
technic.register_electric_furnace({tier="LV", demand={300}, speed = 2})
local electric_furnace_formspec =
"invsize[8,9;]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"..
"label[0,0;Electric Furnace]"..
"label[1,3;Power level]"
minetest.register_node(
"technic:electric_furnace",
{description = "Electric furnace",
tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
"technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Electric Furnace")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", electric_furnace_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node(
"technic:electric_furnace_active",
{description = "Electric Furnace",
tiles = {"technic_electric_furnace_top.png", "technic_electric_furnace_bottom.png", "technic_electric_furnace_side.png",
"technic_electric_furnace_side.png", "technic_electric_furnace_side.png", "technic_electric_furnace_front_active.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "technic:electric_furnace",
groups = {cracky=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_abm(
{ nodenames = {"technic:electric_furnace","technic:electric_furnace_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local state = meta:get_int("state")
local next_state = state
-- Machine information
local machine_name = "Electric furnace"
local machine_node = "technic:electric_furnace"
local machine_state_demand = { 50, 1000 }
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("LV_EU_demand", machine_state_demand[1])
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
-- State machine
if eu_input == 0 then
-- Unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
-- Execute always if powered logic
local inv = meta:get_inventory()
local empty = inv:is_empty("src")
if state == 1 then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
if not empty and result and inv:room_for_item("dst",result) then
next_state = 2
end
elseif state == 2 then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
if empty then
next_state = 1
else
meta:set_int("src_time", meta:get_int("src_time") + 3) -- Cooking time 3x
local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
if result and result.item and meta:get_int("src_time") >= result.time then
-- check if there's room for output in "dst" list
meta:set_int("src_time", 0)
if inv:room_for_item("dst",result.item) then
-- take stuff from "src" list
srcstack = inv:get_stack("src", 1)
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
-- Put result in "dst" list
inv:add_item("dst", result.item)
else
-- all full: go idle
next_state = 1
end
end
end
end
end
-- Change state?
if next_state ~= state then
meta:set_int("LV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
end,
})
technic.register_LV_machine ("technic:electric_furnace","RE")
technic.register_LV_machine ("technic:electric_furnace_active","RE")

View File

@ -1,52 +1,58 @@
technic.extractor_recipes ={}
technic.register_extractor_recipe = function(src, src_count, dst, dst_count)
technic.extractor_recipes[src] = {src_count = src_count, dst_name = dst, dst_count = dst_count}
if unified_inventory then
unified_inventory.register_craft({
type = "extracting",
output = dst.." "..dst_count,
items = {src.." "..src_count},
width = 0,
})
end
end
technic.extractor_recipes[src] = {src_count = src_count, dst_name = dst, dst_count = dst_count}
if unified_inventory then
unified_inventory.register_craft(
{
type = "extracting",
output = dst.." "..dst_count,
items = {src.." "..src_count},
width = 0,
})
end
end
-- Receive an ItemStack of result by an ItemStack input
technic.get_extractor_recipe = function(item)
if technic.extractor_recipes[item.name] and
item.count >= technic.extractor_recipes[item.name].src_count then
return technic.extractor_recipes[item.name]
else
return nil
end
end
if technic.extractor_recipes[item.name]
and item.count >= technic.extractor_recipes[item.name].src_count then
return technic.extractor_recipes[item.name]
else
return nil
end
end
technic.register_extractor_recipe("technic:coal_dust", 1, "dye:black", 2)
technic.register_extractor_recipe("default:cactus", 1, "dye:green", 2)
technic.register_extractor_recipe("default:dry_shrub", 1, "dye:brown", 2)
technic.register_extractor_recipe("flowers:geranium", 1, "dye:blue", 2)
technic.register_extractor_recipe("flowers:dandelion_white", 1, "dye:white", 2)
technic.register_extractor_recipe("flowers:dandelion_yellow", 1, "dye:yellow", 2)
technic.register_extractor_recipe("flowers:tulip", 1, "dye:orange", 2)
technic.register_extractor_recipe("flowers:rose", 1, "dye:red", 2)
technic.register_extractor_recipe("flowers:viola", 1, "dye:violet", 2)
technic.register_extractor_recipe("technic:raw_latex", 1, "technic:rubber", 3)
technic.register_extractor_recipe("technic:coal_dust", 1, "dye:black", 2)
technic.register_extractor_recipe("default:cactus", 1, "dye:green", 2)
technic.register_extractor_recipe("default:dry_shrub", 1, "dye:brown", 2)
technic.register_extractor_recipe("flowers:geranium", 1, "dye:blue", 2)
technic.register_extractor_recipe("flowers:dandelion_white", 1, "dye:white", 2)
technic.register_extractor_recipe("flowers:dandelion_yellow", 1, "dye:yellow", 2)
technic.register_extractor_recipe("flowers:tulip", 1, "dye:orange", 2)
technic.register_extractor_recipe("flowers:rose", 1, "dye:red", 2)
technic.register_extractor_recipe("flowers:viola", 1, "dye:violet", 2)
technic.register_extractor_recipe("technic:raw_latex", 1, "technic:rubber", 3)
technic.register_extractor_recipe("moretrees:rubber_tree_trunk_empty", 1, "technic:rubber", 1)
technic.register_extractor_recipe("moretrees:rubber_tree_trunk", 1, "technic:rubber", 1)
technic.register_extractor_recipe("technic:uranium", 5, "technic:enriched_uranium", 1)
technic.register_extractor_recipe("moretrees:rubber_tree_trunk", 1, "technic:rubber", 1)
technic.register_extractor_recipe("technic:uranium", 5, "technic:enriched_uranium", 1)
minetest.register_alias("extractor", "technic:extractor")
minetest.register_craft({
output = 'technic:extractor',
recipe = {
{'technic:treetap', 'technic:motor', 'technic:treetap'},
{'technic:treetap', 'technic:lv_cable0', 'technic:treetap'},
{'', '', ''},
}
})
output = 'technic:extractor',
recipe = {
{'technic:treetap', 'technic:motor', 'technic:treetap'},
{'technic:treetap', 'technic:lv_cable', 'technic:treetap'},
{'','',''},
}
})
minetest.register_craftitem("technic:extractor", {
description = "Extractor",
stack_max = 99,
})
local extractor_formspec =
"invsize[8,9;]"..
@ -55,121 +61,160 @@ local extractor_formspec =
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node("technic:extractor", {
description = "Extractor",
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Extractor")
meta:set_string("formspec", extractor_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node(
"technic:extractor",
{
description = "Extractor",
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Extractor")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", extractor_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node("technic:extractor_active", {
description = "Extractor",
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
paramtype2 = "facedir",
groups = {cracky=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node(
"technic:extractor_active",
{
description = "Extractor",
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
paramtype2 = "facedir",
groups = {cracky=2,not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_abm({
nodenames = {"technic:extractor", "technic:extractor_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
-- The machine will automatically shut down if disconnected from power in some fashion.
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local srcstack = inv:get_stack("src", 1)
local eu_input = meta:get_int("LV_EU_input")
minetest.register_abm(
{ nodenames = {"technic:extractor","technic:extractor_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
-- Run a machine through its states. Takes the same arguments as the ABM action
-- and adds the machine's states and any extra data which is needed by the machine.
-- A machine is characterized by running through a set number of states (usually 2:
-- Idle and active) in some order. A state decides when to move to the next one
-- and the machine only changes state if it is powered correctly.
-- The machine will automatically shut down if disconnected from power in some fashion.
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local state = meta:get_int("state")
local next_state = state
-- Machine information
local machine_name = "Extractor"
local machine_node = "technic:extractor"
local demand = 300
-- Machine information
local machine_name = "Extractor"
local machine_node = "technic:extractor"
local machine_state_demand = { 50, 300 }
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("LV_EU_demand", machine_state_demand[1])
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
-- State machine
if eu_input == 0 then
-- unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
local inv = meta:get_inventory()
local empty = inv:is_empty("src")
local srcstack = inv:get_stack("src", 1)
local src_item = nil
local recipe = nil
local result = nil
if srcstack then
src_item = srcstack:to_table()
end
if src_item then
recipe = technic.get_extractor_recipe(src_item)
end
if recipe then
result = {name=recipe.dst_name, count=recipe.dst_count}
end
if state == 1 then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
-- Setup meta data if it does not exist.
if not eu_input then
meta:set_int("LV_EU_demand", demand)
meta:set_int("LV_EU_input", 0)
return
end
if not empty and result and inv:room_for_item("dst",result) then
meta:set_int("src_time", 0)
next_state = 2
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
elseif state == 2 then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
if srcstack then
src_item = srcstack:to_table()
end
if src_item then
recipe = technic.get_extractor_recipe(src_item)
end
if recipe then
result = {name=recipe.dst_name, count=recipe.dst_count}
end
if inv:is_empty("src") or (not recipe) or (not result) or
(not inv:room_for_item("dst", result)) then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
meta:set_int("LV_EU_demand", 0)
return
end
if empty then
next_state = 1
else
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") == 4 then -- 4 ticks per output
-- check if there's room for output in "dst" list
if eu_input < demand then
-- unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
elseif eu_input >= demand then
-- Powered
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") >= 4 then -- 4 ticks per output
meta:set_int("src_time", 0)
meta:set_int("src_time", 0)
if recipe and inv:room_for_item("dst",result) then
-- take stuff from "src" list
srcstack:take_item(recipe.src_count)
inv:set_stack("src", 1, srcstack)
inv:set_stack("src", 1, srcstack)
-- Put result in "dst" list
inv:add_item("dst", result)
end
end
meta:set_int("LV_EU_demand", demand)
end
})
else
-- all full: go idle
next_state = 1
end
end
end
end
end
-- Change state?
if next_state ~= state then
meta:set_int("LV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
end
})
technic.register_machine("LV", "technic:extractor", technic.receiver)
technic.register_machine("LV", "technic:extractor_active", technic.receiver)
technic.register_LV_machine ("technic:extractor","RE")
technic.register_LV_machine ("technic:extractor_active","RE")

View File

@ -1,139 +1,150 @@
-- The electric generator.
-- The coal driven EU generator.
-- A simple device to get started on the electric machines.
-- Inefficient and expensive in fuel (200EU per tick)
-- Inefficient and expensive in coal (200EU 16 ticks)
-- Also only allows for LV machinery to run.
minetest.register_alias("generator", "technic:generator")
minetest.register_alias("generator", "technic:generator_active")
minetest.register_craft({
output = 'technic:generator',
recipe = {
{'default:stone', 'default:stone', 'default:stone'},
{'default:stone', '', 'default:stone'},
{'default:stone', 'default:stone', 'default:stone'},
{'default:stone', '', 'default:stone'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
minetest.register_craftitem("technic:generator", {
description = "Coal Driven Generator",
stack_max = 99,
})
local generator_formspec =
"invsize[8,9;]"..
"label[0,0;Generator]"..
"image[0,0;5,5;technic_generator_menu.png]"..
"image[1,1;1,2;technic_power_meter_bg.png]"..
-- "label[0,0;Generator]"..
"label[1,3;Power level]"..
"list[current_name;src;3,1;1,1;]"..
"image[4,1;1,1;default_furnace_fire_bg.png]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node("technic:generator", {
description = "Electric Generator",
tiles = {"technic_generator_top.png", "technic_machine_bottom.png", "technic_generator_side.png",
"technic_generator_side.png", "technic_generator_side.png", "technic_generator_front.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Electric Generator")
meta:set_int("LV_EU_supply", 0)
-- Signal to the switching station that this device burns some
-- sort of fuel and needs special handling
meta:set_int("LV_EU_from_fuel", 1)
meta:set_int("burn_time", 0)
meta:set_string("formspec", generator_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node("technic:generator_active", {
description = "Electric Generator",
tiles = {"technic_generator_top.png", "technic_machine_bottom.png",
"technic_generator_side.png", "technic_generator_side.png",
"technic_generator_side.png", "technic_generator_front_active.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop = "technic:generator",
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") then
minetest.chat_send_player(player:get_player_name(),
"Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_abm({
nodenames = {"technic:generator", "technic:generator_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local burn_time = meta:get_int("burn_time")
local burn_totaltime = meta:get_int("burn_totaltime")
-- If more to burn and the energy produced was used: produce some more
if burn_time > 0 then
meta:set_int("LV_EU_supply", 200) -- Give 200EUs
burn_time = burn_time - 1
meta:set_int("burn_time", burn_time)
end
-- Burn another piece of fuel
if burn_time == 0 then
minetest.register_node(
"technic:generator",
{
description = "Coal Driven Generator",
tiles = {"technic_generator_top.png", "technic_machine_bottom.png", "technic_generator_side.png",
"technic_generator_side.png", "technic_generator_side.png", "technic_generator_front.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Coal Electric Generator")
meta:set_float("technic_power_machine", 1)
meta:set_int("LV_EU_supply", 0)
meta:set_int("LV_EU_from_fuel", 1) -- Signal to the switching station that this device burns some sort of fuel and needs special handling
meta:set_int("burn_time", 0)
meta:set_string("formspec", generator_formspec)
local inv = meta:get_inventory()
if not inv:is_empty("src") then
local fuellist = inv:get_list("src")
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
if not fuel or fuel.time == 0 then
meta:set_string("infotext", "Generator out of fuel")
hacky_swap_node(pos, "technic:generator")
return
end
meta:set_int("burn_time", fuel.time)
meta:set_int("burn_totaltime", fuel.time)
inv:set_size("src", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node(
"technic:generator_active",
{
description = "Coal Driven Generator",
tiles = {"technic_generator_top.png", "technic_machine_bottom.png", "technic_generator_side.png",
"technic_generator_side.png", "technic_generator_side.png", "technic_generator_front_active.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop="technic:generator",
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
local stack = inv:get_stack("src", 1)
stack:take_item()
inv:set_stack("src", 1, stack)
hacky_swap_node(pos, "technic:generator_active")
meta:set_int("LV_EU_supply", 200) -- Give 200EUs
minetest.register_abm(
{
nodenames = {"technic:generator","technic:generator_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local burn_time= meta:get_int("burn_time")
-- If more to burn and the energy produced was used: produce some more
if burn_time>0 then
if meta:get_int("LV_EU_supply") == 0 then
-- We did not use the power
meta:set_int("LV_EU_supply", 200) -- Give 200EUs
else
burn_time = burn_time - 1
meta:set_int("burn_time",burn_time)
meta:set_string("infotext", "Coal Electric Generator ("..math.floor(burn_time/16*100).."%)")
end
end
-- Burn another piece of coal
if burn_time==0 then
local inv = meta:get_inventory()
if inv:is_empty("src") == false then
local srcstack = inv:get_stack("src", 1)
src_item=srcstack:to_table()
if src_item["name"] == "default:coal_lump" then
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
burn_time=16
meta:set_int("burn_time",burn_time)
hacky_swap_node (pos,"technic:generator_active")
meta:set_int("LV_EU_supply", 200) -- Give 200EUs
else
hacky_swap_node(pos, "technic:generator")
meta:set_int("LV_EU_supply", 0)
meta:set_int("LV_EU_supply", 0)
end
end
end
end
local percent = math.floor((burn_time / burn_totaltime) * 100)
meta:set_string("infotext", "Electric Generator ("..percent.."%)")
meta:set_string("formspec",
"size[8,9]"..
"label[0,0;Generator]"..
"list[current_name;src;3,1;1,1;]"..
"image[4,1;1,1;default_furnace_fire_bg.png^[lowpart:"..
(percent)..":default_furnace_fire_fg.png]"..
"list[current_player;main;0,5;8,4;]")
end
})
local load = 8 -- math.floor((charge/max_charge)*100)
local percent = math.floor((burn_time/16)*100)
meta:set_string("formspec",
"invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
(load)..":technic_power_meter_fg.png]"..
"label[0,0;Generator]"..
"label[1,3;Power level]"..
"list[current_name;src;3,1;1,1;]"..
"image[4,1;1,1;default_furnace_fire_bg.png^[lowpart:"..
(percent)..":default_furnace_fire_fg.png]"..
"list[current_player;main;0,5;8,4;]"
)
technic.register_machine("LV", "technic:generator", technic.producer)
technic.register_machine("LV", "technic:generator_active", technic.producer)
if burn_time==0 then
hacky_swap_node (pos,"technic:generator")
end
end
})
technic.register_LV_machine ("technic:generator","PR")
technic.register_LV_machine ("technic:generator_active","PR")

View File

@ -2,7 +2,6 @@
-- Using hot lava and water this device can create energy from steam
-- The machine is only producing LV EUs and can thus not drive more advanced equipment
-- The output is a little more than the coal burning generator (max 300EUs)
minetest.register_alias("geothermal", "technic:geothermal")
minetest.register_craft({
@ -21,103 +20,137 @@ minetest.register_craftitem("technic:geothermal", {
local geothermal_formspec =
"invsize[8,4;]"..
"image[1,1;1,2;technic_power_meter_bg.png]"..
"label[0,0;Geothermal Generator]"..
"label[1,3;Power level]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node("technic:geothermal", {
description = "Geothermal Generator",
tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Geothermal Generator")
meta:set_float("technic_power_machine", 1)
meta:set_int("LV_EU_supply", 0)
meta:set_string("formspec", geothermal_formspec)
end,
})
minetest.register_node(
"technic:geothermal",
{
description = "Geothermal Generator",
tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Geothermal Generator")
meta:set_float("technic_power_machine", 1)
meta:set_int("LV_EU_supply", 0)
meta:set_string("formspec", geothermal_formspec)
end,
})
minetest.register_node("technic:geothermal_active", {
description = "Geothermal Generator",
tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop = "technic:geothermal",
})
minetest.register_node(
"technic:geothermal_active",
{
description = "Geothermal Generator",
tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop="technic:geothermal",
})
local check_node_around = function(pos)
local node = minetest.get_node(pos)
if node.name == "default:water_source" or node.name == "default:water_flowing" then return 1 end
if node.name == "default:lava_source" or node.name == "default:lava_flowing" then return 2 end
return 0
end
local node=minetest.env:get_node(pos)
if node.name=="default:water_source" or node.name=="default:water_flowing" then return 1 end
if node.name=="default:lava_source" or node.name=="default:lava_flowing" then return 2 end
return 0
end
minetest.register_abm({
nodenames = {"technic:geothermal","technic:geothermal_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local water_nodes = 0
local lava_nodes = 0
local production_level = 0
local eu_supply = 0
minetest.register_abm(
{
nodenames = {"technic:geothermal","technic:geothermal_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local water_nodes = 0
local lava_nodes = 0
local production_level = 0
local eu_supply = 0
-- Correct positioning is water on one side and lava on the other.
-- The two cannot be adjacent because the lava the turns into obsidian or rock.
-- To get to 100% production stack the water and lava one extra block down as well:
-- WGL (W=Water, L=Lava, G=the generator, |=an LV cable)
-- W|L
-- Correct positioning is water on one side and lava on the other.
-- The two cannot be adjacent because the lava the turns into obsidian or rock.
-- To get to 100% production stack the water and lava one extra block down as well:
-- WGL (W=Water, L=Lava, G=the generator, |=an LV cable)
-- W|L
pos.x=pos.x+1
local check=check_node_around(pos)
if check==1 then water_nodes=water_nodes+1 end
if check==2 then lava_nodes=lava_nodes+1 end
pos.y=pos.y-1
local check=check_node_around(pos)
if check==1 then water_nodes=water_nodes+1 end
if check==2 then lava_nodes=lava_nodes+1 end
local positions = {
{x=pos.x+1, y=pos.y, z=pos.z},
{x=pos.x+1, y=pos.y-1, z=pos.z},
{x=pos.x-1, y=pos.y, z=pos.z},
{x=pos.x-1, y=pos.y-1, z=pos.z},
{x=pos.x, y=pos.y, z=pos.z+1},
{x=pos.x, y=pos.y-1, z=pos.z+1},
{x=pos.x, y=pos.y, z=pos.z-1},
{x=pos.x, y=pos.y-1, z=pos.z-1},
}
for _, p in pairs(positions) do
local check = check_node_around(p)
if check == 1 then water_nodes = water_nodes + 1 end
if check == 2 then lava_nodes = lava_nodes + 1 end
end
pos.x=pos.x-2
check=check_node_around(pos)
if check==1 then water_nodes=water_nodes+1 end
if check==2 then lava_nodes=lava_nodes+1 end
pos.y=pos.y+1
check=check_node_around(pos)
if check==1 then water_nodes=water_nodes+1 end
if check==2 then lava_nodes=lava_nodes+1 end
if water_nodes == 1 and lava_nodes == 1 then production_level = 25; eu_supply = 50 end
if water_nodes == 2 and lava_nodes == 1 then production_level = 50; eu_supply = 100 end
if water_nodes == 1 and lava_nodes == 2 then production_level = 75; eu_supply = 200 end
if water_nodes == 2 and lava_nodes == 2 then production_level = 100; eu_supply = 300 end
pos.x=pos.x+1
pos.z=pos.z+1
check=check_node_around(pos)
if check==1 then water_nodes=water_nodes+1 end
if check==2 then lava_nodes=lava_nodes+1 end
pos.y=pos.y-1
check=check_node_around(pos)
if check==1 then water_nodes=water_nodes+1 end
if check==2 then lava_nodes=lava_nodes+1 end
if production_level > 0 then
meta:set_int("LV_EU_supply", eu_supply)
end
pos.z=pos.z-2
check=check_node_around(pos)
if check==1 then water_nodes=water_nodes+1 end
if check==2 then lava_nodes=lava_nodes+1 end
pos.y=pos.y+1
check=check_node_around(pos)
if check==1 then water_nodes=water_nodes+1 end
if check==2 then lava_nodes=lava_nodes+1 end
meta:set_string("formspec",
"invsize[8,4;]"..
"label[0,0;Geothermal Generator]"..
"label[4,0;Production at "..tostring(production_level).."%]")
-- Back to (0,0,0)
pos.z=pos.z+1
if water_nodes==1 and lava_nodes==1 then production_level = 25; eu_supply = 50 end
if water_nodes==2 and lava_nodes==1 then production_level = 50; eu_supply = 100 end
if water_nodes==1 and lava_nodes==2 then production_level = 75; eu_supply = 200 end
if water_nodes==2 and lava_nodes==2 then production_level = 100; eu_supply = 300 end
if production_level > 0 and minetest.get_node(pos).name == "technic:geothermal" then
hacky_swap_node (pos, "technic:geothermal_active")
return
end
if production_level == 0 then
hacky_swap_node(pos, "technic:geothermal")
meta:set_int("LV_EU_supply", 0)
end
end
})
if production_level>0 then
meta:set_int("LV_EU_supply", eu_supply)
end
technic.register_machine("LV", "technic:geothermal", technic.producer)
technic.register_machine("LV", "technic:geothermal_active", technic.producer)
local load = 1 -- math.floor((charge/max_charge)*100)
meta:set_string("formspec",
"invsize[8,4;]"..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
(load)..":technic_power_meter_fg.png]"..
"label[0,0;Geothermal Generator]"..
"label[1,3;Power level]"..
"label[4,0;Production at "..tostring(production_level).."%]"
)
if production_level>0 and minetest.env:get_node(pos).name=="technic:geothermal" then
hacky_swap_node (pos,"technic:geothermal_active")
return
end
if production_level==0 then
hacky_swap_node (pos,"technic:geothermal")
meta:set_int("LV_EU_supply", 0)
end
end
})
technic.register_LV_machine ("technic:geothermal","PR")
technic.register_LV_machine ("technic:geothermal_active","PR")

View File

@ -1,13 +1,352 @@
technic.grinder_recipes ={}
technic.register_grinder_recipe = function(src, dst)
technic.grinder_recipes[src] = dst
if unified_inventory then
unified_inventory.register_craft(
{
type = "grinding",
output = dst,
items = {src},
width = 0,
})
end
end
-- Receive an ItemStack of result by an ItemStack input
technic.get_grinder_recipe = function(itemstack)
local src_item = itemstack:to_table()
if src_item == nil then
return nil
end
local item_name = src_item["name"]
if technic.grinder_recipes[item_name] then
return ItemStack(technic.grinder_recipes[item_name])
else
return nil
end
end
technic.register_grinder_recipe("default:stone","default:sand")
technic.register_grinder_recipe("default:cobble","default:gravel")
technic.register_grinder_recipe("default:gravel","default:dirt")
technic.register_grinder_recipe("default:desert_stone","default:desert_sand")
technic.register_grinder_recipe("default:iron_lump","technic:iron_dust 2")
technic.register_grinder_recipe("default:steel_ingot","technic:iron_dust 1")
technic.register_grinder_recipe("default:coal_lump","technic:coal_dust 2")
technic.register_grinder_recipe("default:copper_lump","technic:copper_dust 2")
technic.register_grinder_recipe("default:copper_ingot","technic:copper_dust 1")
technic.register_grinder_recipe("default:gold_lump","technic:gold_dust 2")
technic.register_grinder_recipe("default:gold_ingot","technic:gold_dust 1")
--technic.register_grinder_recipe("default:bronze_ingot","technic:bronze_dust 1") -- Dust does not exist yet
--technic.register_grinder_recipe("home_decor:brass_ingot","technic:brass_dust 1") -- needs check for the mod
technic.register_grinder_recipe("moreores:tin_lump","technic:tin_dust 2")
technic.register_grinder_recipe("moreores:tin_ingot","technic:tin_dust 1")
technic.register_grinder_recipe("moreores:silver_lump","technic:silver_dust 2")
technic.register_grinder_recipe("moreores:silver_ingot","technic:silver_dust 1")
technic.register_grinder_recipe("moreores:mithril_lump","technic:mithril_dust 2")
technic.register_grinder_recipe("moreores:mithril_ingot","technic:mithril_dust 1")
technic.register_grinder_recipe("technic:chromium_lump","technic:chromium_dust 2")
technic.register_grinder_recipe("technic:chromium_ingot","technic:chromium_dust 1")
technic.register_grinder_recipe("technic:stainless_steel_ingot","stainless_steel_dust 1")
technic.register_grinder_recipe("technic:brass_ingot","technic:brass_dust 1")
technic.register_grinder_recipe("technic:zinc_lump","technic:zinc_dust 2")
technic.register_grinder_recipe("technic:zinc_ingot","technic:zinc_dust 1")
minetest.register_craftitem( "technic:coal_dust", {
description = "Coal Dust",
inventory_image = "technic_coal_dust.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craftitem( "technic:iron_dust", {
description = "Iron Dust",
inventory_image = "technic_iron_dust.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
type = "cooking",
output = "default:steel_ingot",
recipe = "technic:iron_dust",
})
minetest.register_craftitem( "technic:copper_dust", {
description = "Copper Dust",
inventory_image = "technic_copper_dust.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
type = "cooking",
output = "moreores:copper_ingot",
recipe = "technic:copper_dust",
})
minetest.register_craftitem( "technic:tin_dust", {
description = "Tin Dust",
inventory_image = "technic_tin_dust.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
type = "cooking",
output = "moreores:tin_ingot",
recipe = "technic:tin_dust",
})
minetest.register_craftitem( "technic:silver_dust", {
description = "Silver Dust",
inventory_image = "technic_silver_dust.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
type = "cooking",
output = "moreores:silver_ingot",
recipe = "technic:silver_dust",
})
minetest.register_craftitem( "technic:gold_dust", {
description = "Gold Dust",
inventory_image = "technic_gold_dust.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
type = "cooking",
output = "default:gold_ingot",
recipe = "technic:gold_dust",
})
minetest.register_craftitem( "technic:mithril_dust", {
description = "Mithril Dust",
inventory_image = "technic_mithril_dust.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
type = "cooking",
output = "moreores:mithril_ingot",
recipe = "technic:mithril_dust",
})
minetest.register_craftitem( "technic:chromium_dust", {
description = "Chromium Dust",
inventory_image = "technic_chromium_dust.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
type = "cooking",
output = "technic:chromium_ingot",
recipe = "technic:chromium_dust",
})
minetest.register_craftitem( "technic:bronze_dust", {
description = "Bronze Dust",
inventory_image = "technic_bronze_dust.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
type = "cooking",
output = "default:bronze_ingot",
recipe = "technic:bronze_dust",
})
minetest.register_craftitem( "technic:brass_dust", {
description = "Brass Dust",
inventory_image = "technic_brass_dust.png",
on_place_on_ground = minetest.craftitem_place_item,
})
minetest.register_craft({
type = "cooking",
output = "technic:brass_ingot",
recipe = "technic:brass_dust",
})
minetest.register_craftitem( "technic:stainless_steel_dust", {
description = "Stainless Steel Dust",
inventory_image = "technic_stainless_steel_dust.png",
})
minetest.register_craft({
type = "cooking",
output = "technic:stainless_steel_ingot",
recipe = "technic:stainless_steel_dust",
})
minetest.register_craftitem( "technic:zinc_dust", {
description = "Zinc Dust",
inventory_image = "technic_zinc_dust.png",
})
minetest.register_craft({
type = "cooking",
output = "technic:zinc_ingot",
recipe = "technic:zinc_dust",
})
minetest.register_alias("grinder", "technic:grinder")
minetest.register_craft({
output = 'technic:grinder',
recipe = {
{'default:desert_stone', 'default:desert_stone', 'default:desert_stone'},
{'default:desert_stone', 'default:diamond', 'default:desert_stone'},
{'default:stone', 'moreores:copper_ingot', 'default:stone'},
}
})
output = 'technic:grinder',
recipe = {
{'default:desert_stone', 'default:desert_stone', 'default:desert_stone'},
{'default:desert_stone', 'default:diamond', 'default:desert_stone'},
{'default:stone', 'moreores:copper_ingot', 'default:stone'},
}
})
technic.register_grinder({tier="LV", demand={200}, speed=1})
minetest.register_craftitem("technic:grinder", {
description = "Grinder",
stack_max = 99,
})
local grinder_formspec =
"invsize[8,9;]"..
"label[0,0;Grinder]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node(
"technic:grinder",
{
description = "Grinder",
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front.png"},
paramtype2 = "facedir",
groups = {cracky=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Grinder")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", grinder_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node(
"technic:grinder_active",
{
description = "Grinder",
tiles = {"technic_lv_grinder_top.png", "technic_lv_grinder_bottom.png", "technic_lv_grinder_side.png",
"technic_lv_grinder_side.png", "technic_lv_grinder_side.png", "technic_lv_grinder_front_active.png"},
paramtype2 = "facedir",
groups = {cracky=2,not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_abm(
{ nodenames = {"technic:grinder","technic:grinder_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
-- Run a machine through its states. Takes the same arguments as the ABM action
-- and adds the machine's states and any extra data which is needed by the machine.
-- A machine is characterized by running through a set number of states (usually 2:
-- Idle and active) in some order. A state decides when to move to the next one
-- and the machine only changes state if it is powered correctly.
-- The machine will automatically shut down if disconnected from power in some fashion.
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local state = meta:get_int("state")
local next_state = state
-- Machine information
local machine_name = "Grinder"
local machine_node = "technic:grinder"
local machine_state_demand = { 50, 300 }
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("LV_EU_demand", machine_state_demand[1])
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
-- State machine
if eu_input == 0 then
-- unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
local inv = meta:get_inventory()
local empty = inv:is_empty("src")
if state == 1 then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
local result = technic.get_grinder_recipe(inv:get_stack("src", 1))
if not empty and result and inv:room_for_item("dst",result) then
meta:set_int("src_time", 0)
next_state = 2
end
elseif state == 2 then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
if empty then
next_state = 1
else
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") == 4 then -- 4 ticks per output
-- check if there's room for output in "dst" list
local result = technic.get_grinder_recipe(inv:get_stack("src", 1))
meta:set_int("src_time", 0)
if inv:room_for_item("dst",result) then
-- take stuff from "src" list
srcstack = inv:get_stack("src", 1)
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
-- Put result in "dst" list
inv:add_item("dst", result)
else
-- all full: go idle
next_state = 1
end
end
end
end
end
-- Change state?
if next_state ~= state then
meta:set_int("LV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
end
})
technic.register_LV_machine ("technic:grinder","RE")
technic.register_LV_machine ("technic:grinder_active","RE")

View File

@ -1,18 +1,15 @@
local path = technic.modpath.."/machines/lv"
technic.register_tier("LV", "Low Voltage")
local path = technic.modpath.."/machines/LV"
dofile(path.."/cables.lua")
dofile(path.."/wires.lua")
dofile(path.."/battery_box.lua")
dofile(path.."/alloy_furnace.lua")
dofile(path.."/coal_alloy_furnace.lua")
dofile(path.."/solar_panel.lua")
dofile(path.."/solar_array.lua")
dofile(path.."/geothermal.lua")
dofile(path.."/water_mill.lua")
dofile(path.."/generator.lua")
dofile(path.."/electric_furnace.lua")
dofile(path.."/tool_workshop.lua")
dofile(path.."/music_player.lua")
dofile(path.."/grinder.lua")
dofile(path.."/cnc.lua")
@ -20,4 +17,3 @@ dofile(path.."/cnc_api.lua")
dofile(path.."/cnc_nodes.lua")
dofile(path.."/extractor.lua")
dofile(path.."/compressor.lua")

View File

@ -1,138 +1,156 @@
-- LV Music player.
-- The player can play music. But it is high ampage!
-- The playe can play music. But it is high ampage!
minetest.register_alias("music_player", "technic:music_player")
minetest.register_craft({
output = 'technic:music_player',
recipe = {
{'group:wood', 'group:wood', 'group:wood'},
{'default:diamond', 'default:diamond', 'default:diamond'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
{'default:wood', 'default:wood', 'default:wood'},
{'default:diamond', 'default:diamond', 'default:diamond'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
local music_player_formspec =
"invsize[8,9;]"..
"label[0,0;Music Player]"..
"button[4,1;1,1;track1;1]"..
"button[5,1;1,1;track2;2]"..
"button[6,1;1,1;track3;3]"..
"button[4,2;1,1;track4;4]"..
"button[5,2;1,1;track5;5]"..
"button[6,2;1,1;track6;6]"..
"button[4,3;1,1;track7;7]"..
"button[5,3;1,1;track8;8]"..
"button[6,3;1,1;track9;9]"..
"button[4,4;1,2;play;Play]"..
"button[6,4;1,2;stop;Stop]"..
"label[4,0;Current track --]"
minetest.register_node("technic:music_player", {
minetest.register_craftitem("technic:music_player", {
description = "Music Player",
tiles = {"technic_music_player_top.png", "technic_machine_bottom.png", "technic_music_player_side.png",
"technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Music Player")
meta:set_int("active", 0)
meta:set_int("current_track", 1)
meta:set_string("formspec", music_player_formspec)
end,
on_receive_fields = function(pos, formanme, fields, sender)
local meta = minetest.get_meta(pos)
local music_handle = meta:get_int("music_handle")
local current_track = meta:get_int("current_track")
if fields.track1 then current_track = 1 end
if fields.track2 then current_track = 2 end
if fields.track3 then current_track = 3 end
if fields.track4 then current_track = 4 end
if fields.track5 then current_track = 5 end
if fields.track6 then current_track = 6 end
if fields.track7 then current_track = 7 end
if fields.track8 then current_track = 8 end
if fields.track9 then current_track = 9 end
meta:set_int("current_track", current_track)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Music Player]"..
"button[4,1;1,1;track1;1]"..
"button[5,1;1,1;track2;2]"..
"button[6,1;1,1;track3;3]"..
"button[4,2;1,1;track4;4]"..
"button[5,2;1,1;track5;5]"..
"button[6,2;1,1;track6;6]"..
"button[4,3;1,1;track7;7]"..
"button[5,3;1,1;track8;8]"..
"button[6,3;1,1;track9;9]"..
"button[4,4;1,2;play;Play]"..
"button[6,4;1,2;stop;Stop]"..
"label[4,0;Current track "
..current_track.."]")
if fields.play then
if music_handle then
minetest.sound_stop(music_handle)
end
meta:set_int("active", 1)
end
if fields.stop then
meta:set_int("active", 0)
if music_handle then
minetest.sound_stop(music_handle)
end
end
meta:set_int("music_handle", music_handle)
end,
stack_max = 99,
})
minetest.register_abm({
nodenames = {"technic:music_player"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local machine_name = "Music Player"
local machine_node = "technic:music_player"
local demand = 150
local music_player_formspec =
"invsize[8,9;]"..
"label[0,0;Music Player]"..
"button[4,1;1,1;track1;1]"..
"button[5,1;1,1;track2;2]"..
"button[6,1;1,1;track3;3]"..
"button[4,2;1,1;track4;4]"..
"button[5,2;1,1;track5;5]"..
"button[6,2;1,1;track6;6]"..
"button[4,3;1,1;track7;7]"..
"button[5,3;1,1;track8;8]"..
"button[6,3;1,1;track9;9]"..
"button[4,4;1,2;play;Play]"..
"button[6,4;1,2;stop;Stop]"..
"label[4,0;Current track --]"
local music_handle = meta:get_int("music_handle")
local current_track = meta:get_int("current_track")
minetest.register_node(
"technic:music_player",
{
description = "Music Player",
tiles = {"technic_music_player_top.png", "technic_machine_bottom.png", "technic_music_player_side.png",
"technic_music_player_side.png", "technic_music_player_side.png", "technic_music_player_side.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Music Player")
meta:set_float("technic_power_machine", 1)
meta:set_int("active", 0) -- Is the device on?
meta:set_int("music_player_current_track", 1)
meta:set_string("formspec", music_player_formspec)
end,
on_receive_fields = function(pos, formanme, fields, sender)
local meta = minetest.env:get_meta(pos)
music_handle = meta:get_int("music_handle")
music_player_current_track = meta:get_int("music_player_current_track")
if fields.track1 then music_player_current_track = 1 end
if fields.track2 then music_player_current_track = 2 end
if fields.track3 then music_player_current_track = 3 end
if fields.track4 then music_player_current_track = 4 end
if fields.track5 then music_player_current_track = 5 end
if fields.track6 then music_player_current_track = 6 end
if fields.track7 then music_player_current_track = 7 end
if fields.track8 then music_player_current_track = 8 end
if fields.track9 then music_player_current_track = 9 end
meta:set_int("music_player_current_track",music_player_current_track)
if fields.play and meta:get_int("active") == 0 then
if music_handle then minetest.sound_stop(music_handle) end
music_handle = minetest.sound_play("technic_track"..music_player_current_track, {pos = pos, gain = 1.0,loop = true, max_hear_distance = 72,})
meta:set_int("active",1)
end
if fields.stop then
meta:set_int("active",0)
if music_handle then minetest.sound_stop(music_handle) end
end
meta:set_int("music_handle",music_handle)
end,
})
-- Setup meta data if it does not exist.
if not eu_input then
meta:set_int("LV_EU_demand", demand)
meta:set_int("LV_EU_input", 0)
return
end
minetest.register_abm(
{ nodenames = {"technic:music_player"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local state = meta:get_int("state")
local next_state = state
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
-- Machine information
local machine_name = "Music Player"
local machine_node = "technic:music_player"
local machine_state_demand = { 10, 150 }
local music_handle = meta:get_int("music_handle")
if meta:get_int("active") == 0 then
meta:set_string("infotext", machine_name.." Idle")
meta:set_int("LV_EU_demand", 0)
if music_handle then
minetest.sound_stop(music_handle)
end
return
end
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("LV_EU_demand", machine_state_demand[1])
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
-- State machine
if eu_input == 0 then
-- unpowered - go idle
-- hacky_swap_node(pos, machine_node) -- if someday two nodes for this
meta:set_string("infotext", machine_name.." Unpowered")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
if state == 1 then
-- hacky_swap_node(pos, machine_node) -- if someday two nodes for this
meta:set_string("infotext", machine_name.." Idle")
if eu_input < demand then
meta:set_string("infotext", machine_name.." Unpowered")
if music_handle then
minetest.sound_stop(music_handle)
end
elseif eu_input >= demand then
meta:set_string("infotext", machine_name.." Active")
music_handle = minetest.sound_play("technic_track"..current_track,
{pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,})
meta:set_int("music_handle", music_handle)
end
meta:set_int("LV_EU_demand", demand)
end
})
if meta:get_int("active") == 1 then
next_state = 2
end
technic.register_machine("LV", "technic:music_player", technic.receiver)
elseif state == 2 then
-- hacky_swap_node(pos, machine_node.."_active") -- if someday two nodes for this
meta:set_string("infotext", machine_name.." Active")
music_player_current_track=meta:get_int("music_player_current_track")
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Music Player]"..
"button[4,1;1,1;track1;1]"..
"button[5,1;1,1;track2;2]"..
"button[6,1;1,1;track3;3]"..
"button[4,2;1,1;track4;4]"..
"button[5,2;1,1;track5;5]"..
"button[6,2;1,1;track6;6]"..
"button[4,3;1,1;track7;7]"..
"button[5,3;1,1;track8;8]"..
"button[6,3;1,1;track9;9]"..
"button[4,4;1,2;play;Play]"..
"button[6,4;1,2;stop;Stop]"..
"label[4,0;Current track "..tostring(music_player_current_track).."]"
)
if meta:get_int("active") == 0 then
if music_handle then minetest.sound_stop(music_handle) end
next_state = 1
end
end
end
-- Change state?
if next_state ~= state then
meta:set_int("LV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
end
})
technic.register_LV_machine ("technic:music_player","RE")

View File

@ -4,15 +4,75 @@
-- a stable supply.
-- Solar arrays are not able to store large amounts of energy.
-- The LV arrays are used to make medium voltage arrays.
minetest.register_craft({
output = 'technic:solar_array_lv 1',
recipe = {
{'technic:solar_panel', 'technic:solar_panel', 'technic:solar_panel'},
{'default:steel_ingot', 'technic:lv_transformer', 'default:steel_ingot'},
{'', 'technic:lv_cable0', ''},
}
minetest.register_node("technic:solar_array_lv", {
tiles = {"technic_lv_solar_array_top.png", "technic_lv_solar_array_bottom.png", "technic_lv_solar_array_side.png",
"technic_lv_solar_array_side.png", "technic_lv_solar_array_side.png", "technic_lv_solar_array_side.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
description="LV Solar Array",
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_int("technic_power_machine", 1)
meta:set_int("LV_EU_supply", 0)
meta:set_string("infotext", "LV Solar Array")
end,
})
technic.register_solar_array({tier="LV", power=10})
minetest.register_craft(
{output = 'technic:solar_array_lv 1',
recipe = {
{'technic:solar_panel', 'technic:solar_panel', 'technic:solar_panel'},
{'technic:solar_panel', 'technic:lv_transformer', 'technic:solar_panel'},
{'default:steel_ingot', 'technic:lv_cable', 'default:steel_ingot'},
}
})
minetest.register_abm(
{nodenames = {"technic:solar_array_lv"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
-- The action here is to make the solar array produce power
-- Power is dependent on the light level and the height above ground
-- 130m and above is optimal as it would be above cloud level.
-- Height gives 1/4 of the effect, light 3/4. Max. effect is 160EU for the array.
-- There are many ways to cheat by using other light sources like lamps.
-- As there is no way to determine if light is sunlight that is just a shame.
-- To take care of some of it solar arrays do not work outside daylight hours or if
-- built below -10m
local pos1={}
pos1.y=pos.y+1
pos1.x=pos.x
pos1.z=pos.z
local light = minetest.env:get_node_light(pos1, nil)
local time_of_day = minetest.env:get_timeofday()
local meta = minetest.env:get_meta(pos)
if light == nil then light = 0 end
-- turn on array only during day time and if sufficient light
-- I know this is counter intuitive when cheating by using other light sources.
if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
local charge_to_give = math.floor(light*(light*0.5333+pos1.y/130*2.6667))
if charge_to_give<0 then charge_to_give=0 end
if charge_to_give>160 then charge_to_give=160 end
meta:set_string("infotext", "Solar Array is active ("..charge_to_give.."EU)")
meta:set_int("LV_EU_supply", charge_to_give)
else
meta:set_string("infotext", "Solar Array is inactive");
meta:set_int("LV_EU_supply", 0)
end
end,
})
technic.register_LV_machine ("technic:solar_array_lv","PR")

View File

@ -1,10 +1,9 @@
-- Solar panels are the building blocks of LV solar arrays
-- They can however also be used separately but with reduced efficiency due to the missing transformer.
-- Individual panels are less efficient than when the panels are combined into full arrays.
-- Individual panels are 20% less efficient than when the panels are combined into full arrays.
minetest.register_node("technic:solar_panel", {
tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.png", "technic_solar_panel_side.png",
"technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"},
tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.png", "technic_solar_panel_side.png",
"technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
description="Solar Panel",
@ -13,50 +12,59 @@ minetest.register_node("technic:solar_panel", {
paramtype = "light",
is_ground_content = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
meta:set_int("technic_power_machine", 1)
meta:set_int("LV_EU_supply", 0)
meta:set_string("infotext", "LV Solar Panel")
end,
})
minetest.register_craft({
output = 'technic:solar_panel',
output = 'technic:solar_panel 1',
recipe = {
{'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'},
{'default:steel_ingot', 'technic:lv_cable0', 'default:steel_ingot'},
{'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer','technic:doped_silicon_wafer'},
{'technic:doped_silicon_wafer', 'technic:lv_cable', 'technic:doped_silicon_wafer'},
{'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer','technic:doped_silicon_wafer'},
}
})
minetest.register_abm({
nodenames = {"technic:solar_panel"},
minetest.register_abm(
{nodenames = {"technic:solar_panel"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
-- The action here is to make the solar panel prodice power
-- Power is dependent on the light level and the height above ground
-- 130m and above is optimal as it would be above cloud level.
-- Height gives 1/4 of the effect, light 3/4. Max. effect is 26EU.
-- There are many ways to cheat by using other light sources like lamps.
-- As there is no way to determine if light is sunlight that is just a shame.
-- To take care of some of it solar panels do not work outside daylight hours or if
-- built below -10m
local pos1 = {x=pos.x, y=pos.y+1, z=pos.z}
-- Height gives 1/4 of the effect, light 3/4. Max. effect is 26EU.
-- There are many ways to cheat by using other light sources like lamps.
-- As there is no way to determine if light is sunlight that is just a shame.
-- To take care of some of it solar panels do not work outside daylight hours or if
-- built below -10m
local pos1={}
pos1.y=pos.y+1
pos1.x=pos.x
pos1.z=pos.z
local light = minetest.get_node_light(pos1, nil)
local time_of_day = minetest.get_timeofday()
local meta = minetest.get_meta(pos)
local light = minetest.env:get_node_light(pos1, nil)
local time_of_day = minetest.env:get_timeofday()
local meta = minetest.env:get_meta(pos)
if light == nil then light = 0 end
-- turn on panel only during day time and if sufficient light
-- I know this is counter intuitive when cheating by using other light sources underground.
if light >= 12 and time_of_day >= 0.24 and time_of_day <= 0.76 and pos.y > -10 then
local charge_to_give = math.floor((light + pos1.y) * 3)
charge_to_give = math.max(charge_to_give, 0)
charge_to_give = math.min(charge_to_give, 200)
if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
local charge_to_give=math.floor(light*(light*0.0867+pos1.y/130*0.4333))
if charge_to_give<0 then charge_to_give=0 end
if charge_to_give>26 then charge_to_give=26 end
meta:set_string("infotext", "Solar Panel is active ("..charge_to_give.."EU)")
meta:set_int("LV_EU_supply", charge_to_give)
else
@ -66,5 +74,5 @@ minetest.register_abm({
end,
})
technic.register_machine("LV", "technic:solar_panel", technic.producer)
technic.register_LV_machine ("technic:solar_panel","PR")

View File

@ -0,0 +1,122 @@
-- LV Tool workshop
-- This machine repairs tools.
minetest.register_alias("tool_workshop", "technic:tool_workshop")
minetest.register_craft({
output = 'technic:tool_workshop',
recipe = {
{'default:wood', 'default:wood', 'default:wood'},
{'default:wood', 'default:diamond', 'default:wood'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
minetest.register_craftitem("technic:tool_workshop", {
description = "Tool Workshop",
stack_max = 99,
})
local workshop_formspec =
"invsize[8,9;]"..
"list[current_name;src;3,1;1,1;]"..
"label[0,0;Tool Workshop]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node(
"technic:tool_workshop",
{
description = "Tool Workshop",
tiles = {"technic_workshop_top.png", "technic_machine_bottom.png", "technic_workshop_side.png",
"technic_workshop_side.png", "technic_workshop_side.png", "technic_workshop_side.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Tool Workshop")
meta:set_float("technic_power_machine", 1)
meta:set_string("formspec", workshop_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
end
return true
end,
})
minetest.register_abm(
{ nodenames = {"technic:tool_workshop"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("LV_EU_input")
local state = meta:get_int("state")
local next_state = state
-- Machine information
local machine_name = "Tool Workshop"
local machine_node = "technic:tool_workshop"
local machine_state_demand = { 50, 150 }
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("LV_EU_demand", machine_state_demand[1])
meta:set_int("LV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "LV")
-- State machine
if eu_input == 0 then
-- Unpowered - go idle
--hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
local inv = meta:get_inventory()
if state == 1 then
--hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
if not inv:is_empty("src") then
next_state = 2
end
elseif state == 2 then
--hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
if inv:is_empty("src") then
next_state = 1
else
srcstack = inv:get_stack("src", 1)
src_item=srcstack:to_table()
-- Cannot charge cans
if (src_item["name"]=="technic:water_can" or src_item["name"]=="technic:lava_can") then
return
end
local wear=tonumber(src_item["wear"])
wear = math.max(1, wear-2000) -- Improve the tool this much every tick
src_item["wear"]=tostring(wear)
inv:set_stack("src", 1, src_item)
end
end
end
-- Change state?
if next_state ~= state then
meta:set_int("LV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
end
})
technic.register_LV_machine ("technic:tool_workshop","RE")

View File

@ -6,96 +6,117 @@ minetest.register_alias("water_mill", "technic:water_mill")
minetest.register_craft({
output = 'technic:water_mill',
recipe = {
{'default:stone', 'default:stone', 'default:stone'},
{'group:wood', 'default:diamond', 'group:wood'},
{'default:stone', 'default:stone', 'default:stone'},
{'default:wood', 'default:diamond', 'default:wood'},
{'default:stone', 'default:copper_ingot', 'default:stone'},
}
})
minetest.register_node("technic:water_mill", {
minetest.register_craftitem("technic:water_mill", {
description = "Water Mill",
tiles = {"technic_water_mill_top.png", "technic_machine_bottom.png",
"technic_water_mill_side.png", "technic_water_mill_side.png",
"technic_water_mill_side.png", "technic_water_mill_side.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Water Mill")
meta:set_int("LV_EU_supply", 0)
end,
})
minetest.register_node("technic:water_mill_active", {
description = "Water Mill",
tiles = {"technic_water_mill_top_active.png", "technic_machine_bottom.png",
"technic_water_mill_side.png", "technic_water_mill_side.png",
"technic_water_mill_side.png", "technic_water_mill_side.png"},
paramtype2 = "facedir",
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop = "technic:water_mill",
})
local function check_node_around_mill(pos)
local node = minetest.get_node(pos)
if node.name == "default:water_flowing" or
node.name == "default:water_source" then
return true
end
return false
end
minetest.register_abm({
nodenames = {"technic:water_mill", "technic:water_mill_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
local water_nodes = 0
local lava_nodes = 0
local production_level = 0
local eu_supply = 0
local positions = {
{x=pos.x+1, y=pos.y, z=pos.z},
{x=pos.x-1, y=pos.y, z=pos.z},
{x=pos.x, y=pos.y, z=pos.z+1},
{x=pos.x, y=pos.y, z=pos.z-1},
}
for _, p in pairs(positions) do
local check = check_node_around_mill(p)
if check then
water_nodes = water_nodes + 1
end
end
production_level = 25 * water_nodes
eu_supply = 30 * water_nodes
if production_level > 0 then
meta:set_int("LV_EU_supply", eu_supply)
end
meta:set_string("infotext",
"Water Mill ("..production_level.."%)")
if production_level > 0 and
minetest.get_node(pos).name == "technic:water_mill" then
hacky_swap_node (pos, "technic:water_mill_active")
meta:set_int("LV_EU_supply", 0)
return
end
if production_level == 0 then
hacky_swap_node(pos, "technic:water_mill")
end
end
stack_max = 99,
})
technic.register_machine("LV", "technic:water_mill", technic.producer)
technic.register_machine("LV", "technic:water_mill_active", technic.producer)
local water_mill_formspec =
"invsize[8,4;]"..
"image[1,1;1,2;technic_power_meter_bg.png]"..
"label[0,0;Water Mill]"..
"label[1,3;Power level]"..
"list[current_player;main;0,5;8,4;]"
minetest.register_node(
"technic:water_mill",
{
description = "Water Mill",
tiles = {"technic_water_mill_top.png", "technic_machine_bottom.png", "technic_water_mill_side.png",
"technic_water_mill_side.png", "technic_water_mill_side.png", "technic_water_mill_side.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Water Mill")
meta:set_float("technic_power_machine", 1)
meta:set_int("LV_EU_supply", 0)
meta:set_string("formspec", water_mill_formspec)
end,
})
minetest.register_node(
"technic:water_mill_active",
{
description = "Water Mill",
tiles = {"technic_water_mill_top_active.png", "technic_machine_bottom.png", "technic_water_mill_side.png",
"technic_water_mill_side.png", "technic_water_mill_side.png", "technic_water_mill_side.png"},
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop="technic:water_mill",
})
local check_node_around_mill = function(pos)
local node=minetest.env:get_node(pos)
if node.name=="default:water_flowing" then return 1 end
return 0
end
minetest.register_abm(
{
nodenames = {"technic:water_mill","technic:water_mill_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local water_nodes = 0
local lava_nodes = 0
local production_level = 0
local eu_supply = 0
pos.x=pos.x+1
local check=check_node_around_mill (pos)
if check==1 then water_nodes=water_nodes+1 end
pos.x=pos.x-2
check=check_node_around_mill (pos)
if check==1 then water_nodes=water_nodes+1 end
pos.x=pos.x+1
pos.z=pos.z+1
check=check_node_around_mill (pos)
if check==1 then water_nodes=water_nodes+1 end
pos.z=pos.z-2
check=check_node_around_mill (pos)
if check==1 then water_nodes=water_nodes+1 end
pos.z=pos.z+1
if water_nodes==1 then production_level = 25; eu_supply = 30 end
if water_nodes==2 then production_level = 50; eu_supply = 60 end
if water_nodes==3 then production_level = 75; eu_supply = 90 end
if water_nodes==4 then production_level = 100; eu_supply = 120 end
if production_level>0 then
meta:set_int("LV_EU_supply", eu_supply)
end
local load = 1 -- math.floor((charge/max_charge)*100)
meta:set_string("formspec",
"invsize[8,4;]"..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
(load)..":technic_power_meter_fg.png]"..
"label[0,0;Water Mill]"..
"label[1,3;Power level]"..
"label[4,0;Production at "..tostring(production_level).."%]"
)
if production_level>0 and minetest.env:get_node(pos).name=="technic:water_mill" then
hacky_swap_node (pos,"technic:water_mill_active")
meta:set_int("LV_EU_supply", 0)
return
end
if production_level==0 then hacky_swap_node (pos,"technic:water_mill") end
end
})
technic.register_LV_machine ("technic:water_mill","PR")
technic.register_LV_machine ("technic:water_mill_active","PR")

View File

@ -0,0 +1,401 @@
--LV cable node boxes
minetest.register_alias("lv_cable", "technic:lv_cable")
minetest.register_craft({
output = 'technic:lv_cable 6',
recipe = {
{'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
}
})
minetest.register_craftitem("technic:lv_cable", {
description = "Low Voltage Copper Cable",
stack_max = 99,
})
minetest.register_node("technic:lv_cable", {
description = "Low Voltage Copper Cable",
tiles = {"technic_lv_cable.png"},
inventory_image = "technic_lv_cable_wield.png",
wield_image = "technic_lv_cable_wield.png",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
drop = "technic:lv_cable",
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("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)
check_connections (pos)
end,
after_dig_node = function (pos, oldnode, oldmetadata, digger)
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:lv_cable"..count, {
description = "Low Voltage Copper Cable",
tiles = {"technic_lv_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:lv_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)
check_connections_on_destroy (pos)
end,
})
count=count+1 end end end end end end
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("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:lv_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:lv_cable"..rule)
end
pos1.x=pos1.x-2
if minetest.env:get_meta(pos1):get_float("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:lv_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:lv_cable"..rule)
end
pos1.x=pos1.x+1
pos1.y=pos1.y+1
if minetest.env:get_meta(pos1):get_float("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:lv_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:lv_cable"..rule)
end
if minetest.env:get_meta(pos1):get_float("technic_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:lv_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("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:lv_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:lv_cable"..rule)
end
pos1.y=pos1.y+1
pos1.z=pos1.z+1
if minetest.env:get_meta(pos1):get_float("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:lv_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:lv_cable"..rule)
end
pos1.z=pos1.z-2
if minetest.env:get_meta(pos1):get_float("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:lv_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:lv_cable"..rule)
end
pos1.z=pos1.z+1
end
function make_rule_number (x1,x2,y1,y2,z1,z2)
local temp= z2+z1*2+y2*4+y1*8+x2*16+x1*32
return temp
end
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("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:lv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:lv_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("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:lv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:lv_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("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:lv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:lv_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("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:lv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:lv_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("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:lv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:lv_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("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:lv_cable") end
if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
meta=minetest.env:get_meta(pos1)
meta:set_float("z1",z1)
end
pos1.y=pos1.y+1
end

View File

@ -3,12 +3,458 @@
minetest.register_craft({
output = 'technic:mv_alloy_furnace',
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_alloy_furnace', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
{'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
{'technic:stainless_steel_ingot', 'technic:alloy_furnace', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
}
})
local mv_alloy_furnace_formspec =
"invsize[8,10;]"..
"label[0,0;MV Alloy Furnace]"..
"list[current_name;src;3,1;1,2;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,6;8,4;]"..
"list[current_name;upgrade1;1,4;1,1;]"..
"list[current_name;upgrade2;2,4;1,1;]"..
"label[1,5;Upgrade Slots]"
minetest.register_node(
"technic:mv_alloy_furnace",
{description = "MV Alloy Furnace",
tiles = {"technic_mv_alloy_furnace_top.png", "technic_mv_alloy_furnace_bottom.png", "technic_mv_alloy_furnace_side_tube.png",
"technic_mv_alloy_furnace_side_tube.png", "technic_mv_alloy_furnace_side.png", "technic_mv_alloy_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky=2, tubedevice=1,tubedevice_receiver=1},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("src",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("src",stack)
end,
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "MV Alloy furnace")
meta:set_float("technic_mv_power_machine", 1)
meta:set_int("tube_time", 0)
meta:set_string("formspec", mv_alloy_furnace_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 2)
inv:set_size("dst", 4)
inv:set_size("upgrade1", 1)
inv:set_size("upgrade2", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
technic.register_alloy_furnace({tier="MV", cook_time=4, upgrade=1, tube=1, demand={3000, 2000, 1000}})
minetest.register_node(
"technic:mv_alloy_furnace_active",
{description = "MV Alloy Furnace",
tiles = {"technic_mv_alloy_furnace_top.png", "technic_mv_alloy_furnace_bottom.png", "technic_mv_alloy_furnace_side_tube.png",
"technic_mv_alloy_furnace_side_tube.png", "technic_mv_alloy_furnace_side.png", "technic_mv_alloy_furnace_front_active.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "technic:mv_alloy_furnace",
groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("src",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("src",stack)
end,
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
-- These three makes sure upgrades are not moved in or out while the furnace is active.
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "src" or listname == "dst" then
return 99
else
return 0 -- Disallow the move
end
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if listname == "src" or listname == "dst" then
return 99
else
return 0 -- Disallow the move
end
end,
allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player)
return 0
end,
})
local send_cooked_items = function(pos,x_velocity,z_velocity)
-- Send items on their way in the pipe system.
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local i=0
for _,stack in ipairs(inv:get_list("dst")) do
i=i+1
if stack then
local item0=stack:to_table()
if item0 then
item0["count"]="1"
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
item1:setacceleration({x=0, y=0, z=0})
stack:take_item(1);
inv:set_stack("dst", i, stack)
return
end
end
end
end
local smelt_item = function(pos)
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
meta:set_int("src_time", meta:get_int("src_time") + 3) -- Cooking time 3x faster
local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
dst_stack={}
dst_stack["name"]=alloy_recipes[dst_index].dst_name
dst_stack["count"]=alloy_recipes[dst_index].dst_count
if result and result.item and meta:get_int("src_time") >= result.time then
meta:set_int("src_time", 0)
-- check if there's room for output in "dst" list
if inv:room_for_item("dst",result) then
-- take stuff from "src" list
srcstack = inv:get_stack("src", 1)
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
-- Put result in "dst" list
inv:add_item("dst", result.item)
return 1
else
return 0 -- done
end
end
return 0 -- done
end
minetest.register_abm(
{nodenames = {"technic:mv_alloy_furnace","technic:mv_alloy_furnace_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("MV_EU_input")
local state = meta:get_int("state")
local next_state = state
-- Machine information
local machine_name = "MV Alloy Furnace"
local machine_node = "technic:mv_alloy_furnace"
local machine_state_demand = { 50, 2000, 1500, 1000 }
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("MV_EU_demand", machine_state_demand[1])
meta:set_int("MV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "MV")
-- Execute always logic
-- CODE HERE --
-- State machine
if eu_input == 0 then
-- Unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
-- Execute always if powered logic
local meta=minetest.env:get_meta(pos)
-- Get the names of the upgrades
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local upg_item1
local upg_item1_name=""
local upg_item2
local upg_item2_name=""
local srcstack = inv:get_stack("upgrade1", 1)
if srcstack then upg_item1=srcstack:to_table() end
srcstack = inv:get_stack("upgrade2", 1)
if srcstack then upg_item2=srcstack:to_table() end
if upg_item1 then upg_item1_name=upg_item1.name end
if upg_item2 then upg_item2_name=upg_item2.name end
-- Save some power by installing battery upgrades. Fully upgraded makes this
-- furnace use the same amount of power as the LV version
local EU_saving_upgrade = 0
if upg_item1_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
if upg_item2_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
-- Tube loading speed can be upgraded using control logic units
local tube_speed_upgrade = 0
if upg_item1_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
if upg_item2_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
-- Handle pipeworks (consumes tube_speed_upgrade)
local pos1={x=pos.x, y=pos.y, z=pos.z}
local x_velocity=0
local z_velocity=0
-- Output is on the left side of the furnace
if node.param2==3 then pos1.z=pos1.z-1 z_velocity =-1 end
if node.param2==2 then pos1.x=pos1.x-1 x_velocity =-1 end
if node.param2==1 then pos1.z=pos1.z+1 z_velocity = 1 end
if node.param2==0 then pos1.x=pos1.x+1 x_velocity = 1 end
local output_tube_connected = false
local meta1 = minetest.env:get_meta(pos1)
if meta1:get_int("tubelike") == 1 then
output_tube_connected=true
end
tube_time = meta:get_int("tube_time")
tube_time = tube_time + tube_speed_upgrade
if tube_time > 3 then
tube_time = 0
if output_tube_connected then
send_cooked_items(pos,x_velocity,z_velocity)
end
end
meta:set_int("tube_time", tube_time)
-- The machine shuts down if we have nothing to smelt since we tube stuff
-- out while being idle.
if inv:is_empty("src") then
next_state = 1
end
----------------------
local empty = 1
local recipe = nil
local result = nil
-- Get what to cook if anything
local srcstack = inv:get_stack("src", 1)
local src2stack = inv:get_stack("src", 2)
local src_item1 = nil
local src_item2 = nil
if srcstack and src2stack then
src_item1 = srcstack:to_table()
src_item2 = src2stack:to_table()
empty = 0
end
if src_item1 and src_item2 then
recipe = technic.get_alloy_recipe(src_item1,src_item2)
end
if recipe then
result = { name=recipe.dst_name, count=recipe.dst_count}
end
if state == 1 then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if not inv:is_empty("src") then
if empty == 0 and recipe and inv:room_for_item("dst", result) then
meta:set_string("infotext", machine_name.." Active")
meta:set_int("src_time", 0)
next_state = 2+EU_saving_upgrade -- Next state is decided by the battery upgrade (state 2= 0 batteries, state 3 = 1 battery, 4 = 2 batteries)
end
end
elseif state == 2 or state == 3 or state == 4 then
hacky_swap_node(pos, machine_node.."_active")
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") == 4 then -- 4 ticks per output
meta:set_string("src_time", 0)
-- check if there's room for output in "dst" list and that we have the materials
if recipe and inv:room_for_item("dst", result) then
-- Take stuff from "src" list
srcstack:take_item(recipe.src1_count)
inv:set_stack("src", 1, srcstack)
src2stack:take_item(recipe.src2_count)
inv:set_stack("src2", 1, src2stack)
-- Put result in "dst" list
inv:add_item("dst",result)
else
next_state = 1
end
end
end
end
-- Change state?
if next_state ~= state then
meta:set_int("MV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
------------------------------------
-- local pos1={}
-- pos1.x=pos.x
-- pos1.y=pos.y
-- pos1.z=pos.z
-- local x_velocity=0
-- local z_velocity=0
--
-- -- output is on the left side of the furnace
-- if node.param2==3 then pos1.z=pos1.z-1 z_velocity =-1 end
-- if node.param2==2 then pos1.x=pos1.x-1 x_velocity =-1 end
-- if node.param2==1 then pos1.z=pos1.z+1 z_velocity = 1 end
-- if node.param2==0 then pos1.x=pos1.x+1 x_velocity = 1 end
--
-- local output_tube_connected = false
-- local meta=minetest.env:get_meta(pos1)
-- if meta:get_int("tubelike")==1 then output_tube_connected=true end
-- meta = minetest.env:get_meta(pos)
-- local inv = meta:get_inventory()
-- local upg_item1
-- local upg_item1_name=""
-- local upg_item2
-- local upg_item2_name=""
-- local srcstack = inv:get_stack("upgrade1", 1)
-- if srcstack then upg_item1=srcstack:to_table() end
-- srcstack = inv:get_stack("upgrade2", 1)
-- if srcstack then upg_item2=srcstack:to_table() end
-- if upg_item1 then upg_item1_name=upg_item1.name end
-- if upg_item2 then upg_item2_name=upg_item2.name end
--
-- local speed=0
-- if upg_item1_name=="technic:control_logic_unit" then speed=speed+1 end
-- if upg_item2_name=="technic:control_logic_unit" then speed=speed+1 end
-- tube_time=meta:get_float("tube_time")
-- tube_time=tube_time+speed
-- if tube_time>3 then
-- tube_time=0
-- if output_tube_connected then send_cooked_items(pos,x_velocity,z_velocity) end
-- end
-- meta:set_float("tube_time", tube_time)
--
-- local extra_buffer_size = 0
-- if upg_item1_name=="technic:battery" then extra_buffer_size =extra_buffer_size + 10000 end
-- if upg_item2_name=="technic:battery" then extra_buffer_size =extra_buffer_size + 10000 end
-- local internal_EU_buffer_size=2000+extra_buffer_size
-- meta:set_float("internal_EU_buffer_size",internal_EU_buffer_size)
--
-- internal_EU_buffer=meta:get_float("internal_EU_buffer")
-- if internal_EU_buffer > internal_EU_buffer_size then internal_EU_buffer = internal_EU_buffer_size end
-- local meta = minetest.env:get_meta(pos)
-- local load = math.floor(internal_EU_buffer/internal_EU_buffer_size * 100)
-- meta:set_string("formspec",
-- MV_alloy_furnace_formspec..
-- "image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
-- (load)..":technic_power_meter_fg.png]")
--
-- local inv = meta:get_inventory()
--
-- local furnace_is_cookin = meta:get_int("furnace_is_cookin")
--
-- local srclist = inv:get_list("src")
-- local srclist2 = inv:get_list("src2")
--
-- srcstack = inv:get_stack("src", 1)
-- if srcstack then src_item1=srcstack:to_table() end
-- srcstack = inv:get_stack("src", 2)
-- if srcstack then src_item2=srcstack:to_table() end
-- dst_index=nil
--
-- if src_item1 and src_item2 then
-- dst_index=get_cook_result(src_item1,src_item2)
-- end
--
--
-- if (furnace_is_cookin == 1) then
-- if internal_EU_buffer>=150 then
-- internal_EU_buffer=internal_EU_buffer-150;
-- meta:set_float("internal_EU_buffer",internal_EU_buffer)
-- meta:set_float("src_time", meta:get_float("src_time") + 1)
-- if dst_index and meta:get_float("src_time") >= 4 then
-- -- check if there's room for output in "dst" list
-- dst_stack={}
-- dst_stack["name"]=alloy_recipes[dst_index].dst_name
-- dst_stack["count"]=alloy_recipes[dst_index].dst_count
-- if inv:room_for_item("dst",dst_stack) then
-- -- Put result in "dst" list
-- inv:add_item("dst",dst_stack)
-- -- take stuff from "src" list
-- for i=1,alloy_recipes[dst_index].src1_count,1 do
-- srcstack = inv:get_stack("src", 1)
-- srcstack:take_item()
-- inv:set_stack("src", 1, srcstack)
-- end
-- for i=1,alloy_recipes[dst_index].src2_count,1 do
-- srcstack = inv:get_stack("src", 2)
-- srcstack:take_item()
-- inv:set_stack("src", 2, srcstack)
-- end
--
-- else
-- print("Furnace inventory full!")
-- end
-- meta:set_string("src_time", 0)
-- end
-- end
-- end
--
-- if dst_index and meta:get_int("furnace_is_cookin")==0 then
-- hacky_swap_node(pos,"technic:mv_alloy_furnace_active")
-- meta:set_string("infotext","MV Alloy Furnace active")
-- meta:set_int("furnace_is_cookin",1)
-- meta:set_string("src_time", 0)
-- return
-- end
--
-- if meta:get_int("furnace_is_cookin")==0 or dst_index==nil then
-- hacky_swap_node(pos,"technic:mv_alloy_furnace")
-- meta:set_string("infotext","MV Alloy Furnace inactive")
-- meta:set_int("furnace_is_cookin",0)
-- meta:set_string("src_time", 0)
-- end
--
end,
})
technic.register_MV_machine ("technic:mv_alloy_furnace","RE")
technic.register_MV_machine ("technic:mv_alloy_furnace_active","RE")

View File

@ -1,20 +1,152 @@
-- MV Battery box
minetest.register_craft(
{output = 'technic:mv_battery_box 1',
recipe = {
{'technic:battery_box', 'technic:battery_box', 'technic:battery_box'},
{'technic:battery_box', 'technic:mv_transformer', 'technic:battery_box'},
{'', 'technic:mv_cable', ''},
}
})
minetest.register_craft({
output = 'technic:mv_battery_box0',
recipe = {
{'technic:lv_battery_box0', 'technic:lv_battery_box0', 'technic:lv_battery_box0'},
{'technic:lv_battery_box0', 'technic:mv_transformer', 'technic:lv_battery_box0'},
{'', 'technic:mv_cable0', ''},
}
})
local battery_box_formspec =
"invsize[8,9;]"..
"image[1,1;1,2;technic_power_meter_bg.png]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;1,1;]"..
"label[0,0;MV Battery Box]"..
"label[3,0;Charge]"..
"label[5,0;Discharge]"..
"label[1,3;Power level]"..
"list[current_player;main;0,5;8,4;]"..
"background[-0.19,-0.25;8.4,9.75;ui_form_bg.png]"..
"background[0,0;8,4;ui_mv_battery_box.png]"..
"background[0,5;8,4;ui_main_inventory.png]"
technic.register_battery_box({
tier = "MV",
max_charge = 300000,
charge_rate = 20000,
discharge_rate = 80000,
charge_step = 2000,
discharge_step = 8000,
})
minetest.register_node(
"technic:mv_battery_box", {
description = "MV Battery Box",
tiles = {"technic_mv_battery_box_top.png", "technic_mv_battery_box_bottom.png", "technic_mv_battery_box_side0.png",
"technic_mv_battery_box_side0.png", "technic_mv_battery_box_side0.png", "technic_mv_battery_box_side0.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
drop = "technic:mv_battery_box",
on_construct = function(pos)
if pos==nil then return end
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
meta:set_string("infotext", "MV Battery box")
meta:set_float("technic_mv_power_machine", 1)
meta:set_string("formspec", battery_box_formspec)
meta:set_int("MV_EU_demand", 0) -- How much can this node charge
meta:set_int("MV_EU_supply", 0) -- How much can this node discharge
meta:set_int("MV_EU_input", 0) -- How much power is this machine getting.
meta:set_float("internal_EU_charge", 0)
inv:set_size("src", 1)
inv:set_size("dst", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
for i=1,8,1 do
minetest.register_node(
"technic:mv_battery_box"..i,
{
description = "MV Battery Box",
tiles = {"technic_mv_battery_box_top.png", "technic_mv_battery_box_bottom.png", "technic_mv_battery_box_side0.png^technic_power_meter"..i..".png",
"technic_mv_battery_box_side0.png^technic_power_meter"..i..".png", "technic_mv_battery_box_side0.png^technic_power_meter"..i..".png", "technic_mv_battery_box_side0.png^technic_power_meter"..i..".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_battery_box",
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
end
minetest.register_abm(
{
nodenames = {"technic:mv_battery_box","technic:mv_battery_box1","technic:mv_battery_box2","technic:mv_battery_box3","technic:mv_battery_box4",
"technic:mv_battery_box5","technic:mv_battery_box6","technic:mv_battery_box7","technic:mv_battery_box8"
},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local max_charge = 300000 -- Set maximum charge for the device here
local max_charge_rate = 2000 -- Set maximum rate of charging (4000)
local max_discharge_rate = 3000 -- Set maximum rate of discharging
local eu_input = meta:get_int("MV_EU_input")
local current_charge = meta:get_int("internal_EU_charge") -- Battery charge right now
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "MV")
-- Charge/discharge the battery with the input EUs
if eu_input >=0 then
current_charge = math.min(current_charge+eu_input, max_charge)
else
current_charge = math.max(current_charge+eu_input, 0)
end
-- Charging/discharging tools here
current_charge = charge_tools(meta, current_charge, 4000)
current_charge = discharge_tools(meta, current_charge, max_charge, 4000)
-- Set a demand (we allow batteries to charge on less than the demand though)
meta:set_int("MV_EU_demand", math.min(max_charge_rate, max_charge-current_charge))
-- Set how much we can supply
meta:set_int("MV_EU_supply", math.min(max_discharge_rate, current_charge))
meta:set_int("internal_EU_charge", current_charge)
--dprint("BA: input:"..eu_input.." supply="..meta:get_int("MV_EU_supply").." demand="..meta:get_int("MV_EU_demand").." current:"..current_charge)
-- Select node textures
local i=math.ceil((current_charge/max_charge)*8)
if i > 8 then i = 8 end
local j = meta:get_float("last_side_shown")
if i~=j then
if i>0 then hacky_swap_node(pos,"technic:mv_battery_box"..i)
elseif i==0 then hacky_swap_node(pos,"technic:mv_battery_box") end
meta:set_float("last_side_shown",i)
end
local load = math.floor(current_charge/max_charge * 100)
meta:set_string("formspec",
battery_box_formspec..
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:"..
(load)..":technic_power_meter_fg.png]"
)
if eu_input == 0 then
meta:set_string("infotext", "MV Battery box: "..current_charge.."/"..max_charge.." (idle)")
else
meta:set_string("infotext", "MV Battery box: "..current_charge.."/"..max_charge)
end
end
})
-- Register as a battery type
-- Battery type machines function as power reservoirs and can both receive and give back power
technic.register_MV_machine("technic:mv_battery_box","BA")
for i=1,8,1 do
technic.register_MV_machine("technic:mv_battery_box"..i,"BA")
end

View File

@ -5,14 +5,301 @@
-- Also in addition this furnace can be attached to the pipe system from the pipeworks mod.
-- FIXME: kpoppel I'd like to introduce an induction heating element here also
minetest.register_craft({
output = 'technic:mv_electric_furnace',
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_electric_furnace', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
{'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
}
})
minetest.register_craft(
{output = 'technic:mv_electric_furnace',
recipe = {
{'technic:stainless_steel_ingot', 'technic:electric_furnace', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
}
})
technic.register_electric_furnace({tier="MV", upgrade=1, tube=1, demand={2000, 1000, 500}, speed=4})
local mv_electric_furnace_formspec =
"invsize[8,10;]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,6;8,4;]"..
"label[0,0;MV Electric Furnace]"..
"list[current_name;upgrade1;1,4;1,1;]"..
"list[current_name;upgrade2;2,4;1,1;]"..
"label[1,5;Upgrade Slots]"
minetest.register_node(
"technic:mv_electric_furnace",
{description = "MV Electric furnace",
tiles = {"technic_mv_electric_furnace_top.png", "technic_mv_electric_furnace_bottom.png", "technic_mv_electric_furnace_side_tube.png",
"technic_mv_electric_furnace_side_tube.png", "technic_mv_electric_furnace_side.png", "technic_mv_electric_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("src",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("src",stack)
end,
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "MV Electric furnace")
meta:set_float("technic_mv_power_machine", 1)
meta:set_int("tube_time", 0)
meta:set_string("formspec", mv_electric_furnace_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
inv:set_size("upgrade1", 1)
inv:set_size("upgrade2", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node(
"technic:mv_electric_furnace_active",
{description = "MV Electric Furnace",
tiles = {"technic_mv_electric_furnace_top.png", "technic_mv_electric_furnace_bottom.png", "technic_mv_electric_furnace_side_tube.png",
"technic_mv_electric_furnace_side_tube.png", "technic_mv_electric_furnace_side.png", "technic_mv_electric_furnace_front_active.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "technic:mv_electric_furnace",
groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("src",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("src",stack)
end,
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
-- These three makes sure upgrades are not moved in or out while the furnace is active.
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "src" or listname == "dst" then
return 99
else
return 0 -- Disallow the move
end
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if listname == "src" or listname == "dst" then
return 99
else
return 0 -- Disallow the move
end
end,
allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player)
return 0
end,
})
local send_cooked_items = function(pos,x_velocity,z_velocity)
-- Send items on their way in the pipe system.
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local i=0
for _,stack in ipairs(inv:get_list("dst")) do
i=i+1
if stack then
local item0=stack:to_table()
if item0 then
item0["count"]="1"
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
item1:setacceleration({x=0, y=0, z=0})
stack:take_item(1);
inv:set_stack("dst", i, stack)
return
end
end
end
end
local smelt_item = function(pos)
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
meta:set_int("src_time", meta:get_int("src_time") + 3) -- Cooking time 3x faster
local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
if result and result.item and meta:get_int("src_time") >= result.time then
meta:set_int("src_time", 0)
-- check if there's room for output in "dst" list
if inv:room_for_item("dst",result) then
-- take stuff from "src" list
srcstack = inv:get_stack("src", 1)
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
-- Put result in "dst" list
inv:add_item("dst", result.item)
return 1
else
return 0 -- done
end
end
return 0 -- done
end
minetest.register_abm(
{nodenames = {"technic:mv_electric_furnace","technic:mv_electric_furnace_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("MV_EU_input")
local state = meta:get_int("state")
local next_state = state
-- Machine information
local machine_name = "MV Electric Furnace"
local machine_node = "technic:mv_electric_furnace"
local machine_state_demand = { 50, 2000, 1500, 1000 }
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("MV_EU_demand", machine_state_demand[1])
meta:set_int("MV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "MV")
-- Execute always logic
-- CODE HERE --
-- State machine
if eu_input == 0 then
-- Unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
-- Execute always if powered logic
local meta=minetest.env:get_meta(pos)
-- Get the names of the upgrades
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local upg_item1
local upg_item1_name=""
local upg_item2
local upg_item2_name=""
local srcstack = inv:get_stack("upgrade1", 1)
if srcstack then upg_item1=srcstack:to_table() end
srcstack = inv:get_stack("upgrade2", 1)
if srcstack then upg_item2=srcstack:to_table() end
if upg_item1 then upg_item1_name=upg_item1.name end
if upg_item2 then upg_item2_name=upg_item2.name end
-- Save some power by installing battery upgrades. Fully upgraded makes this
-- furnace use the same amount of power as the LV version
local EU_saving_upgrade = 0
if upg_item1_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
if upg_item2_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
-- Tube loading speed can be upgraded using control logic units
local tube_speed_upgrade = 0
if upg_item1_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
if upg_item2_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
-- Handle pipeworks (consumes tube_speed_upgrade)
local pos1={x=pos.x, y=pos.y, z=pos.z}
local x_velocity=0
local z_velocity=0
-- Output is on the left side of the furnace
if node.param2==3 then pos1.z=pos1.z-1 z_velocity =-1 end
if node.param2==2 then pos1.x=pos1.x-1 x_velocity =-1 end
if node.param2==1 then pos1.z=pos1.z+1 z_velocity = 1 end
if node.param2==0 then pos1.x=pos1.x+1 x_velocity = 1 end
local output_tube_connected = false
local meta1 = minetest.env:get_meta(pos1)
if meta1:get_int("tubelike") == 1 then
output_tube_connected=true
end
tube_time = meta:get_int("tube_time")
tube_time = tube_time + tube_speed_upgrade
if tube_time > 3 then
tube_time = 0
if output_tube_connected then
send_cooked_items(pos,x_velocity,z_velocity)
end
end
meta:set_int("tube_time", tube_time)
-- The machine shuts down if we have nothing to smelt since we tube stuff
-- out while being idle.
if inv:is_empty("src") then
next_state = 1
end
----------------------
if state == 1 then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if not inv:is_empty("src") then
local result = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("src")})
if result then
meta:set_string("infotext", machine_name.." Active")
meta:set_int("src_time", 0)
next_state = 2+EU_saving_upgrade -- Next state is decided by the battery upgrade (state 2= 0 batteries, state 3 = 1 battery, 4 = 2 batteries)
end
else
meta:set_string("infotext", "Electric Furnace Idle")
end
elseif state == 2 or state == 3 or state == 4 then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
result = smelt_item(pos, data)
if result == 0 then
next_state = 1
end
end
end
-- Change state?
if next_state ~= state then
meta:set_int("MV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
end,
})
technic.register_MV_machine ("technic:mv_electric_furnace","RE")
technic.register_MV_machine ("technic:mv_electric_furnace_active","RE")

View File

@ -3,11 +3,291 @@
minetest.register_craft({
output = 'technic:mv_grinder',
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_grinder', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
{'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
{'technic:stainless_steel_ingot', 'technic:grinder', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_000000', 'technic:mv_transformer', 'pipeworks:tube_000000'},
{'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
}
})
minetest.register_craftitem("technic:mv_grinder", {
description = "MV Grinder",
stack_max = 99,
})
technic.register_grinder({tier="MV", demand={600, 450, 300}, speed=2, upgrade=1, tube=1})
local mv_grinder_formspec =
"invsize[8,10;]"..
"list[current_name;src;3,1;1,1;]"..
"list[current_name;dst;5,1;2,2;]"..
"list[current_player;main;0,6;8,4;]"..
"label[0,0;MV Grinder]"..
"list[current_name;upgrade1;1,4;1,1;]"..
"list[current_name;upgrade2;2,4;1,1;]"..
"label[1,5;Upgrade Slots]"
minetest.register_node(
"technic:mv_grinder",
{
description = "MV Grinder",
tiles = {"technic_mv_grinder_top.png", "technic_mv_grinder_bottom.png", "technic_mv_grinder_side.png",
"technic_mv_grinder_side.png", "technic_mv_grinder_side.png", "technic_mv_grinder_front.png"},
paramtype2 = "facedir",
groups = {cracky=2, tubedevice=1,tubedevice_receiver=1,},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("src",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("src",stack)
end,
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "MV Grinder")
meta:set_float("technic_mv_power_machine", 1)
meta:set_int("tube_time", 0)
meta:set_string("formspec", mv_grinder_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 1)
inv:set_size("dst", 4)
inv:set_size("upgrade1", 1)
inv:set_size("upgrade2", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
})
minetest.register_node(
"technic:mv_grinder_active",
{
description = "Grinder",
tiles = {"technic_mv_grinder_top.png", "technic_mv_grinder_bottom.png", "technic_mv_grinder_side.png",
"technic_mv_grinder_side.png", "technic_mv_grinder_side.png", "technic_mv_grinder_front_active.png"},
paramtype2 = "facedir",
groups = {cracky=2,tubedevice=1,tubedevice_receiver=1,not_in_creative_inventory=1},
tube={ insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("src",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("src",stack)
end,
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") or not inv:is_empty("upgrade1") or not inv:is_empty("upgrade2") then
minetest.chat_send_player(player:get_player_name(), "Machine cannot be removed because it is not empty");
return false
else
return true
end
end,
-- These three makes sure upgrades are not moved in or out while the grinder is active.
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if listname == "src" or listname == "dst" then
return 99
else
return 0 -- Disallow the move
end
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if listname == "src" or listname == "dst" then
return 99
else
return 0 -- Disallow the move
end
end,
allow_metadata_inventory_move = function(pos, from_list, to_list, to_list, to_index, count, player)
return 0
end,
})
local send_grinded_items = function(pos,x_velocity,z_velocity)
-- Send items on their way in the pipe system.
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local i=0
for _,stack in ipairs(inv:get_list("dst")) do
i=i+1
if stack then
local item0=stack:to_table()
if item0 then
item0["count"]="1"
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
item1:setacceleration({x=0, y=0, z=0})
stack:take_item(1);
inv:set_stack("dst", i, stack)
return
end
end
end
end
minetest.register_abm(
{ nodenames = {"technic:mv_grinder","technic:mv_grinder_active"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
-- Run a machine through its states. Takes the same arguments as the ABM action
-- and adds the machine's states and any extra data which is needed by the machine.
-- A machine is characterized by running through a set number of states (usually 2:
-- Idle and active) in some order. A state decides when to move to the next one
-- and the machine only changes state if it is powered correctly.
-- The machine will automatically shut down if disconnected from power in some fashion.
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("MV_EU_input")
local state = meta:get_int("state")
local next_state = state
-- Machine information
local machine_name = "MV Grinder"
local machine_node = "technic:mv_grinder"
local machine_state_demand = { 50, 600, 450, 300 }
-- Setup meta data if it does not exist. state is used as an indicator of this
if state == 0 then
meta:set_int("state", 1)
meta:set_int("MV_EU_demand", machine_state_demand[1])
meta:set_int("MV_EU_input", 0)
return
end
-- Power off automatically if no longer connected to a switching station
technic.switching_station_timeout_count(pos, "MV")
-- State machine
if eu_input == 0 then
-- unpowered - go idle
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Unpowered")
next_state = 1
elseif eu_input == machine_state_demand[state] then
-- Powered - do the state specific actions
local inv = meta:get_inventory()
local empty = inv:is_empty("src")
-- get the names of the upgrades
local upg_item1
local upg_item1_name=""
local upg_item2
local upg_item2_name=""
local srcstack = inv:get_stack("upgrade1", 1)
if srcstack then upg_item1=srcstack:to_table() end
srcstack = inv:get_stack("upgrade2", 1)
if srcstack then upg_item2=srcstack:to_table() end
if upg_item1 then upg_item1_name=upg_item1.name end
if upg_item2 then upg_item2_name=upg_item2.name end
-- Save some power by installing battery upgrades. Fully upgraded makes this
-- furnace use the same amount of power as the LV version
local EU_saving_upgrade = 0
if upg_item1_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
if upg_item2_name=="technic:battery" then EU_saving_upgrade = EU_saving_upgrade + 1 end
-- Tube loading speed can be upgraded using control logic units
local tube_speed_upgrade = 0
if upg_item1_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
if upg_item2_name=="technic:control_logic_unit" then tube_speed_upgrade = tube_speed_upgrade + 1 end
-- Handle pipeworks (consumes tube_speed_upgrade)
local pos1={x=pos.x, y=pos.y, z=pos.z}
local x_velocity=0
local z_velocity=0
-- Output is on the left side of the furnace
if node.param2==3 then pos1.z=pos1.z-1 z_velocity =-1 end
if node.param2==2 then pos1.x=pos1.x-1 x_velocity =-1 end
if node.param2==1 then pos1.z=pos1.z+1 z_velocity = 1 end
if node.param2==0 then pos1.x=pos1.x+1 x_velocity = 1 end
local output_tube_connected = false
local meta1 = minetest.env:get_meta(pos1)
if meta1:get_int("tubelike") == 1 then
output_tube_connected=true
end
tube_time = meta:get_int("tube_time")
tube_time = tube_time + tube_speed_upgrade
if tube_time > 3 then
tube_time = 0
if output_tube_connected then
send_grinded_items(pos,x_velocity,z_velocity)
end
end
meta:set_int("tube_time", tube_time)
-- The machine shuts down if we have nothing to smelt since we tube stuff
-- out while being idle.
if inv:is_empty("src") then
next_state = 1
end
if state == 1 then
hacky_swap_node(pos, machine_node)
meta:set_string("infotext", machine_name.." Idle")
local result = technic.get_grinder_recipe(inv:get_stack("src", 1))
if not empty and result and inv:room_for_item("dst",result) then
meta:set_int("src_time", 0)
next_state = 2+EU_saving_upgrade
end
elseif state == 2 or state == 3 or state == 4 then
hacky_swap_node(pos, machine_node.."_active")
meta:set_string("infotext", machine_name.." Active")
if empty then
next_state = 1
else
meta:set_int("src_time", meta:get_int("src_time") + 1)
if meta:get_int("src_time") == 4 then -- 4 ticks per output
-- check if there's room for output in "dst" list
local result = technic.get_grinder_recipe(inv:get_stack("src", 1))
meta:set_int("src_time", 0)
if inv:room_for_item("dst",result) then
-- take stuff from "src" list
srcstack = inv:get_stack("src", 1)
srcstack:take_item()
inv:set_stack("src", 1, srcstack)
-- Put result in "dst" list
inv:add_item("dst", result)
else
-- all full: go idle
next_state = 1
end
end
end
end
end
-- Change state?
if next_state ~= state then
meta:set_int("MV_EU_demand", machine_state_demand[next_state])
meta:set_int("state", next_state)
end
end
})
technic.register_MV_machine ("technic:mv_grinder","RE")
technic.register_MV_machine ("technic:mv_grinder_active","RE")

View File

@ -1,16 +1,11 @@
local path = technic.modpath.."/machines/mv"
technic.register_tier("MV", "Medium Voltage")
local path = technic.modpath.."/machines/MV"
dofile(path.."/alloy_furnace.lua")
dofile(path.."/wires.lua")
dofile(path.."/battery_box.lua")
dofile(path.."/cables.lua")
dofile(path.."/electric_furnace.lua")
dofile(path.."/grinder.lua")
dofile(path.."/solar_array.lua")
dofile(path.."/tool_workshop.lua")
dofile(path.."/wind_mill.lua")
dofile(path.."/electric_furnace.lua")
dofile(path.."/alloy_furnace.lua")
dofile(path.."/grinder.lua")
-- The power radiator supplies appliances with inductive coupled power:
-- Lighting and associated textures is taken directly from VanessaE's homedecor and made electric.

View File

@ -6,20 +6,20 @@
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function (s) return s end
S = function ( s ) return s end
end
function technic_homedecor_node_is_owned(pos, placer)
local ownername = false
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
if HasOwner(pos, placer) then
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
if HasOwner(pos, placer) then -- returns true if the node is owned
if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
if type(getLastOwner) == "function" then -- ...is an old version
if type(getLastOwner) == "function" then -- ...is an old version
ownername = getLastOwner(pos)
elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
ownername = GetNodeOwnerName(pos)
else
ownername = S("someone")
@ -27,38 +27,38 @@ function technic_homedecor_node_is_owned(pos, placer)
end
end
elseif type(isprotect) == "function" then -- glomie's protection mod
elseif type(isprotect)=="function" then -- glomie's protection mod
if not isprotect(5, pos, placer) then
ownername = S("someone")
end
elseif type(protector) == "table" and type(protector.can_dig) == "function" then -- Zeg9's protection mod
elseif type(protector)=="table" and type(protector.can_dig)=="function" then -- Zeg9's protection mod
if not protector.can_dig(5, pos, placer) then
ownername = S("someone")
end
end
if ownername ~= false then
minetest.chat_send_player(placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
minetest.chat_send_player( placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
return true
else
return false
end
end
local dirs1 = {20, 23, 22, 21}
local dirs2 = {9, 18, 7, 12}
local dirs1 = { 20, 23, 22, 21 }
local dirs2 = { 9, 18, 7, 12 }
local technic_homedecor_rotate_and_place = function(itemstack, placer, pointed_thing)
if not technic_homedecor_node_is_owned(pointed_thing.under, placer)
and not technic_homedecor_node_is_owned(pointed_thing.above, placer) then
local node = minetest.get_node(pointed_thing.under)
local node = minetest.env:get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name] or not minetest.registered_nodes[node.name].on_rightclick then
local above = pointed_thing.above
local under = pointed_thing.under
local pitch = placer:get_look_pitch()
local pname = minetest.get_node(under).name
local node = minetest.get_node(above)
local pname = minetest.env:get_node(under).name
local node = minetest.env:get_node(above)
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
local wield_name = itemstack:get_name()
@ -74,14 +74,14 @@ local technic_homedecor_rotate_and_place = function(itemstack, placer, pointed_t
iswall = false
end
if not minetest.registered_nodes[minetest.get_node(pos1).name]["buildable_to"] then return end
if not minetest.registered_nodes[minetest.env:get_node(pos1).name]["buildable_to"] then return end
if iswall then
minetest.add_node(pos1, {name = wield_name, param2 = dirs2[fdir+1] }) -- place wall variant
minetest.env:add_node(pos1, {name = wield_name, param2 = dirs2[fdir+1] }) -- place wall variant
elseif isceiling then
minetest.add_node(pos1, {name = wield_name, param2 = 20 }) -- place upside down variant
minetest.env:add_node(pos1, {name = wield_name, param2 = 20 }) -- place upside down variant
else
minetest.add_node(pos1, {name = wield_name, param2 = 0 }) -- place right side up
minetest.env:add_node(pos1, {name = wield_name, param2 = 0 }) -- place right side up
end
if not homedecor_expect_infinite_stacks then

View File

@ -4,13 +4,13 @@
-- without the overhead of the wiring needed for larger machines.
--
-- The power radiator will consume power corresponding to the
-- sum(power rating of the attached appliances)/0.06
-- sum(power rating of the attached appliances)/0.6
-- Using inductive power transfer is very inefficient so this is
-- set to the factor 0.06.
-- set to the factor 0.6.
--
-- Punching the radiator will toggle the power state of all attached appliances.
local power_radius = 12
--
local power_radius = 6
------------------------------------------------------------------
-- API for inductive powered nodes:
@ -18,12 +18,11 @@ local power_radius = 12
-- Also two nodes are needed: The inactive and the active one. The active must be called <name>_active .
------------------------------------------------------------------
-- Register a new appliance using this function
technic.inductive_nodes = {}
technic.register_inductive_machine = function(name)
table.insert(technic.inductive_nodes, name)
table.insert(technic.inductive_nodes, name.."_active")
end
table.insert(technic.inductive_nodes, name)
table.insert(technic.inductive_nodes, name.."_active")
end
-- Appliances:
-- has_supply: pos of supply node if the appliance has a power radiator near with sufficient power for the demand else ""
@ -31,124 +30,126 @@ end
-- EU_charge: Actual use. set to EU_demand if active==1
-- active: set to 1 if the device is on
technic.inductive_on_construct = function(pos, eu_demand, infotext)
local meta = minetest.get_meta(pos)
meta:set_string("infotext", infotext)
meta:set_int("technic_inductive_power_machine", 1)
meta:set_int("EU_demand", eu_demand) -- The power demand of this appliance
meta:set_int("EU_charge", 0) -- The actual power draw of this appliance
meta:set_string("has_supply", "") -- Register whether we are powered or not. For use with several radiators.
meta:set_int("active", 0) -- If the appliance can be turned on and off by using it use this.
end
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", infotext)
meta:set_int("technic_inductive_power_machine", 1)
meta:set_int("EU_demand",eu_demand) -- The power demand of this appliance
meta:set_int("EU_charge",0) -- The actual power draw of this appliance
meta:set_string("has_supply","") -- Register whether we are powered or not. For use with several radiators.
meta:set_int("active", 0) -- If the appliance can be turned on and off by using it use this.
end
technic.inductive_on_punch_off = function(pos, eu_charge, swapnode)
local meta = minetest.get_meta(pos)
if meta:get_string("has_supply") ~= "" then
hacky_swap_node(pos, swapnode)
meta:set_int("active", 1)
meta:set_int("EU_charge",eu_charge)
--print("-----------")
--print("Turn on:")
--print("EU_charge: "..meta:get_int("EU_charge"))
--print("has_supply: "..meta:get_string("has_supply"))
--print("<----------->")
end
end
local meta = minetest.env:get_meta(pos)
if meta:get_string("has_supply") ~= "" then
hacky_swap_node(pos, swapnode)
meta:set_int("active", 1)
meta:set_int("EU_charge",eu_charge)
--print("-----------")
--print("Turn on:")
--print("EUcha:"..meta:get_int("EU_charge"))
--print("has_supply:"..meta:get_string("has_supply"))
--print("<----------->")
end
end
technic.inductive_on_punch_on = function(pos, eu_charge, swapnode)
local meta = minetest.get_meta(pos)
hacky_swap_node(pos, swapnode)
meta:set_int("active", 0)
meta:set_int("EU_charge",eu_charge)
--print("-----------")
--print("Turn off:")
--print("EU_charge: "..meta:get_int("EU_charge"))
--print("has_supply: "..meta:get_string("has_supply"))
--print("<---------->")
end
local meta = minetest.env:get_meta(pos)
hacky_swap_node(pos, swapnode)
meta:set_int("active", 0)
meta:set_int("EU_charge",eu_charge)
--print("-----------")
--print("Turn off:")
--print("EUcha:"..meta:get_int("EU_charge"))
--print("has_supply:"..meta:get_string("has_supply"))
--print("<---------->")
end
local shutdown_inductive_appliances = function(pos)
-- The supply radius
local rad = power_radius
-- If the radiator is removed. turn off all appliances in region
-- If another radiator is near it will turn on the appliances again
local positions = minetest.find_nodes_in_area(
{x=pos.x-rad, y=pos.y-rad, z=pos.z-rad},
{x=pos.x+rad, y=pos.y+rad, z=pos.z+rad},
technic.inductive_nodes)
for _, pos1 in pairs(positions) do
local meta1 = minetest.get_meta(pos1)
-- If the appliance is belonging to this node
if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
local nodename = minetest.get_node(pos1).name
-- Swap the node and make sure it is off and unpowered
if string.sub(nodename, -7) == "_active" then
hacky_swap_node(pos1, string.sub(nodename, 1, -8))
meta1:set_int("active", 0)
meta1:set_int("EU_charge", 0)
end
meta1:set_string("has_supply", "")
end
end
end
-- The supply radius
local rad = power_radius
-- If the radiator is removed. turn off all appliances in region
-- If another radiator is near it will turn on the appliances again
local positions = minetest.env:find_nodes_in_area({x=pos.x-rad,y=pos.y-rad,z=pos.z-rad},{x=pos.x+rad,y=pos.y+rad,z=pos.z+rad}, technic.inductive_nodes)
for _,pos1 in pairs(positions) do
local meta1 = minetest.env:get_meta(pos1)
-- If the appliance is belonging to this node
if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
local nodename = minetest.env:get_node(pos1).name
-- Swap the node and make sure it is off and unpowered
if string.sub(nodename, -7) == "_active" then
hacky_swap_node(pos1, string.sub(nodename, 1, -8))
meta1:set_int("active", 0)
meta1:set_int("EU_charge", 0)
end
meta1:set_string("has_supply", "")
end
end
end
local toggle_on_off_inductive_appliances = function(pos, node, puncher)
if pos == nil then return end
-- The supply radius
local rad = power_radius
local positions = minetest.find_nodes_in_area(
{x=pos.x-rad, y=pos.y-rad, z=pos.z-rad},
{x=pos.x+rad, y=pos.y+rad, z=pos.z+rad},
technic.inductive_nodes)
for _, pos1 in pairs(positions) do
local meta1 = minetest.get_meta(pos1)
if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
minetest.punch_node(pos1)
end
end
end
if pos == nil then return end
-- The supply radius
local rad = power_radius
local positions = minetest.env:find_nodes_in_area({x=pos.x-rad,y=pos.y-rad,z=pos.z-rad},{x=pos.x+rad,y=pos.y+rad,z=pos.z+rad}, technic.inductive_nodes)
for _,pos1 in pairs(positions) do
local meta1 = minetest.env:get_meta(pos1)
if meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
minetest.env:punch_node(pos1)
end
end
end
minetest.register_node("technic:power_radiator", {
description = "Power Radiator",
tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("MV_EU_demand",1) -- Demand on the primary side when idle
meta:set_int("connected_EU_demand",0) -- Potential demand of connected appliances
meta:set_string("infotext", "Power Radiator")
end,
on_dig = function(pos, node, digger)
shutdown_inductive_appliances(pos)
return minetest.node_dig(pos, node, digger)
end,
on_punch = function(pos, node, puncher)
toggle_on_off_inductive_appliances(pos, node, puncher)
end
})
minetest.register_node(
"technic:power_radiator", {
description = "Power Radiator",
tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_int("technic_mv_power_machine", 1) -- MV machine
meta:set_int("MV_EU_demand",1) -- Demand on the primary side when idle
meta:set_int("connected_EU_demand",0) -- Potential demand of connected appliances
meta:set_string("infotext", "Power Radiator")
-- meta:set_int("active", 0)
end,
on_dig = function(pos, node, digger)
shutdown_inductive_appliances(pos)
return minetest.node_dig(pos, node, digger)
end,
on_punch = function(pos, node, puncher)
toggle_on_off_inductive_appliances(pos, node, puncher)
end
})
minetest.register_craft({
output = 'technic:power_radiator 1',
recipe = {
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
{'technic:copper_coil', 'technic:mv_transformer', 'technic:copper_coil'},
{'technic:rubber', 'technic:mv_cable0', 'technic:rubber'},
}
})
minetest.register_craft(
{
output = 'technic:power_radiator 1',
recipe = {
{'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot', 'technic:stainless_steel_ingot'},
{'technic:copper_coil', 'technic:mv_transformer', 'technic:copper_coil'},
{'technic:rubber', 'technic:mv_cable', 'technic:rubber'},
}
})
minetest.register_abm({
nodenames = {"technic:power_radiator"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.register_abm(
{nodenames = {"technic:power_radiator"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos)
local eu_input = meta:get_int("MV_EU_input")
local eu_demand = meta:get_int("MV_EU_demand")
@ -157,64 +158,69 @@ minetest.register_abm({
technic.switching_station_timeout_count(pos, "MV")
if eu_input == 0 then
-- No power
meta:set_string("infotext", "Power Radiator is unpowered");
-- meta:set_int("active", 1) -- used for setting textures someday maybe
shutdown_inductive_appliances(pos)
meta:set_int("connected_EU_demand", 0)
meta:set_int("MV_EU_demand",1)
-- No power
meta:set_string("infotext", "Power Radiator is unpowered");
-- meta:set_int("active",1) -- used for setting textures someday maybe
shutdown_inductive_appliances(pos)
meta:set_int("connected_EU_demand", 0)
meta:set_int("MV_EU_demand",1)
elseif eu_input == eu_demand then
-- Powered and ready
-- Powered and ready
-- The maximum EU sourcing a single radiator can provide.
local max_charge = 30000 -- == the max EU demand of the radiator
local connected_EU_demand = meta:get_int("connected_EU_demand")
-- The maximum EU sourcing a single radiator can provide.
local max_charge = 3000 -- == the max EU demand of the radiator
local connected_EU_demand = meta:get_int("connected_EU_demand")
-- Efficiency factor
local eff_factor = 0.06
-- The supply radius
local rad = power_radius
-- Efficiency factor
local eff_factor = 0.6
-- The supply radius
local rad = power_radius
local meta1 = nil
local pos1 = {}
local used_charge = 0
-- Index all nodes within supply range
local positions = minetest.env:find_nodes_in_area({x=pos.x-rad,y=pos.y-rad,z=pos.z-rad},{x=pos.x+rad,y=pos.y+rad,z=pos.z+rad}, technic.inductive_nodes)
for _,pos1 in pairs(positions) do
local meta1 = minetest.env:get_meta(pos1)
-- If not supplied see if this node can handle it.
if meta1:get_string("has_supply") == "" then
-- if demand surpasses the capacity of this node, don't bother adding it.
local app_eu_demand = math.floor(meta1:get_int("EU_demand")/eff_factor)
if connected_EU_demand + app_eu_demand <= max_charge then
--print("I can supply this:"..connected_EU_demand.."|"..app_eu_demand.."<="..max_charge.."|act:"..meta1:get_int("EU_charge"))
-- We can power the appliance. Register, and spend power if it is on.
connected_EU_demand = connected_EU_demand + app_eu_demand
local meta1 = nil
local pos1 = {}
local used_charge = 0
-- Index all nodes within supply range
local positions = minetest.find_nodes_in_area(
{x=pos.x-rad, y=pos.y-rad, z=pos.z-rad},
{x=pos.x+rad, y=pos.y+rad, z=pos.z+rad},
technic.inductive_nodes)
for _, pos1 in pairs(positions) do
local meta1 = minetest.get_meta(pos1)
-- If not supplied see if this node can handle it.
if meta1:get_string("has_supply") == "" then
-- if demand surpasses the capacity of this node, don't bother adding it.
local app_eu_demand = math.floor(meta1:get_int("EU_demand") / eff_factor)
if connected_EU_demand + app_eu_demand <= max_charge then
-- We can power the appliance. Register, and spend power if it is on.
connected_EU_demand = connected_EU_demand + app_eu_demand
meta1:set_string("has_supply", pos.x..pos.y..pos.z)
--Always 0: used_charge = math.floor(used_charge + meta1:get_int("EU_charge") / eff_factor)
end
elseif meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
-- The appliance has power from this node. Spend power if it is on.
used_charge = used_charge + math.floor(meta1:get_int("EU_charge") / eff_factor)
end
meta:set_string("infotext", "Power Radiator is powered ("
..math.floor(used_charge / max_charge * 100)
.."% of maximum power)");
if used_charge == 0 then
meta:set_int("MV_EU_demand", 1) -- Still idle
else
meta:set_int("MV_EU_demand", used_charge)
end
end
-- Save state
meta:set_int("connected_EU_demand", connected_EU_demand)
meta1:set_string("has_supply", pos.x..pos.y..pos.z)
--Always 0: used_charge = math.floor(used_charge+meta1:get_int("EU_charge")/eff_factor)
end
elseif meta1:get_string("has_supply") == pos.x..pos.y..pos.z then
-- The appliance has power from this node. Spend power if it is on.
used_charge = used_charge+math.floor(meta1:get_int("EU_charge")/eff_factor)
--print("My Lamp ("..pos.x..","..pos.y..","..pos.z..") Used:"..used_charge.."Max:"..max_charge)
end
meta:set_string("infotext", "Power Radiator is powered ("..math.floor(used_charge/max_charge*100).."% of maximum power)");
if used_charge == 0 then
meta:set_int("MV_EU_demand", 1) -- Still idle
else
meta:set_int("MV_EU_demand", used_charge)
end
-- meta:set_int("active",1) -- used for setting textures someday maybe
end
-- Save state
meta:set_int("connected_EU_demand",connected_EU_demand)
else
-- This is the case where input ~= demand. Overloaded or underpowered!
-- --If demand surpasses actual supply turn off everything - we are out of power
-- if used_charge>eu_input then
-- meta:set_string("infotext", "Power Radiator is overloaded ("..math.floor(used_charge/eu_input*100).."% of available power)");
---- meta:set_int("active",1) -- used for setting textures someday maybe
-- shutdown_inductive_appliances(pos)
-- connected_EU_demand = 0
end
end,
})
technic.register_machine("MV", "technic:power_radiator", technic.receiver)
end,
})
technic.register_MV_machine ("technic:power_radiator","RE")

View File

@ -1,12 +1,82 @@
minetest.register_craft({
output = 'technic:solar_array_mv 1',
recipe = {
{'technic:solar_array_lv', 'technic:solar_array_lv', 'technic:solar_array_lv'},
{'default:steel_ingot', 'technic:mv_transformer', 'default:steel_ingot'},
{'', 'technic:mv_cable0', ''},
}
-- The medium voltage solar array is an assembly of low voltage arrays.
-- The assembly can deliver medium voltage levels and is a 10% less efficient
-- compared to 5 individual low voltage arrays due to losses in the transformer.
-- However medium voltage is supplied.
-- Solar arrays are not able to store large amounts of energy.
-- The MV arrays are used to make high voltage arrays.
minetest.register_node("technic:solar_array_mv", {
tiles = {"technic_mv_solar_array_top.png", "technic_mv_solar_array_bottom.png", "technic_mv_solar_array_side.png",
"technic_mv_solar_array_side.png", "technic_mv_solar_array_side.png", "technic_mv_solar_array_side.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
description="MV Solar Array",
active = false,
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_float("technic_mv_power_machine", 1)
meta:set_int("MV_EU_supply", 0)
meta:set_string("infotext", "MV Solar Array")
end,
})
technic.register_solar_array({tier="MV", power=30})
minetest.register_craft(
{
output = 'technic:solar_array_mv 1',
recipe = {
{'technic:solar_array_lv', 'technic:solar_array_lv','technic:solar_array_lv'},
{'technic:solar_array_lv', 'technic:mv_transformer','technic:solar_array_lv'},
{'default:steel_ingot', 'technic:mv_cable', 'default:steel_ingot'},
}
})
minetest.register_abm(
{nodenames = {"technic:solar_array_mv"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
-- The action here is to make the solar array produce power
-- Power is dependent on the light level and the height above ground
-- 130m and above is optimal as it would be above cloud level.
-- Height gives 1/4 of the effect, light 3/4. Max. effect is 720EU for the array.
-- There are many ways to cheat by using other light sources like lamps.
-- As there is no way to determine if light is sunlight that is just a shame.
-- To take care of some of it solar panels do not work outside daylight hours or if
-- built below -10m
local pos1={}
pos1.y=pos.y+1
pos1.x=pos.x
pos1.z=pos.z
local light = minetest.env:get_node_light(pos1, nil)
local time_of_day = minetest.env:get_timeofday()
local meta = minetest.env:get_meta(pos)
if light == nil then light = 0 end
-- turn on array only during day time and if sufficient light
-- I know this is counter intuitive when cheating by using other light sources.
if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then
local charge_to_give = math.floor(light*(light*2.4+pos1.y/130*12))
if charge_to_give<0 then charge_to_give=0 end
if charge_to_give>1000 then charge_to_give=1000 end
meta:set_string("infotext", "Solar Array is active ("..charge_to_give.."EU)")
-- meta:set_float("active",1)
meta:set_int("MV_EU_supply", charge_to_give)
else
meta:set_string("infotext", "Solar Array is inactive");
meta:set_int("MV_EU_supply", 0)
end
end,
})
technic.register_MV_machine ("technic:solar_array_mv","PR")

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

View File

@ -20,7 +20,7 @@ minetest.register_craft({
})
mk1_on = function(pos, node)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local pos1={}
pos1.x=pos.x
@ -34,7 +34,7 @@ mk1_on = function(pos, node)
if node.name == "technic:constructor_mk1_off" then
hacky_swap_node(pos,"technic:constructor_mk1_on")
nodeupdate(pos)
local node1=minetest.get_node(pos1)
local node1=minetest.env:get_node(pos1)
deploy_node (inv,"slot1",pos1,node1,node)
end
end
@ -57,7 +57,7 @@ minetest.register_node("technic:constructor_mk1_off", {
mesecons= {effector={action_on=mk1_on}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Constructor MK1]"..
@ -70,7 +70,7 @@ minetest.register_node("technic:constructor_mk1_off", {
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("slot1")
end,
@ -91,7 +91,7 @@ minetest.register_node("technic:constructor_mk1_on", {
--Constructor MK2
mk2_on = function(pos, node)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local pos1={}
local pos2={}
@ -109,9 +109,9 @@ mk2_on = function(pos, node)
if node.name == "technic:constructor_mk2_off" then
hacky_swap_node(pos,"technic:constructor_mk2_on")
nodeupdate(pos)
local node1=minetest.get_node(pos1)
local node1=minetest.env:get_node(pos1)
deploy_node (inv,"slot1",pos1,node1,node)
local node1=minetest.get_node(pos2)
local node1=minetest.env:get_node(pos2)
deploy_node (inv,"slot2",pos2,node1,node)
end
end
@ -133,7 +133,7 @@ minetest.register_node("technic:constructor_mk2_off", {
mesecons= {effector={action_on=mk2_on}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Constructor MK2]"..
@ -149,7 +149,7 @@ minetest.register_node("technic:constructor_mk2_off", {
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false then return false end
return true
@ -170,7 +170,7 @@ minetest.register_node("technic:constructor_mk2_on", {
-- Constructor MK3
mk3_on = function(pos, node)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local pos1={}
@ -202,13 +202,13 @@ mk3_on = function(pos, node)
if node.name == "technic:constructor_mk3_off" then
hacky_swap_node(pos,"technic:constructor_mk3_on")
nodeupdate(pos)
local node1=minetest.get_node(pos1)
local node1=minetest.env:get_node(pos1)
deploy_node (inv,"slot1",pos1,node1,node)
local node1=minetest.get_node(pos2)
local node1=minetest.env:get_node(pos2)
deploy_node (inv,"slot2",pos2,node1,node)
local node1=minetest.get_node(pos3)
local node1=minetest.env:get_node(pos3)
deploy_node (inv,"slot3",pos3,node1,node)
local node1=minetest.get_node(pos4)
local node1=minetest.env:get_node(pos4)
deploy_node (inv,"slot4",pos4,node1,node)
end
end
@ -230,7 +230,7 @@ minetest.register_node("technic:constructor_mk3_off", {
mesecons= {effector={action_on=mk3_on}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Constructor MK2]"..
@ -253,7 +253,7 @@ minetest.register_node("technic:constructor_mk3_off", {
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false or inv:is_empty("slot3")==false or inv:is_empty("slot4")==false then return false end
return true
@ -279,7 +279,7 @@ deploy_node =function (inv, slot_name, pos1, node1, node)
local def = stack1[1]:get_definition()
if def.type == "node" then
node_to_be_placed={name=stack1[1]:get_name(), param1=0, param2=node.param2}
minetest.set_node(pos1,node_to_be_placed)
minetest.env:set_node(pos1,node_to_be_placed)
stack1[1]:take_item()
inv:set_stack(slot_name, 1, stack1[1])
elseif def.type == "craft" then
@ -334,10 +334,10 @@ deploy_node =function (inv, slot_name, pos1, node1, node)
end
loop = loop + 1
end
minetest.remove_node(pos1)
minetest.env:remove_node(pos1)
elseif type(drop) == "string" then
inv:add_item(slot_name,drop)
minetest.remove_node(pos1)
minetest.env:remove_node(pos1)
end
end

Some files were not shown because too many files have changed in this diff Show More