summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--concrete/init.lua206
-rw-r--r--origin0
-rw-r--r--technic/config.lua3
-rw-r--r--technic/crafts.lua11
-rw-r--r--technic/helpers.lua196
-rw-r--r--technic/init.lua15
-rw-r--r--technic/items.lua9
-rw-r--r--technic/legacy.lua9
-rw-r--r--technic/machines/HV/battery_box.lua2
-rw-r--r--technic/machines/HV/cables.lua4
-rw-r--r--technic/machines/HV/forcefield.lua7
-rw-r--r--technic/machines/HV/generator.lua2
-rw-r--r--technic/machines/HV/nuclear_reactor.lua714
-rw-r--r--technic/machines/HV/quarry.lua5
-rw-r--r--technic/machines/HV/solar_array.lua2
-rw-r--r--technic/machines/LV/alloy_furnace.lua6
-rw-r--r--technic/machines/LV/battery_box.lua6
-rw-r--r--technic/machines/LV/cables.lua4
-rw-r--r--technic/machines/LV/cnc.lua37
-rw-r--r--technic/machines/LV/compressor.lua6
-rw-r--r--technic/machines/LV/electric_furnace.lua2
-rw-r--r--technic/machines/LV/extractor.lua2
-rw-r--r--technic/machines/LV/generator.lua2
-rw-r--r--technic/machines/LV/geothermal.lua10
-rw-r--r--technic/machines/LV/grinder.lua2
-rw-r--r--technic/machines/LV/music_player.lua6
-rw-r--r--technic/machines/LV/solar_array.lua2
-rw-r--r--technic/machines/LV/solar_panel.lua26
-rw-r--r--technic/machines/LV/water_mill.lua24
-rw-r--r--technic/machines/MV/alloy_furnace.lua2
-rw-r--r--technic/machines/MV/battery_box.lua2
-rw-r--r--technic/machines/MV/cables.lua10
-rw-r--r--technic/machines/MV/centrifuge.lua6
-rw-r--r--technic/machines/MV/compressor.lua2
-rw-r--r--technic/machines/MV/electric_furnace.lua4
-rw-r--r--technic/machines/MV/extractor.lua2
-rw-r--r--technic/machines/MV/generator.lua2
-rw-r--r--technic/machines/MV/grinder.lua4
-rw-r--r--technic/machines/MV/power_radiator.lua19
-rw-r--r--technic/machines/MV/solar_array.lua2
-rw-r--r--technic/machines/MV/tool_workshop.lua6
-rw-r--r--technic/machines/MV/wind_mill.lua26
-rw-r--r--technic/machines/other/frames.lua2
-rw-r--r--technic/machines/register/battery_box.lua6
-rw-r--r--technic/machines/register/cables.lua203
-rw-r--r--technic/machines/register/centrifuge_recipes.lua3
-rw-r--r--technic/machines/register/common.lua4
-rw-r--r--technic/machines/register/generator.lua10
-rw-r--r--technic/machines/register/grinder_recipes.lua6
-rw-r--r--technic/machines/register/machine_base.lua12
-rw-r--r--technic/machines/register/solar_array.lua5
-rw-r--r--technic/machines/supply_converter.lua19
-rw-r--r--technic/machines/switching_station.lua43
-rw-r--r--technic/radiation.lua483
-rw-r--r--technic/textures/technic_stone_dust.pngbin0 -> 417 bytes
-rw-r--r--technic/textures/technicx32/technic_stone_dust.pngbin0 -> 1284 bytes
-rw-r--r--technic/tools/chainsaw.lua16
-rw-r--r--technic/tools/mining_drill.lua10
-rw-r--r--technic/tools/mining_lasers.lua73
-rw-r--r--technic_worldgen/nodes.lua4
60 files changed, 1160 insertions, 1146 deletions
diff --git a/concrete/init.lua b/concrete/init.lua
index d1fa1aa..66564ba 100644
--- a/concrete/init.lua
+++ b/concrete/init.lua
@@ -7,11 +7,14 @@ technic.concrete_posts = {}
-- Boilerplate to support localized strings if intllib mod is installed.
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
-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")
+for i = 0, 31 do
+ minetest.register_alias("technic:concrete_post"..i,
+ "technic:concrete_post")
+end
+for i = 32, 63 do
+ minetest.register_alias("technic:concrete_post"..i,
+ "technic:concrete_post_with_platform")
+end
local steel_ingot
if minetest.get_modpath("technic_worldgen") then
@@ -41,17 +44,17 @@ 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'},
{'default:stone','technic:rebar','default:stone'},
-}
+ }
})
minetest.register_craft({
@@ -63,13 +66,6 @@ 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}
-
minetest.register_craftitem(":technic:rebar", {
description = S("Rebar"),
inventory_image = "technic_rebar.png",
@@ -80,27 +76,29 @@ minetest.register_node(":technic:concrete", {
tiles = {"technic_concrete_block.png",},
groups = {cracky=1, level=2, concrete=1},
sounds = default.node_sound_stone_defaults(),
- after_place_node = function(pos, placer, itemstack)
- technic.update_posts(pos, false)
- end,
- after_dig_node = function (pos, oldnode, oldmetadata, digger)
- technic.update_posts(pos, false)
- end,
})
minetest.register_node(":technic:blast_resistant_concrete", {
description = S("Blast-resistant Concrete Block"),
tiles = {"technic_blast_resistant_concrete_block.png",},
- groups={cracky=1, level=3, concrete=1},
+ groups = {cracky=1, level=3, concrete=1},
sounds = default.node_sound_stone_defaults(),
- after_place_node = function(pos, player, itemstack)
- technic.update_posts(pos, false)
- end,
- after_dig_node = function (pos, oldnode, oldmetadata, digger)
- technic.update_posts(pos, false)
+ on_blast = function(pos, intensity)
+ if intensity > 9 then
+ minetest.remove_node(pos)
+ return {"technic:blast_resistant_concrete"}
+ end
end,
})
+
+local box_platform = {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}
+local box_post = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
+local box_front = {-0.1, -0.3, 0, 0.1, 0.3, -0.5}
+local box_back = {-0.1, -0.3, 0, 0.1, 0.3, 0.5}
+local box_left = {0, -0.3, -0.1, -0.5, 0.3, 0.1}
+local box_right = {0, -0.3, -0.1, 0.5, 0.3, 0.1}
+
minetest.register_node(":technic:concrete_post_platform", {
description = S("Concrete Post Platform"),
tiles = {"technic_concrete_block.png",},
@@ -114,161 +112,45 @@ minetest.register_node(":technic:concrete_post_platform", {
},
on_place = function (itemstack, placer, pointed_thing)
local node = minetest.get_node(pointed_thing.under)
- if not technic.concrete_posts[node.name] then
+ if node.name ~= "technic:concrete_post" then
return minetest.item_place_node(itemstack, placer, pointed_thing)
end
- local links = technic.concrete_posts[node.name]
- if links[6] ~= 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], links[5], 1})
- minetest.set_node(pointed_thing.under, {name="technic:concrete_post"..id})
+ minetest.set_node(pointed_thing.under, {name="technic:concrete_post_with_platform"})
itemstack:take_item()
placer:set_wielded_item(itemstack)
return itemstack
end,
})
-local function gen_post_nodebox(x1, x2, z1, z2, y, platform)
- local box
- local xx = x1 + x2
- local zz = z1 + z2
- if ((xx == 2 and zz == 0) or (xx == 0 and zz == 2)) and y == 0 then
- box = {}
- else
- box = {box_center}
- end
- 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
-
-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
-
-function technic.get_post_id(links)
- return (links[1] * 1) + (links[2] * 2)
- + (links[3] * 4) + (links[4] * 8)
- + (links[5] * 16) + (links[6] * 32)
-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},
- {x=pos.x, y=pos.y-1, z=pos.z},
- {x=pos.x, y=pos.y+1, z=pos.z},
- }
-
- local links = {0, 0, 0, 0, 0, 0}
-
- 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
-
- if links[5] == 1 or links[6] == 1 then
- links[5] = 1
- links[6] = 0
- 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[6] = oldlinks[6]
- end
- minetest.set_node(pos, {name="technic:concrete_post"
- ..technic.get_post_id(links)})
- end
-end
-
-for x1 = 0, 1 do
-for x2 = 0, 1 do
-for z1 = 0, 1 do
-for z2 = 0, 1 do
-for y = 0, 1 do
for platform = 0, 1 do
- local links = {x1, x2, z1, z2, y, 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)
+ local after_dig_node = nil
+ if platform == 1 then
+ after_dig_node = function(pos, old_node)
+ old_node.name = "technic:concrete_post"
+ minetest.set_node(pos, old_node)
end
end
- minetest.register_node(":technic:concrete_post"..id, {
+ minetest.register_node(":technic:concrete_post"..(platform == 1 and "_with_platform" or ""), {
description = S("Concrete Post"),
tiles = {"technic_concrete_block.png"},
- groups = groups,
+ groups = {cracky=1, level=2, concrete_post=1, not_in_creative_inventory=platform},
sounds = default.node_sound_stone_defaults(),
- drop = drop,
+ drop = (platform == 1 and "technic:concrete_post_platform" or
+ "technic:concrete_post"),
paramtype = "light",
sunlight_propagates = true,
- drawtype = "nodebox",
+ drawtype = "nodebox",
+ connects_to = {"group:concrete", "group:concrete_post"},
node_box = {
- type = "fixed",
- fixed = gen_post_nodebox(x1, x2, z1, z2, y, platform),
+ type = "connected",
+ fixed = {box_post, (platform == 1 and box_platform or nil)},
+ connect_front = box_front,
+ connect_back = box_back,
+ connect_left = box_left,
+ connect_right = box_right,
},
- after_place_node = function(pos, placer, itemstack)
- technic.update_posts(pos, true)
- end,
after_dig_node = after_dig_node,
})
end
-end
-end
-end
-end
-end
diff --git a/origin b/origin
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/origin
diff --git a/technic/config.lua b/technic/config.lua
index 81a2224..29321f9 100644
--- a/technic/config.lua
+++ b/technic/config.lua
@@ -9,6 +9,9 @@ local defaults = {
enable_wind_mill = "false",
enable_frames = "false",
enable_corium_griefing = "true",
+ enable_radiation_protection = "true",
+ enable_entity_radiation_damage = "true",
+ enable_longterm_radiation_damage = "true",
}
for k, v in pairs(defaults) do
diff --git a/technic/crafts.lua b/technic/crafts.lua
index 8a8cd37..4859768 100644
--- a/technic/crafts.lua
+++ b/technic/crafts.lua
@@ -191,3 +191,14 @@ minetest.register_craft({
},
})
+minetest.register_craft({
+ output = "default:dirt 2",
+ type = "shapeless",
+ replacements = {{"bucket:bucket_water","bucket:bucket_empty"}},
+ recipe = {
+ "technic:stone_dust",
+ "group:leaves",
+ "bucket:bucket_water",
+ "group:sand",
+ },
+})
diff --git a/technic/helpers.lua b/technic/helpers.lua
index e8efcf3..5780f27 100644
--- a/technic/helpers.lua
+++ b/technic/helpers.lua
@@ -1,27 +1,38 @@
---load config
-local sepchar = nil
+local digit_sep_esc
do
- local sepcode = technic.config:get("thousand_separator")
- --default is SI style
- sepchar = sepcode and string.char(sepcode) or " "
- baresepchar = sepchar
- --handling if sepchar is magic...
- for magic in string.gmatch("().%+-*?[^$", ".") do
- if sepchar == magic then sepchar = "%"..sepchar end
+ local sep = technic.config:get("digit_separator")
+ sep = tonumber(sep) and string.char(sep) or sep or " "
+ -- Escape for gsub
+ for magic in ("().%+-*?[^$"):gmatch(".") do
+ if sep == magic then
+ sep = "%"..sep
+ end
end
+ digit_sep_esc = sep
+end
+
+
+function technic.pretty_num(num)
+ local str, k = tostring(num), nil
+ repeat
+ str, k = str:gsub("^(-?%d+)(%d%d%d)", "%1"..digit_sep_esc.."%2")
+ until k == 0
+ return str
end
--- Only changes name, keeps other params
+
+--- Same as minetest.swap_node, but only changes name
+-- and doesn't re-set if already set.
function technic.swap_node(pos, name)
local node = minetest.get_node(pos)
if node.name ~= name then
node.name = name
minetest.swap_node(pos, node)
end
- return node.name
end
--- Fully charge RE chargeable item.
+
+--- Fully charge RE chargeable item.
-- Must be defined early to reference in item definitions.
function technic.refill_RE_charge(stack)
local max_charge = technic.power_tools[stack:get_name()]
@@ -33,35 +44,148 @@ function technic.refill_RE_charge(stack)
return stack
end
-local function resolve_name(function_name)
- local a = _G
- for key in string.gmatch(function_name, "([^%.]+)(%.?)") do
- if a[key] then
- a = a[key]
+
+-- If the node is loaded, returns it. If it isn't loaded, load it and return nil.
+function technic.get_or_load_node(pos)
+ local node = minetest.get_node_or_nil(pos)
+ if node then return node end
+ local vm = VoxelManip()
+ local MinEdge, MaxEdge = vm:read_from_map(pos, pos)
+ return nil
+end
+
+
+technic.tube_inject_item = pipeworks.tube_inject_item or function(pos, start_pos, velocity, item)
+ local tubed = pipeworks.tube_item(vector.new(pos), item)
+ tubed:get_luaentity().start_pos = vector.new(start_pos)
+ tubed:setvelocity(velocity)
+ tubed:setacceleration(vector.new(0, 0, 0))
+end
+
+
+--- Iterates over the node positions along the specified ray.
+-- The returned positions will not include the starting position.
+function technic.trace_node_ray(pos, dir, range)
+ local x_step = dir.x > 0 and 1 or -1
+ local y_step = dir.y > 0 and 1 or -1
+ local z_step = dir.z > 0 and 1 or -1
+
+ local i = 1
+ return function(p)
+ -- Approximation of where we should be if we weren't rounding
+ -- to nodes. This moves forward a bit faster then we do.
+ -- A correction is done below.
+ local real_x = pos.x + (dir.x * i)
+ local real_y = pos.y + (dir.y * i)
+ local real_z = pos.z + (dir.z * i)
+
+ -- How far off we've gotten from where we should be.
+ local dx = math.abs(real_x - p.x)
+ local dy = math.abs(real_y - p.y)
+ local dz = math.abs(real_z - p.z)
+
+ -- If the real position moves ahead too fast, stop it so we
+ -- can catch up. If it gets too far ahead it will smooth
+ -- out our movement too much and we won't turn fast enough.
+ if dx + dy + dz < 2 then
+ i = i + 1
+ end
+
+ -- Step in whichever direction we're most off course in.
+ if dx > dy then
+ if dx > dz then
+ p.x = p.x + x_step
+ else
+ p.z = p.z + z_step
+ end
+ elseif dy > dz then
+ p.y = p.y + y_step
else
+ p.z = p.z + z_step
+ end
+ if vector.distance(pos, p) > range then
return nil
end
- end
- return a
+ return p
+ end, vector.round(pos)
end
-function technic.function_exists(function_name)
- return type(resolve_name(function_name)) == 'function'
-end
--- if the node is loaded, returns it. If it isn't loaded, load it and return nil.
-function technic.get_or_load_node(pos)
- local node_or_nil = minetest.get_node_or_nil(pos)
- if node_or_nil then return node_or_nil end
- local vm = VoxelManip()
- local MinEdge, MaxEdge = vm:read_from_map(pos, pos)
- return nil
+--- Like trace_node_ray, but includes extra positions close to the ray.
+function technic.trace_node_ray_fat(pos, dir, range)
+ local x_step = dir.x > 0 and 1 or -1
+ local y_step = dir.y > 0 and 1 or -1
+ local z_step = dir.z > 0 and 1 or -1
+
+ local next_poses = {}
+
+ local i = 1
+ return function(p)
+ local ni, np = next(next_poses)
+ if np then
+ next_poses[ni] = nil
+ return np
+ end
+
+ -- Approximation of where we should be if we weren't rounding
+ -- to nodes. This moves forward a bit faster then we do.
+ -- A correction is done below.
+ local real_x = pos.x + (dir.x * i)
+ local real_y = pos.y + (dir.y * i)
+ local real_z = pos.z + (dir.z * i)
+
+ -- How far off we've gotten from where we should be.
+ local dx = math.abs(real_x - p.x)
+ local dy = math.abs(real_y - p.y)
+ local dz = math.abs(real_z - p.z)
+
+ -- If the real position moves ahead too fast, stop it so we
+ -- can catch up. If it gets too far ahead it will smooth
+ -- out our movement too much and we won't turn fast enough.
+ if dx + dy + dz < 2 then
+ i = i + 1
+ end
+
+ -- Step in whichever direction we're most off course in.
+ local sx, sy, sz -- Whether we've already stepped along each axis
+ if dx > dy then
+ if dx > dz then
+ sx = true
+ p.x = p.x + x_step
+ else
+ sz = true
+ p.z = p.z + z_step
+ end
+ elseif dy > dz then
+ sy = true
+ p.y = p.y + y_step
+ else
+ sz = true
+ p.z = p.z + z_step
+ end
+
+ if vector.distance(pos, p) > range then
+ return nil
+ end
+
+ -- Add other positions that we're significantly off on.
+ -- We can just use fixed integer keys here because the
+ -- table will be completely cleared before we reach this
+ -- code block again.
+ local dlen = math.sqrt(dx*dx + dy*dy + dz*dz)
+ -- Normalized axis deltas
+ local dxn, dyn, dzn = dx / dlen, dy / dlen, dz / dlen
+ if not sx and dxn > 0.5 then
+ next_poses[1] = vector.new(p.x + x_step, p.y, p.z)
+ end
+ if not sy and dyn > 0.5 then
+ next_poses[2] = vector.new(p.x, p.y + y_step, p.z)
+ end
+ if not sz and dzn > 0.5 then
+ next_poses[3] = vector.new(p.x, p.y, p.z + z_step)
+ end
+
+ return p
+ end, vector.round(pos)
end
-function technic.prettynum(num)
- local str, k = tostring(num), nil
- repeat
- str, k = str:gsub("^(-?%d+)(%d%d%d)", "%1"..sepchar.."%2")
- until k == 0
- return str
-end \ No newline at end of file
diff --git a/technic/init.lua b/technic/init.lua
index 25361af..4464082 100644
--- a/technic/init.lua
+++ b/technic/init.lua
@@ -2,22 +2,18 @@
-- namespace: technic
-- (c) 2012-2013 by RealBadAngel <mk@realbadangel.pl>
+local load_start = os.clock()
+
technic = rawget(_G, "technic") or {}
technic.creative_mode = minetest.setting_getbool("creative_mode")
-technic.tube_inject_item = pipeworks.tube_inject_item or function (pos, start_pos, velocity, item)
- local tubed = pipeworks.tube_item(vector.new(pos), item)
- tubed:get_luaentity().start_pos = vector.new(start_pos)
- tubed:setvelocity(velocity)
- tubed:setacceleration(vector.new(0, 0, 0))
-end
-local load_start = os.clock()
local modpath = minetest.get_modpath("technic")
technic.modpath = modpath
+
-- Boilerplate to support intllib
-if minetest.get_modpath("intllib") then
+if rawget(_G, "intllib") then
technic.getter = intllib.Getter()
else
technic.getter = function(s,a,...)if a==nil then return s end a={a,...}return s:gsub("(@?)@(%(?)(%d+)(%)?)",function(e,o,n,c)if e==""then return a[tonumber(n)]..(o==""and c or"")else return"@"..o..n..c end end) end
@@ -39,6 +35,9 @@ dofile(modpath.."/crafts.lua")
-- Register functions
dofile(modpath.."/register.lua")
+-- Radiation
+dofile(modpath.."/radiation.lua")
+
-- Machines
dofile(modpath.."/machines/init.lua")
diff --git a/technic/items.lua b/technic/items.lua
index 27e05e4..a0edb96 100644
--- a/technic/items.lua
+++ b/technic/items.lua
@@ -194,14 +194,16 @@ for p = 0, 35 do
-- a natural (0.7%-fissile) uranium block having the activity of
-- 9 uranium ore blocks (due to 9 ingots per block). The group
-- value is proportional to the square root of the activity, and
- -- uranium ore has radioactive=1000. This yields radioactive=2065
- -- for a fully-depleted uranium block and radioactive=5286 for
+ -- uranium ore has radioactive=1. This yields radioactive=1.0
+ -- for a fully-depleted uranium block and radioactive=2.6 for
-- a 3.5%-fissile uranium block.
+ local radioactivity = math.floor(math.sqrt((1+5.55*p/35) * 18 / (1+5.55*7/35)) + 0.5);
(ov or minetest.register_node)(block, {
description = string.format(S("%.1f%%-Fissile Uranium Block"), p/10),
tiles = {"technic_uranium_block.png"},
is_ground_content = true,
- groups = {uranium_block=1, not_in_creative_inventory=nici, cracky=1, level=2, radioactive=math.floor(1000*math.sqrt((1+5.55*p/35) * 9 / (1+5.55*7/35)) + 0.5)},
+ groups = {uranium_block=1, not_in_creative_inventory=nici,
+ cracky=1, level=2, radioactive=radioactivity},
sounds = default.node_sound_stone_defaults(),
});
if not ov then
@@ -219,3 +221,4 @@ for p = 0, 35 do
})
end
end
+
diff --git a/technic/legacy.lua b/technic/legacy.lua
index 8360a71..6a080e1 100644
--- a/technic/legacy.lua
+++ b/technic/legacy.lua
@@ -22,9 +22,6 @@ technic.legacy_nodenames = {
["technic:compressor"] = "technic:lv_compressor",
["technic:compressor_active"] = "technic:lv_compressor_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",
["technic:generator"] = "technic:lv_generator",
["technic:generator_active"] = "technic:lv_generator_active",
@@ -36,3 +33,9 @@ for old, new in pairs(technic.legacy_nodenames) do
minetest.register_alias(old, new)
end
+for i = 0, 64 do
+ minetest.register_alias("technic:hv_cable"..i, "technic:hv_cable")
+ minetest.register_alias("technic:mv_cable"..i, "technic:mv_cable")
+ minetest.register_alias("technic:lv_cable"..i, "technic:lv_cable")
+end
+
diff --git a/technic/machines/HV/battery_box.lua b/technic/machines/HV/battery_box.lua
index 1e054ec..9093ba9 100644
--- a/technic/machines/HV/battery_box.lua
+++ b/technic/machines/HV/battery_box.lua
@@ -4,7 +4,7 @@ minetest.register_craft({
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:hv_cable', ''},
}
})
diff --git a/technic/machines/HV/cables.lua b/technic/machines/HV/cables.lua
index 25297c8..0b86a23 100644
--- a/technic/machines/HV/cables.lua
+++ b/technic/machines/HV/cables.lua
@@ -1,9 +1,9 @@
minetest.register_craft({
- output = 'technic:hv_cable0 3',
+ output = 'technic:hv_cable 3',
recipe = {
{'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting'},
- {'technic:mv_cable0', 'technic:mv_cable0', 'technic:mv_cable0'},
+ {'technic:mv_cable', 'technic:mv_cable', 'technic:mv_cable'},
{'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting', 'homedecor:plastic_sheeting'},
}
})
diff --git a/technic/machines/HV/forcefield.lua b/technic/machines/HV/forcefield.lua
index 0f0836d..3bf93b0 100644
--- a/technic/machines/HV/forcefield.lua
+++ b/technic/machines/HV/forcefield.lua
@@ -15,7 +15,7 @@ minetest.register_craft({
recipe = {
{"default:mese", "technic:motor", "default:mese" },
{"technic:deployer_off", "technic:machine_casing", "technic:deployer_off"},
- {"default:mese", "technic:hv_cable0", "default:mese" },
+ {"default:mese", "technic:hv_cable", "default:mese" },
}
})
@@ -195,7 +195,7 @@ end
minetest.register_node("technic:forcefield_emitter_off", {
description = S("%s Forcefield Emitter"):format("HV"),
tiles = {"technic_forcefield_emitter_off.png"},
- groups = {cracky = 1, technic_machine = 1},
+ groups = {cracky = 1, technic_machine = 1, technic_hv = 1},
on_receive_fields = forcefield_receive_fields,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
@@ -215,7 +215,8 @@ minetest.register_node("technic:forcefield_emitter_off", {
minetest.register_node("technic:forcefield_emitter_on", {
description = S("%s Forcefield Emitter"):format("HV"),
tiles = {"technic_forcefield_emitter_on.png"},
- groups = {cracky = 1, technic_machine = 1, not_in_creative_inventory=1},
+ groups = {cracky = 1, technic_machine = 1, technic_hv = 1,
+ not_in_creative_inventory=1},
drop = "technic:forcefield_emitter_off",
on_receive_fields = forcefield_receive_fields,
on_destruct = function(pos)
diff --git a/technic/machines/HV/generator.lua b/technic/machines/HV/generator.lua
index aa83590..3fb494b 100644
--- a/technic/machines/HV/generator.lua
+++ b/technic/machines/HV/generator.lua
@@ -5,7 +5,7 @@ minetest.register_craft({
recipe = {
{'technic:carbon_plate', 'technic:mv_generator', 'technic:composite_plate'},
{'pipeworks:tube_1', 'technic:hv_transformer', 'pipeworks:tube_1'},
- {'technic:stainless_steel_ingot', 'technic:hv_cable0', 'technic:stainless_steel_ingot'},
+ {'technic:stainless_steel_ingot', 'technic:hv_cable', 'technic:stainless_steel_ingot'},
}
})
diff --git a/technic/machines/HV/nuclear_reactor.lua b/technic/machines/HV/nuclear_reactor.lua
index 3aa1ba8..16bb928 100644
--- a/technic/machines/HV/nuclear_reactor.lua
+++ b/technic/machines/HV/nuclear_reactor.lua
@@ -1,34 +1,34 @@
--- The enriched uranium rod driven EU generator.
--- A very large and advanced machine providing vast amounts of power.
--- Very efficient but also expensive to run as it needs uranium. (10000EU 86400 ticks (one week))
--- Provides HV EUs that can be down converted as needed.
---
--- 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
+--[[
+ The enriched uranium rod driven EU generator.
+A very large and advanced machine providing vast amounts of power.
+Very efficient but also expensive to run as it needs uranium.
+Provides 10000 HV EUs for one week (only counted when loaded).
+
+The nuclear reactor core requires a casing of water and a protective
+shield to work. This is checked now and then and if the casing is not
+intact the reactor will melt down!
+--]]
+
+local burn_ticks = 7 * 24 * 60 * 60 -- Seconds
+local power_supply = 100000 -- EUs
+local fuel_type = "technic:uranium_fuel" -- The reactor burns this
local S = technic.getter
-if not vector.length_square then
- vector.length_square = function (v)
- return v.x*v.x + v.y*v.y + v.z*v.z
- end
-end
+local reactor_desc = S("@1 Nuclear Reactor Core", S("HV")),
--- FIXME: recipe must make more sense like a rod recepticle, steam chamber, HV generator?
+
+-- FIXME: Recipe should make more sense like a rod recepticle, steam chamber, HV generator?
minetest.register_craft({
output = 'technic:hv_nuclear_reactor_core',
recipe = {
{'technic:carbon_plate', 'default:obsidian_glass', 'technic:carbon_plate'},
{'technic:composite_plate', 'technic:machine_casing', 'technic:composite_plate'},
- {'technic:stainless_steel_ingot', 'technic:hv_cable0', 'technic:stainless_steel_ingot'},
+ {'technic:stainless_steel_ingot', 'technic:hv_cable', 'technic:stainless_steel_ingot'},
}
})
-local generator_formspec =
+local reactor_formspec =
"invsize[8,9;]"..
"label[0,0;"..S("Nuclear Reactor Rod Compartment").."]"..
"list[current_name;src;2,1;3,2;]"..
@@ -36,103 +36,113 @@ local generator_formspec =
"listring[]"
-- "Boxy sphere"
-local nodebox = {
- { -0.353, -0.353, -0.353, 0.353, 0.353, 0.353 }, -- Box
- { -0.495, -0.064, -0.064, 0.495, 0.064, 0.064 }, -- Circle +-x
- { -0.483, -0.128, -0.128, 0.483, 0.128, 0.128 },
- { -0.462, -0.191, -0.191, 0.462, 0.191, 0.191 },
- { -0.433, -0.249, -0.249, 0.433, 0.249, 0.249 },
- { -0.397, -0.303, -0.303, 0.397, 0.303, 0.303 },
- { -0.305, -0.396, -0.305, 0.305, 0.396, 0.305 }, -- Circle +-y
- { -0.250, -0.432, -0.250, 0.250, 0.432, 0.250 },
- { -0.191, -0.461, -0.191, 0.191, 0.461, 0.191 },
- { -0.130, -0.482, -0.130, 0.130, 0.482, 0.130 },
- { -0.066, -0.495, -0.066, 0.066, 0.495, 0.066 },
- { -0.064, -0.064, -0.495, 0.064, 0.064, 0.495 }, -- Circle +-z
- { -0.128, -0.128, -0.483, 0.128, 0.128, 0.483 },
- { -0.191, -0.191, -0.462, 0.191, 0.191, 0.462 },
- { -0.249, -0.249, -0.433, 0.249, 0.249, 0.433 },
- { -0.303, -0.303, -0.397, 0.303, 0.303, 0.397 },
+local node_box = {
+ {-0.353, -0.353, -0.353, 0.353, 0.353, 0.353}, -- Box
+ {-0.495, -0.064, -0.064, 0.495, 0.064, 0.064}, -- Circle +-x
+ {-0.483, -0.128, -0.128, 0.483, 0.128, 0.128},
+ {-0.462, -0.191, -0.191, 0.462, 0.191, 0.191},
+ {-0.433, -0.249, -0.249, 0.433, 0.249, 0.249},
+ {-0.397, -0.303, -0.303, 0.397, 0.303, 0.303},
+ {-0.305, -0.396, -0.305, 0.305, 0.396, 0.305}, -- Circle +-y
+ {-0.250, -0.432, -0.250, 0.250, 0.432, 0.250},
+ {-0.191, -0.461, -0.191, 0.191, 0.461, 0.191},
+ {-0.130, -0.482, -0.130, 0.130, 0.482, 0.130},
+ {-0.066, -0.495, -0.066, 0.066, 0.495, 0.066},
+ {-0.064, -0.064, -0.495, 0.064, 0.064, 0.495}, -- Circle +-z
+ {-0.128, -0.128, -0.483, 0.128, 0.128, 0.483},
+ {-0.191, -0.191, -0.462, 0.191, 0.191, 0.462},
+ {-0.249, -0.249, -0.433, 0.249, 0.249, 0.433},
+ {-0.303, -0.303, -0.397, 0.303, 0.303, 0.397},
}
+local SS_OFF = 0
+local SS_DANGER = 1
+local SS_CLEAR = 2
+
local reactor_siren = {}
-local function siren_set_state(pos, newstate)
+local function siren_set_state(pos, state)
local hpos = minetest.hash_node_position(pos)
local siren = reactor_siren[hpos]
if not siren then
- if newstate == "off" then return end
- siren = {state="off"}
+ if state == SS_OFF then return end
+ siren = {state=SS_OFF}
reactor_siren[hpos] = siren
end
- if newstate == "danger" and siren.state ~= "danger" then
+ if state == SS_DANGER and siren.state ~= SS_DANGER then
if siren.handle then minetest.sound_stop(siren.handle) end
- siren.handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_danger_loop", {pos=pos, gain=1.5, loop=true, max_hear_distance=48})
- siren.state = "danger"
- elseif newstate == "clear" then
+ siren.handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_danger_loop",
+ {pos=pos, gain=1.5, loop=true, max_hear_distance=48})
+ siren.state = SS_DANGER
+ elseif state == SS_CLEAR then
if siren.handle then minetest.sound_stop(siren.handle) end
- local clear_handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_clear", {pos=pos, gain=1.5, loop=false, max_hear_distance=48})
+ local clear_handle = minetest.sound_play("technic_hv_nuclear_reactor_siren_clear",
+ {pos=pos, gain=1.5, loop=false, max_hear_distance=48})
siren.handle = clear_handle
- siren.state = "clear"
- minetest.after(10, function ()
- if siren.handle == clear_handle then
- minetest.sound_stop(clear_handle)
- if reactor_siren[hpos] == siren then
- reactor_siren[hpos] = nil
- end
+ siren.state = SS_CLEAR
+ minetest.after(10, function()
+ if siren.handle ~= clear_handle then return end
+ minetest.sound_stop(clear_handle)
+ if reactor_siren[hpos] == siren then
+ reactor_siren[hpos] = nil
end
end)
- elseif newstate == "off" and siren.state ~= "off" then
+ elseif state == SS_OFF and siren.state ~= SS_OFF then
if siren.handle then minetest.sound_stop(siren.handle) end
- siren.handle = nil
reactor_siren[hpos] = nil
end
end
+
local function siren_danger(pos, meta)
meta:set_int("siren", 1)
- siren_set_state(pos, "danger")
+ siren_set_state(pos, SS_DANGER)
end
+
local function siren_clear(pos, meta)
if meta:get_int("siren") ~= 0 then
- siren_set_state(pos, "clear")
+ siren_set_state(pos, SS_CLEAR)
meta:set_int("siren", 0)
end
end
--- The standard reactor structure consists of a 9x9x9 cube. 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
---
--- The man-hole and the HV cable are only in the middle, and the man-hole
--- is optional.
---
--- For the reactor to operate and not melt down, it insists on the inner
--- 7x7x7 portion (from the core out to the blast-resistant concrete)
--- being intact. Intactness only depends on the number of nodes of the
--- right type in each layer. The water layer must have water in all but
--- at most one node; the steel and blast-resistant concrete layers must
--- have the right material in all but at most two nodes. The permitted
--- gaps are meant for the cable and man-hole, but can actually be anywhere
--- and contain anything. For the reactor to be useful, a cable must
--- connect to the core, but it can go in any direction.
---
--- The outer concrete layer of the standard structure is not required
--- for the reactor to operate. It is noted here because it used to
--- be mandatory, and for historical reasons (that it predates the
--- implementation of radiation) it needs to continue being adequate
--- shielding of legacy reactors. If it ever ceases to be adequate
--- shielding for new reactors, legacy ones should be grandfathered.
-local reactor_structure_badness = function(pos)
+--[[
+The standard reactor structure consists of a 9x9x9 cube. A cross
+section through the middle:
+
+ CCCC CCCC
+ CBBB BBBC
+ CBLL LLBC
+ CBLWWWLBC
+ CBLW#WLBC
+ CBLW|WLBC
+ CBLL|LLBC
+ CBBB|BBBC
+ CCCC|CCCC
+ C = Concrete, B = Blast-resistant concrete, L = Lead,
+ W = water node, # = reactor core, | = HV cable
+
+The man-hole is optional (but necessary for refueling).
+
+For the reactor to operate and not melt down, it insists on the inner
+7x7x7 portion (from the core out to the blast-resistant concrete)
+being intact. Intactness only depends on the number of nodes of the
+right type in each layer. The water layer must have water in all but
+at most one node; the steel and blast-resistant concrete layers must
+have the right material in all but at most two nodes. The permitted
+gaps are meant for the cable and man-hole, but can actually be anywhere
+and contain anything. For the reactor to be useful, a cable must
+connect to the core, but it can go in any direction.
+
+The outer concrete layer of the standard structure is not required
+for the reactor to operate. It is noted here because it used to
+be mandatory, and for historical reasons (that it predates the
+implementation of radiation) it needs to continue being adequate
+shielding of legacy reactors. If it ever ceases to be adequate
+shielding for new reactors, legacy ones should be grandfathered.
+
+For legacy reasons, if the reactor has a stainless steel layer instead
+of a lead layer it will be converted to a lead layer.
+--]]
+local function reactor_structure_badness(pos)
local vm = VoxelManip()
local pos1 = vector.subtract(pos, 3)
local pos2 = vector.add(pos, 3)
@@ -141,11 +151,12 @@ local reactor_structure_badness = function(pos)
local area = VoxelArea:new({MinEdge=MinEdge, MaxEdge=MaxEdge})
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_lead = minetest.get_content_id("technic:lead_block")
+ local c_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 blastlayer, steellayer, waterlayer = 0, 0, 0
+ local blast_layer, steel_layer, lead_layer, water_layer = 0, 0, 0, 0
for z = pos1.z, pos2.z do
for y = pos1.y, pos2.y do
@@ -155,38 +166,63 @@ local reactor_structure_badness = function(pos)
y == pos1.y or y == pos2.y or
z == pos1.z or z == pos2.z then
if cid == c_blast_concrete then
- blastlayer = blastlayer + 1
+ blast_layer = blast_layer + 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 cid == c_stainless_steel then
- steellayer = steellayer + 1
+ y == pos1.y+1 or y == pos2.y-1 or
+ z == pos1.z+1 or z == pos2.z-1 then
+ if cid == c_lead then
+ lead_layer = lead_layer + 1
+ elseif cid == c_steel then
+ steel_layer = steel_layer + 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
+ y == pos1.y+2 or y == pos2.y-2 or
+ z == pos1.z+2 or z == pos2.z-2 then
if cid == c_water_source or cid == c_water_flowing then
- waterlayer = waterlayer + 1
+ water_layer = water_layer + 1
end
end
end
end
end
- if waterlayer > 25 then waterlayer = 25 end
- if steellayer > 96 then steellayer = 96 end
- if blastlayer > 216 then blastlayer = 216 end
- return (25 - waterlayer) + (96 - steellayer) + (216 - blastlayer)
+
+ if steel_layer >= 96 then
+ for z = pos1.z+1, pos2.z-1 do
+ for y = pos1.y+1, pos2.y-1 do
+ for x = pos1.x+1, pos2.x-1 do
+ local vi = area:index(x, y, z)
+ if 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[vi] == c_steel then
+ data[vi] = c_lead
+ end
+ end
+ end
+ end
+ end
+ vm:set_data(data)
+ vm:write_to_map()
+ lead_layer = steel_layer
+ end
+
+ if water_layer > 25 then water_layer = 25 end
+ if lead_layer > 96 then lead_layer = 96 end
+ if blast_layer > 216 then blast_layer = 216 end
+ return (25 - water_layer) + (96 - lead_layer) + (216 - blast_layer)
end
-local function meltdown_reactor(pos)
- print("A reactor melted down at "..minetest.pos_to_string(pos))
+
+local function melt_down_reactor(pos)
+ minetest.log("action", "A reactor melted down at "..minetest.pos_to_string(pos))
minetest.set_node(pos, {name="technic:corium_source"})
end
+
minetest.register_abm({
nodenames = {"technic:hv_nuclear_reactor_core_active"},
- interval = 1,
+ interval = 4,
chance = 1,
action = function (pos, node)
local meta = minetest.get_meta(pos)
@@ -194,14 +230,14 @@ minetest.register_abm({
local accum_badness = meta:get_int("structure_accumulated_badness")
if badness == 0 then
if accum_badness ~= 0 then
- meta:set_int("structure_accumulated_badness", accum_badness - 1)
+ meta:set_int("structure_accumulated_badness", accum_badness - 4)
siren_clear(pos, meta)
end
else
siren_danger(pos, meta)
accum_badness = accum_badness + badness
- if accum_badness >= 100 then
- meltdown_reactor(pos)
+ if accum_badness >= 25 then
+ melt_down_reactor(pos)
else
meta:set_int("structure_accumulated_badness", accum_badness)
end
@@ -209,40 +245,36 @@ minetest.register_abm({
end,
})
-local run = function(pos, node)
+local function run(pos, node)
local meta = minetest.get_meta(pos)
- local machine_name = S("Nuclear %s Generator Core"):format("HV")
local burn_time = meta:get_int("burn_time") or 0
if burn_time >= burn_ticks or burn_time == 0 then
local inv = meta:get_inventory()
if not inv:is_empty("src") then
- local srclist = inv:get_list("src")
+ local src_list = 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
- correct_fuel_count = correct_fuel_count + 1
- end
+ for _, src_stack in pairs(src_list) do
+ if src_stack and src_stack:get_name() == fuel_type then
+ correct_fuel_count = correct_fuel_count + 1
end
end
- -- Check that the reactor is complete as well
- -- as the correct number of correct fuel
+ -- Check that the reactor is complete and has the correct fuel
if correct_fuel_count == 6 and
- reactor_structure_badness(pos) == 0 then
+ reactor_structure_badness(pos) == 0 then
meta:set_int("burn_time", 1)
technic.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)
+ for idx, src_stack in pairs(src_list) do
+ src_stack:take_item()
+ inv:set_stack("src", idx, src_stack)
end
return
end
end
meta:set_int("HV_EU_supply", 0)
meta:set_int("burn_time", 0)
- meta:set_string("infotext", S("%s Idle"):format(machine_name))
+ meta:set_string("infotext", S("%s Idle"):format(reactor_desc))
technic.swap_node(pos, "technic:hv_nuclear_reactor_core")
meta:set_int("structure_accumulated_badness", 0)
siren_clear(pos, meta)
@@ -250,40 +282,33 @@ local run = function(pos, node)
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", machine_name.." ("..percent.."%)")
+ meta:set_string("infotext", reactor_desc.." ("..percent.."%)")
meta:set_int("HV_EU_supply", power_supply)
end
end
minetest.register_node("technic:hv_nuclear_reactor_core", {
- description = S("Nuclear %s Generator Core"):format("HV"),
- 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"},
- groups = {cracky=1, technic_machine=1},
+ description = reactor_desc,
+ tiles = {"technic_hv_nuclear_reactor_core.png"},
+ groups = {cracky=1, technic_machine=1, technic_hv=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
- drawtype="nodebox",
+ drawtype = "nodebox",
paramtype = "light",
stack_max = 1,
node_box = {
type = "fixed",
- fixed = nodebox
+ fixed = node_box
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
- meta:set_string("infotext", S("Nuclear %s Generator Core"):format("HV"))
- 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("burn_time", 0)
- meta:set_string("formspec", generator_formspec)
+ meta:set_string("infotext", reactor_desc)
+ meta:set_string("formspec", reactor_formspec)
local inv = meta:get_inventory()
inv:set_size("src", 6)
- end,
+ end,
can_dig = technic.machine_can_dig,
- on_destruct = function(pos) siren_set_state(pos, "off") end,
+ on_destruct = function(pos) siren_set_state(pos, SS_OFF) end,
allow_metadata_inventory_put = technic.machine_inventory_put,
allow_metadata_inventory_take = technic.machine_inventory_take,
allow_metadata_inventory_move = technic.machine_inventory_move,
@@ -291,23 +316,22 @@ minetest.register_node("technic:hv_nuclear_reactor_core", {
})
minetest.register_node("technic:hv_nuclear_reactor_core_active", {
- 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"},
- groups = {cracky=1, technic_machine=1, radioactive=11000, not_in_creative_inventory=1},
+ tiles = {"technic_hv_nuclear_reactor_core.png"},
+ groups = {cracky=1, technic_machine=1, technic_hv=1,
+ radioactive=4, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
- drop="technic:hv_nuclear_reactor_core",
- drawtype="nodebox",
- light_source = 15,
+ drop = "technic:hv_nuclear_reactor_core",
+ drawtype = "nodebox",
+ light_source = 14,
paramtype = "light",
node_box = {
type = "fixed",
- fixed = nodebox
+ fixed = node_box
},
can_dig = technic.machine_can_dig,
- after_dig_node = meltdown_reactor,
- on_destruct = function(pos) siren_set_state(pos, "off") end,
+ after_dig_node = melt_down_reactor,
+ on_destruct = function(pos) siren_set_state(pos, SS_OFF) end,
allow_metadata_inventory_put = technic.machine_inventory_put,
allow_metadata_inventory_take = technic.machine_inventory_take,
allow_metadata_inventory_move = technic.machine_inventory_move,
@@ -318,10 +342,10 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", {
end,
on_timer = function(pos, node)
local meta = minetest.get_meta(pos)
-
+
-- Connected back?
if meta:get_int("HV_EU_timeout") > 0 then return false end
-
+
local burn_time = meta:get_int("burn_time") or 0
if burn_time >= burn_ticks or burn_time == 0 then
@@ -332,7 +356,7 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", {
siren_clear(pos, meta)
return false
end
-
+
meta:set_int("burn_time", burn_time + 1)
return true
end,
@@ -341,383 +365,3 @@ minetest.register_node("technic:hv_nuclear_reactor_core_active", {
technic.register_machine("HV", "technic:hv_nuclear_reactor_core", technic.producer)
technic.register_machine("HV", "technic:hv_nuclear_reactor_core_active", technic.producer)
--- radioactivity
-
--- Radiation resistance represents the extent to which a material
--- attenuates radiation passing through it; i.e., how good a radiation
--- shield it is. This is identified per node type. For materials that
--- exist in real life, the radiation resistance value that this system
--- uses for a node type consisting of a solid cube of that material is the
--- (approximate) number of halvings of ionising radiation that is achieved
--- by a metre of the material in real life. This is approximately
--- proportional to density, which provides a good way to estimate it.
--- Homogeneous mixtures of materials have radiation resistance computed
--- by a simple weighted mean. Note that the amount of attenuation that
--- a material achieves in-game is not required to be (and is not) the
--- same as the attenuation achieved in real life.
---
--- Radiation resistance for a node type may be specified in the node
--- definition, under the key "radiation_resistance". As an interim
--- measure, until node definitions widely include this, this code
--- knows a bunch of values for particular node types in several mods,
--- and values for groups of node types. The node definition takes
--- precedence if it specifies a value. Nodes for which no value at
--- all is known are taken to provide no radiation resistance at all;
--- this is appropriate for the majority of node types. Only node types
--- consisting of a fairly homogeneous mass of material should report
--- non-zero radiation resistance; anything with non-uniform geometry
--- or complex internal structure should show no radiation resistance.
--- Fractional resistance values are permitted; two significant figures
--- is the recommended precision.
-local default_radiation_resistance_per_node = {
- ["default:brick"] = 13,
- ["default:bronzeblock"] = 45,
- ["default:clay"] = 15,
- ["default:coalblock"] = 9.6,
- ["default:cobble"] = 15,
- ["default:copperblock"] = 46,
- ["default:desert_cobble"] = 15,
- ["default:desert_sand"] = 10,
- ["default:desert_stone"] = 17,
- ["default:desert_stonebrick"] = 17,
- ["default:diamondblock"] = 24,
- ["default:dirt"] = 8.2,
- ["default:dirt_with_grass"] = 8.2,
- ["default:dirt_with_grass_footsteps"] = 8.2,
- ["default:dirt_with_snow"] = 8.2,
- ["default:glass"] = 17,
- ["default:goldblock"] = 170,
- ["default:gravel"] = 10,
- ["default:ice"] = 5.6,
- ["default:lava_flowing"] = 8.5,
- ["default:lava_source"] = 17,
- ["default:mese"] = 21,
- ["default:mossycobble"] = 15,
- ["default:nyancat"] = 1000,
- ["default:nyancat_rainbow"] = 1000,
- ["default:obsidian"] = 18,
- ["default:obsidian_glass"] = 18,
- ["default:sand"] = 10,
- ["default:sandstone"] = 15,
- ["default:sandstonebrick"] = 15,
- ["default:snowblock"] = 1.7,
- ["default:steelblock"] = 40,
- ["default:stone"] = 17,
- ["default:stone_with_coal"] = 16,
- ["default:stone_with_copper"] = 20,
- ["default:stone_with_diamond"] = 18,
- ["default:stone_with_gold"] = 34,
- ["default:stone_with_iron"] = 20,
- ["default:stone_with_mese"] = 17,
- ["default:stonebrick"] = 17,
- ["default:water_flowing"] = 2.8,
- ["default:water_source"] = 5.6,
- ["farming:desert_sand_soil"] = 10,
- ["farming:desert_sand_soil_wet"] = 10,
- ["farming:soil"] = 8.2,
- ["farming:soil_wet"] = 8.2,
- ["glooptest:akalin_crystal_glass"] = 21,
- ["glooptest:akalinblock"] = 40,
- ["glooptest:alatro_crystal_glass"] = 21,
- ["glooptest:alatroblock"] = 40,
- ["glooptest:amethystblock"] = 18,
- ["glooptest:arol_crystal_glass"] = 21,
- ["glooptest:crystal_glass"] = 21,
- ["glooptest:emeraldblock"] = 19,
- ["glooptest:heavy_crystal_glass"] = 21,
- ["glooptest:mineral_akalin"] = 20,
- ["glooptest:mineral_alatro"] = 20,
- ["glooptest:mineral_amethyst"] = 17,
- ["glooptest:mineral_arol"] = 20,
- ["glooptest:mineral_desert_coal"] = 16,
- ["glooptest:mineral_desert_iron"] = 20,
- ["glooptest:mineral_emerald"] = 17,
- ["glooptest:mineral_kalite"] = 20,
- ["glooptest:mineral_ruby"] = 18,
- ["glooptest:mineral_sapphire"] = 18,
- ["glooptest:mineral_talinite"] = 20,
- ["glooptest:mineral_topaz"] = 18,
- ["glooptest:reinforced_crystal_glass"] = 21,
- ["glooptest:rubyblock"] = 27,
- ["glooptest:sapphireblock"] = 27,
- ["glooptest:talinite_crystal_glass"] = 21,
- ["glooptest:taliniteblock"] = 40,
- ["glooptest:topazblock"] = 24,
- ["mesecons_extrawires:mese_powered"] = 21,
- ["moreblocks:cactus_brick"] = 13,
- ["moreblocks:cactus_checker"] = 8.5,
- ["moreblocks:circle_stone_bricks"] = 17,
- ["moreblocks:clean_glass"] = 17,
- ["moreblocks:coal_checker"] = 9.0,
- ["moreblocks:coal_glass"] = 17,
- ["moreblocks:coal_stone"] = 17,
- ["moreblocks:coal_stone_bricks"] = 17,
- ["moreblocks:glow_glass"] = 17,
- ["moreblocks:grey_bricks"] = 15,
- ["moreblocks:iron_checker"] = 11,
- ["moreblocks:iron_glass"] = 17,
- ["moreblocks:iron_stone"] = 17,
- ["moreblocks:iron_stone_bricks"] = 17,
- ["moreblocks:plankstone"] = 9.3,
- ["moreblocks:split_stone_tile"] = 15,
- ["moreblocks:split_stone_tile_alt"] = 15,
- ["moreblocks:stone_tile"] = 15,
- ["moreblocks:super_glow_glass"] = 17,
- ["moreblocks:tar"] = 7.0,
- ["moreblocks:wood_tile"] = 1.7,
- ["moreblocks:wood_tile_center"] = 1.7,
- ["moreblocks:wood_tile_down"] = 1.7,
- ["moreblocks:wood_tile_flipped"] = 1.7,
- ["moreblocks:wood_tile_full"] = 1.7,
- ["moreblocks:wood_tile_left"] = 1.7,
- ["moreblocks:wood_tile_right"] = 1.7,
- ["moreblocks:wood_tile_up"] = 1.7,
- ["moreores:mineral_mithril"] = 18,
- ["moreores:mineral_silver"] = 21,
- ["moreores:mineral_tin"] = 19,
- ["moreores:mithril_block"] = 26,
- ["moreores:silver_block"] = 53,
- ["moreores:tin_block"] = 37,
- ["snow:snow_brick"] = 2.8,
- ["technic:brass_block"] = 43,
- ["technic:carbon_steel_block"] = 40,
- ["technic:cast_iron_block"] = 40,
- ["technic:chernobylite_block"] = 40,
- ["technic:chromium_block"] = 37,
- ["technic:corium_flowing"] = 40,
- ["technic:corium_source"] = 80,
- ["technic:granite"] = 18,
- ["technic:lead_block"] = 80,
- ["technic:marble"] = 18,
- ["technic:marble_bricks"] = 18,
- ["technic:mineral_chromium"] = 19,
- ["technic:mineral_uranium"] = 71,
- ["technic:mineral_zinc"] = 19,
- ["technic:stainless_steel_block"] = 40,
- ["technic:zinc_block"] = 36,
- ["tnt:tnt"] = 11,
- ["tnt:tnt_burning"] = 11,
-}
-local default_radiation_resistance_per_group = {
- concrete = 16,
- tree = 3.4,
- uranium_block = 500,
- wood = 1.7,
-}
-local cache_radiation_resistance = {}
-local function node_radiation_resistance(nodename)
- local eff = cache_radiation_resistance[nodename]
- if eff then return eff end
- local def = minetest.registered_nodes[nodename] or {groups={}}
- eff = def.radiation_resistance or default_radiation_resistance_per_node[nodename]
- if not eff then
- for g, v in pairs(def.groups) do
- if v > 0 and default_radiation_resistance_per_group[g] then
- eff = default_radiation_resistance_per_group[g]
- break
- end
- end
- end
- if not eff then eff = 0 end
- cache_radiation_resistance[nodename] = eff
- return eff
-end
-
--- Radioactive nodes cause damage to nearby players. The damage
--- effect depends on the intrinsic strength of the radiation source,
--- the distance between the source and the player, and the shielding
--- effect of the intervening material. These determine a rate of damage;
--- total damage caused is the integral of this over time.
---
--- In the absence of effective shielding, for a specific source the
--- damage rate varies realistically in inverse proportion to the square
--- of the distance. (Distance is measured to the player's abdomen,
--- not to the nominal player position which corresponds to the foot.)
--- However, if the player is inside a non-walkable (liquid or gaseous)
--- radioactive node, the nominal distance could go to zero, yielding
--- infinite damage. In that case, the player's body is displacing the
--- radioactive material, so the effective distance should remain non-zero.
--- We therefore apply a lower distance bound of sqrt(0.75) m, which is
--- the maximum distance one can get from the node centre within the node.
---
--- A radioactive node is identified by being in the "radioactive" group,
--- and the group value signifies the strength of the radiation source.
--- The group value is the distance in millimetres from a node at which
--- an unshielded player will be damaged by 0.25 HP/s. Or, equivalently,
--- it is 2000 times the square root of the damage rate in HP/s that an
--- unshielded player 1 m away will take.
---
--- Shielding is assessed by sampling every 0.25 m along the path
--- from the source to the player, ignoring the source node itself.
--- The summed shielding values from the sampled nodes yield a measure
--- of the total amount of shielding on the path. As in reality,
--- shielding causes exponential attenuation of radiation. However, the
--- effect is scaled down relative to real life. A metre of a node with
--- radiation resistance value R yields attenuation of sqrt(R)*0.1 nepers.
--- (In real life it would be about R*0.69 nepers, by the definition
--- of the radiation resistance values.) The sqrt part of this formula
--- scales down the differences between shielding types, reflecting the
--- game's simplification of making expensive materials such as gold
--- readily available in cubic metres. The multiplicative factor in the
--- formula scales down the difference between shielded and unshielded
--- safe distances, avoiding the latter becoming impractically large.
---
--- Damage is processed at rates down to 0.25 HP/s, which in the absence of
--- shielding is attained at the distance specified by the "radioactive"
--- group value. Computed damage rates below 0.25 HP/s result in no
--- damage at all to the player. This gives the player an opportunity
--- to be safe, and limits the range at which source/player interactions
--- need to be considered.
-local assumed_abdomen_offset = vector.new(0, 1, 0)
-local assumed_abdomen_offset_length = vector.length(assumed_abdomen_offset)
-local cache_scaled_shielding = {}
-
-local damage_enabled = minetest.setting_getbool("enable_damage")
-
-if damage_enabled then
- minetest.register_abm({
- nodenames = {"group:radioactive"},
- interval = 1,
- chance = 1,
- action = function (pos, node)
- local strength = minetest.registered_nodes[node.name].groups.radioactive
- for _, o in ipairs(minetest.get_objects_inside_radius(pos, strength*0.001 + assumed_abdomen_offset_length)) do
- if o:is_player() then
- local rel = vector.subtract(vector.add(o:getpos(), assumed_abdomen_offset), pos)
- local dist_sq = vector.length_square(rel)
- local dist = math.sqrt(dist_sq)
- local dirstep = dist == 0 and vector.new(0,0,0) or vector.divide(rel, dist*4)
- local intpos = pos
- local shielding = 0
- for intdist = 0.25, dist, 0.25 do
- intpos = vector.add(intpos, dirstep)
- local intnodepos = vector.round(intpos)
- if not vector.equals(intnodepos, pos) then
- local sname = minetest.get_node(intnodepos).name
- local sval = cache_scaled_shielding[sname]
- if not sval then
- sval = math.sqrt(node_radiation_resistance(sname)) * -0.025
- cache_scaled_shielding[sname] = sval
- end
- shielding = shielding + sval
- end
- end
- local dmg_rate = 0.25e-6 * strength*strength * math.exp(shielding) / math.max(0.75, dist_sq)
- if dmg_rate >= 0.25 then
- local dmg_int = math.floor(dmg_rate)
- if math.random() < dmg_rate-dmg_int then
- dmg_int = dmg_int + 1
- end
- if dmg_int > 0 then
- o:set_hp(math.max(o:get_hp() - dmg_int, 0))
- end
- end
- end
- end
- end,
- })
-end
-
--- radioactive materials that can result from destroying a reactor
-local corium_griefing = 1
-if (not technic.config:get_bool("enable_corium_griefing")) then
- corium_griefing = 0
-end
-
-for _, state in ipairs({ "flowing", "source" }) do
- minetest.register_node("technic:corium_"..state, {
- description = S(state == "source" and "Corium Source" or "Flowing Corium"),
- drawtype = (state == "source" and "liquid" or "flowingliquid"),
- [state == "source" and "tiles" or "special_tiles"] = {{
- name = "technic_corium_"..state.."_animated.png",
- animation = {
- type = "vertical_frames",
- aspect_w = 16,
- aspect_h = 16,
- length = 3.0,
- },
- }},
- paramtype = "light",
- paramtype2 = (state == "flowing" and "flowingliquid" or nil),
- light_source = (state == "source" and 8 or 5),
- walkable = false,
- pointable = false,
- diggable = false,
- buildable_to = true,
- drop = "",
- drowning = 1,
- liquidtype = state,
- liquid_alternative_flowing = "technic:corium_flowing",
- liquid_alternative_source = "technic:corium_source",
- liquid_viscosity = LAVA_VISC,
- liquid_renewable = false,
- damage_per_second = 6,
- post_effect_color = { a=192, r=80, g=160, b=80 },
- groups = {
- liquid = 2,
- hot = 3,
- igniter = corium_griefing,
- radioactive = (state == "source" and 32000 or 16000),
- not_in_creative_inventory = (state == "flowing" and 1 or nil),
- },
- })
-end
-
-if bucket and bucket.register_liquid then
- bucket.register_liquid(
- "technic:corium_source",
- "technic:corium_flowing",
- "technic:bucket_corium",
- "technic_bucket_corium.png",
- "Corium Bucket"
- )
-end
-
-minetest.register_node("technic:chernobylite_block", {
- description = S("Chernobylite Block"),
- tiles = { "technic_chernobylite_block.png" },
- is_ground_content = true,
- groups = { cracky=1, radioactive=5000, level=2 },
- sounds = default.node_sound_stone_defaults(),
- light_source = 2,
-
-})
-
-minetest.register_abm({
- nodenames = {"group:water"},
- neighbors = {"technic:corium_source"},
- interval = 1,
- chance = 1,
- action = function (pos, node)
- minetest.remove_node(pos)
- end,
-})
-
-if (corium_griefing == 1) then
- minetest.register_abm({
- nodenames = {"technic:corium_flowing"},
- interval = 5,
- chance = 10,
- action = function (pos, node)
- minetest.set_node(pos, {name="technic:chernobylite_block"})
- end,
- })
- minetest.register_abm({
- nodenames = { "technic:corium_source", "technic:corium_flowing" },
- interval = 4,
- chance = 4,
- action = function (pos, node)
- for _, offset in ipairs({
- vector.new(1,0,0),
- vector.new(-1,0,0),
- vector.new(0,0,1),
- vector.new(0,0,-1),
- vector.new(0,-1,0),
- }) do
- if math.random(8) == 1 then
- minetest.dig_node(vector.add(pos, offset))
- end
- end
- end,
- })
-end
diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua
index 60805cc..8255676 100644
--- a/technic/machines/HV/quarry.lua
+++ b/technic/machines/HV/quarry.lua
@@ -5,7 +5,7 @@ minetest.register_craft({
recipe = {
{"technic:carbon_plate", "pipeworks:filter", "technic:composite_plate"},
{"technic:motor", "technic:machine_casing", "technic:diamond_drill_head"},
- {"technic:carbon_steel_block", "technic:hv_cable0", "technic:carbon_steel_block"}},
+ {"technic:carbon_steel_block", "technic:hv_cable", "technic:carbon_steel_block"}},
output = "technic:quarry",
})
@@ -213,7 +213,8 @@ minetest.register_node("technic:quarry", {
"technic_carbon_steel_block.png^default_tool_mesepick.png",
"technic_carbon_steel_block.png"),
paramtype2 = "facedir",
- groups = {cracky=2, tubedevice=1, technic_machine = 1},
+ groups = {cracky=2, tubedevice=1, technic_machine=1, technic_hv=1},
+ connect_sides = {"bottom", "front", "left", "right"},
tube = {
connect_sides = {top = 1},
},
diff --git a/technic/machines/HV/solar_array.lua b/technic/machines/HV/solar_array.lua
index 414291a..c7de7c8 100644
--- a/technic/machines/HV/solar_array.lua
+++ b/technic/machines/HV/solar_array.lua
@@ -6,7 +6,7 @@ minetest.register_craft({
recipe = {
{'technic:solar_array_mv', 'technic:solar_array_mv', 'technic:solar_array_mv'},
{'technic:carbon_plate', 'technic:hv_transformer', 'technic:composite_plate'},
- {'', 'technic:hv_cable0', ''},
+ {'', 'technic:hv_cable', ''},
}
})
diff --git a/technic/machines/LV/alloy_furnace.lua b/technic/machines/LV/alloy_furnace.lua
index bdf2f31..5e4f7c4 100644
--- a/technic/machines/LV/alloy_furnace.lua
+++ b/technic/machines/LV/alloy_furnace.lua
@@ -4,9 +4,9 @@
minetest.register_craft({
output = 'technic:lv_alloy_furnace',
recipe = {
- {'default:brick', 'default:brick', 'default:brick'},
- {'default:brick', 'technic:machine_casing', 'default:brick'},
- {'default:brick', 'technic:lv_cable0', 'default:brick'},
+ {'default:brick', 'default:brick', 'default:brick'},
+ {'default:brick', 'technic:machine_casing', 'default:brick'},
+ {'default:brick', 'technic:lv_cable', 'default:brick'},
}
})
diff --git a/technic/machines/LV/battery_box.lua b/technic/machines/LV/battery_box.lua
index 429bcd6..066bc9d 100644
--- a/technic/machines/LV/battery_box.lua
+++ b/technic/machines/LV/battery_box.lua
@@ -2,9 +2,9 @@
minetest.register_craft({
output = 'technic:lv_battery_box0',
recipe = {
- {'group:wood', 'group:wood', 'group:wood'},
- {'technic:battery', 'technic:machine_casing', 'technic:battery'},
- {'technic:battery', 'technic:lv_cable0', 'technic:battery'},
+ {'group:wood', 'group:wood', 'group:wood'},
+ {'technic:battery', 'technic:machine_casing', 'technic:battery'},
+ {'technic:battery', 'technic:lv_cable', 'technic:battery'},
}
})
diff --git a/technic/machines/LV/cables.lua b/technic/machines/LV/cables.lua
index e18eae1..d4ed880 100644
--- a/technic/machines/LV/cables.lua
+++ b/technic/machines/LV/cables.lua
@@ -1,8 +1,8 @@
-minetest.register_alias("lv_cable", "technic:lv_cable0")
+minetest.register_alias("lv_cable", "technic:lv_cable")
minetest.register_craft({
- output = 'technic:lv_cable0 6',
+ output = 'technic:lv_cable 6',
recipe = {
{'default:paper', 'default:paper', 'default:paper'},
{'default:copper_ingot', 'default:copper_ingot', 'default:copper_ingot'},
diff --git a/technic/machines/LV/cnc.lua b/technic/machines/LV/cnc.lua
index dd67e9b..58ec6ba 100644
--- a/technic/machines/LV/cnc.lua
+++ b/technic/machines/LV/cnc.lua
@@ -9,6 +9,17 @@
local S = technic.getter
+
+minetest.register_craft({
+ output = 'technic:cnc',
+ recipe = {
+ {'default:glass', 'technic:diamond_drill_head', 'default:glass'},
+ {'technic:control_logic_unit', 'technic:machine_casing', 'technic:motor'},
+ {'technic:carbon_steel_ingot', 'technic:lv_cable', 'technic:carbon_steel_ingot'},
+ },
+})
+
+
local shape = {}
local onesize_products = {
slope = 2,
@@ -174,16 +185,9 @@ minetest.register_node("technic:cnc", {
description = S("%s CNC Machine"):format("LV"),
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",
+ groups = {cracky=2, technic_machine=1, technic_lv=1},
+ connect_sides = {"bottom", "back", "left", "right"},
paramtype2 = "facedir",
- node_box = {
- type = "fixed",
- fixed = {
- {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
- },
- },
- groups = {cracky=2, technic_machine=1},
legacy_facedir_simple = true,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
@@ -207,9 +211,10 @@ minetest.register_node("technic:cnc_active", {
description = S("%s CNC Machine"):format("LV"),
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"},
+ groups = {cracky=2, technic_machine=1, technic_lv=1, not_in_creative_inventory=1},
+ connect_sides = {"bottom", "back", "left", "right"},
paramtype2 = "facedir",
drop = "technic:cnc",
- groups = {cracky=2, technic_machine=1, not_in_creative_inventory=1},
legacy_facedir_simple = true,
can_dig = technic.machine_can_dig,
allow_metadata_inventory_put = technic.machine_inventory_put,
@@ -223,15 +228,3 @@ minetest.register_node("technic:cnc_active", {
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:machine_casing', 'technic:motor'},
- {'technic:carbon_steel_ingot', 'technic:lv_cable0', 'technic:carbon_steel_ingot'},
- },
-})
-
diff --git a/technic/machines/LV/compressor.lua b/technic/machines/LV/compressor.lua
index e2bde40..67b9f79 100644
--- a/technic/machines/LV/compressor.lua
+++ b/technic/machines/LV/compressor.lua
@@ -4,9 +4,9 @@ minetest.register_alias("compressor", "technic:lv_compressor")
minetest.register_craft({
output = 'technic:lv_compressor',
recipe = {
- {'default:stone', 'technic:motor', 'default:stone'},
- {'mesecons:piston', 'technic:machine_casing', 'mesecons:piston'},
- {'technic:fine_silver_wire', 'technic:lv_cable0', 'technic:fine_silver_wire'},
+ {'default:stone', 'technic:motor', 'default:stone'},
+ {'mesecons:piston', 'technic:machine_casing', 'mesecons:piston'},
+ {'technic:fine_silver_wire', 'technic:lv_cable', 'technic:fine_silver_wire'},
}
})
diff --git a/technic/machines/LV/electric_furnace.lua b/technic/machines/LV/electric_furnace.lua
index cc4daff..768f04a 100644
--- a/technic/machines/LV/electric_furnace.lua
+++ b/technic/machines/LV/electric_furnace.lua
@@ -7,7 +7,7 @@ minetest.register_craft({
recipe = {
{'default:cobble', 'default:cobble', 'default:cobble'},
{'default:cobble', 'technic:machine_casing', 'default:cobble'},
- {'default:cobble', 'technic:lv_cable0', 'default:cobble'},
+ {'default:cobble', 'technic:lv_cable', 'default:cobble'},
}
})
diff --git a/technic/machines/LV/extractor.lua b/technic/machines/LV/extractor.lua
index 363d2e3..55d0140 100644
--- a/technic/machines/LV/extractor.lua
+++ b/technic/machines/LV/extractor.lua
@@ -6,7 +6,7 @@ minetest.register_craft({
recipe = {
{'technic:treetap', 'technic:motor', 'technic:treetap'},
{'technic:treetap', 'technic:machine_casing', 'technic:treetap'},
- {'', 'technic:lv_cable0', ''},
+ {'', 'technic:lv_cable', ''},
}
})
diff --git a/technic/machines/LV/generator.lua b/technic/machines/LV/generator.lua
index 999dbc5..dc9815f 100644
--- a/technic/machines/LV/generator.lua
+++ b/technic/machines/LV/generator.lua
@@ -10,7 +10,7 @@ minetest.register_craft({
recipe = {
{'default:stone', 'default:furnace', 'default:stone'},
{'default:stone', 'technic:machine_casing', 'default:stone'},
- {'default:stone', 'technic:lv_cable0', 'default:stone'},
+ {'default:stone', 'technic:lv_cable', 'default:stone'},
}
})
diff --git a/technic/machines/LV/geothermal.lua b/technic/machines/LV/geothermal.lua
index e88d3c9..27f4abc 100644
--- a/technic/machines/LV/geothermal.lua
+++ b/technic/machines/LV/geothermal.lua
@@ -10,9 +10,9 @@ local S = technic.getter
minetest.register_craft({
output = 'technic:geothermal',
recipe = {
- {'technic:granite', 'default:diamond', 'technic:granite'},
+ {'technic:granite', 'default:diamond', 'technic:granite'},
{'technic:fine_copper_wire', 'technic:machine_casing', 'technic:fine_copper_wire'},
- {'technic:granite', 'technic:lv_cable0', 'technic:granite'},
+ {'technic:granite', 'technic:lv_cable', 'technic:granite'},
}
})
@@ -82,8 +82,9 @@ minetest.register_node("technic:geothermal", {
description = S("Geothermal %s Generator"):format("LV"),
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"},
+ groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ technic_machine=1, technic_lv=1},
paramtype2 = "facedir",
- groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
@@ -99,7 +100,8 @@ minetest.register_node("technic:geothermal_active", {
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},
+ groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ technic_machine=1, technic_lv=1, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop = "technic:geothermal",
diff --git a/technic/machines/LV/grinder.lua b/technic/machines/LV/grinder.lua
index da9ea29..9e45bf4 100644
--- a/technic/machines/LV/grinder.lua
+++ b/technic/machines/LV/grinder.lua
@@ -5,7 +5,7 @@ minetest.register_craft({
recipe = {
{'default:desert_stone', 'default:diamond', 'default:desert_stone'},
{'default:desert_stone', 'technic:machine_casing', 'default:desert_stone'},
- {'technic:granite', 'technic:lv_cable0', 'technic:granite'},
+ {'technic:granite', 'technic:lv_cable', 'technic:granite'},
}
})
diff --git a/technic/machines/LV/music_player.lua b/technic/machines/LV/music_player.lua
index dc7e2d0..262fe5f 100644
--- a/technic/machines/LV/music_player.lua
+++ b/technic/machines/LV/music_player.lua
@@ -9,7 +9,7 @@ minetest.register_craft({
recipe = {
{'technic:chromium_ingot', 'default:diamond', 'technic:chromium_ingot'},
{'default:diamond', 'technic:machine_casing', 'default:diamond'},
- {'default:mossycobble', 'technic:lv_cable0', 'default:mossycobble'},
+ {'default:mossycobble', 'technic:lv_cable', 'default:mossycobble'},
}
})
@@ -94,7 +94,9 @@ minetest.register_node("technic:music_player", {
description = S("%s Music Player"):format("LV"),
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, technic_machine=1},
+ groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ technic_machine=1, technic_lv=1},
+ connect_sides = {"bottom"},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
diff --git a/technic/machines/LV/solar_array.lua b/technic/machines/LV/solar_array.lua
index 4d2c3b3..8c1b8f4 100644
--- a/technic/machines/LV/solar_array.lua
+++ b/technic/machines/LV/solar_array.lua
@@ -10,7 +10,7 @@ minetest.register_craft({
recipe = {
{'technic:solar_panel', 'technic:solar_panel', 'technic:solar_panel'},
{'technic:carbon_steel_ingot', 'technic:lv_transformer', 'technic:carbon_steel_ingot'},
- {'', 'technic:lv_cable0', ''},
+ {'', 'technic:lv_cable', ''},
}
})
diff --git a/technic/machines/LV/solar_panel.lua b/technic/machines/LV/solar_panel.lua
index 41dff95..a06ddb8 100644
--- a/technic/machines/LV/solar_panel.lua
+++ b/technic/machines/LV/solar_panel.lua
@@ -4,6 +4,17 @@
local S = technic.getter
+
+minetest.register_craft({
+ output = 'technic:solar_panel',
+ recipe = {
+ {'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'},
+ {'technic:fine_silver_wire', 'technic:lv_cable', 'mesecons_materials:glue'},
+
+ }
+})
+
+
local run = function(pos, node)
-- The action here is to make the solar panel prodice power
-- Power is dependent on the light level and the height above ground
@@ -24,7 +35,7 @@ local run = function(pos, node)
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", S("@1 Active (@2 EU)", machine_name, technic.prettynum(charge_to_give)))
+ meta:set_string("infotext", S("@1 Active (@2 EU)", machine_name, technic.pretty_num(charge_to_give)))
meta:set_int("LV_EU_supply", charge_to_give)
else
meta:set_string("infotext", S("%s Idle"):format(machine_name))
@@ -35,7 +46,9 @@ end
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, technic_machine=1},
+ groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ technic_machine=1, technic_lv=1},
+ connect_sides = {"bottom"},
sounds = default.node_sound_wood_defaults(),
description = S("Small Solar %s Generator"):format("LV"),
active = false,
@@ -54,14 +67,5 @@ minetest.register_node("technic:solar_panel", {
technic_run = run,
})
-minetest.register_craft({
- output = 'technic:solar_panel',
- recipe = {
- {'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'},
- {'technic:fine_silver_wire', 'technic:lv_cable0', 'mesecons_materials:glue'},
-
- }
-})
-
technic.register_machine("LV", "technic:solar_panel", technic.producer)
diff --git a/technic/machines/LV/water_mill.lua b/technic/machines/LV/water_mill.lua
index 9088d1d..acb778c 100644
--- a/technic/machines/LV/water_mill.lua
+++ b/technic/machines/LV/water_mill.lua
@@ -11,25 +11,27 @@ minetest.register_craft({
recipe = {
{'technic:marble', 'default:diamond', 'technic:marble'},
{'group:wood', 'technic:machine_casing', 'group:wood'},
- {'technic:marble', 'technic:lv_cable0', 'technic:marble'},
+ {'technic:marble', 'technic:lv_cable', 'technic:marble'},
}
})
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
+ if node.name == "default:water_flowing"
+ or node.name == "default:river_water_flowing" then
+ return node.param2 -- returns approx. water flow, if any
end
return false
end
local run = function(pos, node)
local meta = minetest.get_meta(pos)
- local water_nodes = 0
+ local water_flow = 0
local lava_nodes = 0
local production_level = 0
local eu_supply = 0
+ local max_output = 35 * 45 -- four param2's at 15 makes 60, cap it lower for "overload protection"
+ -- (plus we want the gen to report 100% if three sides have full flow)
local positions = {
{x=pos.x+1, y=pos.y, z=pos.z},
@@ -41,12 +43,12 @@ local run = function(pos, node)
for _, p in pairs(positions) do
local check = check_node_around_mill(p)
if check then
- water_nodes = water_nodes + 1
+ water_flow = water_flow + check
end
end
- production_level = 25 * water_nodes
- eu_supply = 30 * water_nodes
+ eu_supply = math.min(35 * water_flow, max_output)
+ production_level = math.floor(100 * eu_supply / max_output)
if production_level > 0 then
meta:set_int("LV_EU_supply", eu_supply)
@@ -72,7 +74,8 @@ minetest.register_node("technic:water_mill", {
"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, technic_machine=1},
+ groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ technic_machine=1, technic_lv=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
@@ -89,7 +92,8 @@ minetest.register_node("technic:water_mill_active", {
"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, technic_machine=1, not_in_creative_inventory=1},
+ groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ technic_machine=1, technic_lv=1, not_in_creative_inventory=1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
drop = "technic:water_mill",
diff --git a/technic/machines/MV/alloy_furnace.lua b/technic/machines/MV/alloy_furnace.lua
index a1918fd..eaddee0 100644
--- a/technic/machines/MV/alloy_furnace.lua
+++ b/technic/machines/MV/alloy_furnace.lua
@@ -5,7 +5,7 @@ minetest.register_craft({
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_alloy_furnace', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
- {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
+ {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
}
})
diff --git a/technic/machines/MV/battery_box.lua b/technic/machines/MV/battery_box.lua
index 45437c1..d84ec15 100644
--- a/technic/machines/MV/battery_box.lua
+++ b/technic/machines/MV/battery_box.lua
@@ -5,7 +5,7 @@ minetest.register_craft({
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:mv_cable', ''},
}
})
diff --git a/technic/machines/MV/cables.lua b/technic/machines/MV/cables.lua
index b1a34c8..0c1f457 100644
--- a/technic/machines/MV/cables.lua
+++ b/technic/machines/MV/cables.lua
@@ -1,12 +1,12 @@
-minetest.register_alias("mv_cable", "technic:mv_cable0")
+minetest.register_alias("mv_cable", "technic:mv_cable")
minetest.register_craft({
- output = 'technic:mv_cable0 3',
+ output = 'technic:mv_cable 3',
recipe ={
- {'technic:rubber', 'technic:rubber', 'technic:rubber'},
- {'technic:lv_cable0', 'technic:lv_cable0', 'technic:lv_cable0'},
- {'technic:rubber', 'technic:rubber', 'technic:rubber'},
+ {'technic:rubber', 'technic:rubber', 'technic:rubber'},
+ {'technic:lv_cable', 'technic:lv_cable', 'technic:lv_cable'},
+ {'technic:rubber', 'technic:rubber', 'technic:rubber'},
}
})
diff --git a/technic/machines/MV/centrifuge.lua b/technic/machines/MV/centrifuge.lua
index 5bf24bf..a0aad64 100644
--- a/technic/machines/MV/centrifuge.lua
+++ b/technic/machines/MV/centrifuge.lua
@@ -1,9 +1,9 @@
minetest.register_craft({
output = "technic:mv_centrifuge",
recipe = {
- { "technic:motor", "technic:copper_plate", "technic:diamond_drill_head" },
- { "technic:copper_plate", "technic:machine_casing", "technic:copper_plate" },
- { "pipeworks:one_way_tube", "technic:mv_cable0", "pipeworks:mese_filter" },
+ {"technic:motor", "technic:copper_plate", "technic:diamond_drill_head"},
+ {"technic:copper_plate", "technic:machine_casing", "technic:copper_plate" },
+ {"pipeworks:one_way_tube", "technic:mv_cable", "pipeworks:mese_filter" },
}
})
diff --git a/technic/machines/MV/compressor.lua b/technic/machines/MV/compressor.lua
index 5b36cc5..d97739e 100644
--- a/technic/machines/MV/compressor.lua
+++ b/technic/machines/MV/compressor.lua
@@ -5,7 +5,7 @@ minetest.register_craft({
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_compressor', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
- {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
+ {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
}
})
diff --git a/technic/machines/MV/electric_furnace.lua b/technic/machines/MV/electric_furnace.lua
index 1f6b1c2..b1d2dee 100644
--- a/technic/machines/MV/electric_furnace.lua
+++ b/technic/machines/MV/electric_furnace.lua
@@ -9,8 +9,8 @@ minetest.register_craft({
output = 'technic:mv_electric_furnace',
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_electric_furnace', 'technic:stainless_steel_ingot'},
- {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
- {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
+ {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
+ {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
}
})
diff --git a/technic/machines/MV/extractor.lua b/technic/machines/MV/extractor.lua
index fdef5b2..9066bca 100644
--- a/technic/machines/MV/extractor.lua
+++ b/technic/machines/MV/extractor.lua
@@ -5,7 +5,7 @@ minetest.register_craft({
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_extractor', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
- {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
+ {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
}
})
diff --git a/technic/machines/MV/generator.lua b/technic/machines/MV/generator.lua
index 4ae24b8..db9d59f 100644
--- a/technic/machines/MV/generator.lua
+++ b/technic/machines/MV/generator.lua
@@ -5,7 +5,7 @@ minetest.register_craft({
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_generator', 'technic:stainless_steel_ingot'},
{'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
- {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
+ {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
}
})
diff --git a/technic/machines/MV/grinder.lua b/technic/machines/MV/grinder.lua
index dac536c..19ab372 100644
--- a/technic/machines/MV/grinder.lua
+++ b/technic/machines/MV/grinder.lua
@@ -4,8 +4,8 @@ minetest.register_craft({
output = 'technic:mv_grinder',
recipe = {
{'technic:stainless_steel_ingot', 'technic:lv_grinder', 'technic:stainless_steel_ingot'},
- {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
- {'technic:stainless_steel_ingot', 'technic:mv_cable0', 'technic:stainless_steel_ingot'},
+ {'pipeworks:tube_1', 'technic:mv_transformer', 'pipeworks:tube_1'},
+ {'technic:stainless_steel_ingot', 'technic:mv_cable', 'technic:stainless_steel_ingot'},
}
})
diff --git a/technic/machines/MV/power_radiator.lua b/technic/machines/MV/power_radiator.lua
index 560f8a9..9349e66 100644
--- a/technic/machines/MV/power_radiator.lua
+++ b/technic/machines/MV/power_radiator.lua
@@ -12,6 +12,16 @@
local power_radius = 12
+
+minetest.register_craft({
+ output = 'technic:power_radiator 1',
+ recipe = {
+ {'technic:stainless_steel_ingot', 'technic:mv_transformer', 'technic:stainless_steel_ingot'},
+ {'technic:copper_coil', 'technic:machine_casing', 'technic:copper_coil'},
+ {'technic:rubber', 'technic:mv_cable', 'technic:rubber'},
+ }
+})
+
------------------------------------------------------------------
-- API for inductive powered nodes:
-- Use the functions below to set the corresponding callbacks
@@ -135,15 +145,6 @@ minetest.register_node("technic:power_radiator", {
end
})
-minetest.register_craft({
- output = 'technic:power_radiator 1',
- recipe = {
- {'technic:stainless_steel_ingot', 'technic:mv_transformer', 'technic:stainless_steel_ingot'},
- {'technic:copper_coil', 'technic:machine_casing', 'technic:copper_coil'},
- {'technic:rubber', 'technic:mv_cable0', 'technic:rubber'},
- }
-})
-
minetest.register_abm({
nodenames = {"technic:power_radiator"},
interval = 1,
diff --git a/technic/machines/MV/solar_array.lua b/technic/machines/MV/solar_array.lua
index 227d8ee..4077a5c 100644
--- a/technic/machines/MV/solar_array.lua
+++ b/technic/machines/MV/solar_array.lua
@@ -4,7 +4,7 @@ minetest.register_craft({
recipe = {
{'technic:solar_array_lv', 'technic:solar_array_lv', 'technic:solar_array_lv'},
{'technic:carbon_steel_ingot', 'technic:mv_transformer', 'technic:carbon_steel_ingot'},
- {'', 'technic:mv_cable0', ''},
+ {'', 'technic:mv_cable', ''},
}
})
diff --git a/technic/machines/MV/tool_workshop.lua b/technic/machines/MV/tool_workshop.lua
index 318b1ec..4076cc1 100644
--- a/technic/machines/MV/tool_workshop.lua
+++ b/technic/machines/MV/tool_workshop.lua
@@ -10,7 +10,7 @@ minetest.register_craft({
recipe = {
{'group:wood', 'default:diamond', 'group:wood'},
{'mesecons_pistons:piston_sticky_off', 'technic:machine_casing', 'technic:carbon_cloth'},
- {'default:obsidian', 'technic:mv_cable0', 'default:obsidian'},
+ {'default:obsidian', 'technic:mv_cable', 'default:obsidian'},
}
})
@@ -85,7 +85,9 @@ minetest.register_node("technic:tool_workshop", {
paramtype2 = "facedir",
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, technic_machine=1, tubedevice=1, tubedevice_receiver=1},
+ groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ technic_machine=1, technic_mv=1, tubedevice=1, tubedevice_receiver=1},
+ connect_sides = {"bottom", "back", "left", "right"},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
diff --git a/technic/machines/MV/wind_mill.lua b/technic/machines/MV/wind_mill.lua
index c553051..28a075d 100644
--- a/technic/machines/MV/wind_mill.lua
+++ b/technic/machines/MV/wind_mill.lua
@@ -15,7 +15,7 @@ minetest.register_craft({
recipe = {
{'', 'technic:motor', ''},
{'technic:carbon_steel_ingot', 'technic:carbon_steel_block', 'technic:carbon_steel_ingot'},
- {'', 'technic:mv_cable0', ''},
+ {'', 'technic:mv_cable', ''},
}
})
@@ -33,8 +33,15 @@ local function check_wind_mill(pos)
if pos.y < 30 then
return false
end
+ pos = {x=pos.x, y=pos.y, z=pos.z}
for i = 1, 20 do
- local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z})
+ pos.y = pos.y - 1
+ local node = minetest.get_node_or_nil(pos)
+ if not node then
+ -- we reached CONTENT_IGNORE, we can assume, that nothing changed
+ -- as the user will have to load the block to change it
+ return
+ end
if node.name ~= "technic:wind_mill_frame" then
return false
end
@@ -45,24 +52,25 @@ end
local run = function(pos, node)
local meta = minetest.get_meta(pos)
local machine_name = S("Wind %s Generator"):format("MV")
- local power = math.min(pos.y * 100, 5000)
- if not check_wind_mill(pos) then
+ local check = check_wind_mill(pos)
+ if check == false then
meta:set_int("MV_EU_supply", 0)
meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name))
- return
- else
+ elseif check == true then
+ local power = math.min(pos.y * 100, 5000)
meta:set_int("MV_EU_supply", power)
+ meta:set_string("infotext", S("@1 (@2 EU)", machine_name, technic.pretty_num(power)))
end
-
- meta:set_string("infotext", S("@1 (@2 EU)", machine_name, technic.prettynum(power)))
+ -- check == nil: assume nothing has changed
end
minetest.register_node("technic:wind_mill", {
description = S("Wind %s Generator"):format("MV"),
tiles = {"technic_carbon_steel_block.png"},
paramtype2 = "facedir",
- groups = {cracky=1, technic_machine=1},
+ groups = {cracky=1, technic_machine=1, technic_mv=1},
+ connect_sides = {"top", "bottom", "back", "left", "right"},
sounds = default.node_sound_stone_defaults(),
drawtype = "nodebox",
paramtype = "light",
diff --git a/technic/machines/other/frames.lua b/technic/machines/other/frames.lua
index b3f39b9..2d630a2 100644
--- a/technic/machines/other/frames.lua
+++ b/technic/machines/other/frames.lua
@@ -320,7 +320,7 @@ local nodeboxes= {
else
--local pointed_thing = {type = "node", under = pos}
if pointed_thing then
- minetest.item_place_node(itemstack, placer, pointed_thing)
+ return minetest.item_place_node(itemstack, placer, pointed_thing)
end
end
end,
diff --git a/technic/machines/register/battery_box.lua b/technic/machines/register/battery_box.lua
index 82edca0..953f7af 100644
--- a/technic/machines/register/battery_box.lua
+++ b/technic/machines/register/battery_box.lua
@@ -151,7 +151,7 @@ function technic.register_battery_box(data)
..":technic_power_meter_fg.png]")
local infotext = S("@1 Battery Box: @2/@3", tier,
- technic.prettynum(current_charge), technic.prettynum(max_charge))
+ technic.pretty_num(current_charge), technic.pretty_num(max_charge))
if eu_input == 0 then
infotext = S("%s Idle"):format(infotext)
end
@@ -159,7 +159,8 @@ function technic.register_battery_box(data)
end
for i = 0, 8 do
- local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}
+ local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ technic_machine=1, ["technic_"..ltier]=1}
if i ~= 0 then
groups.not_in_creative_inventory = 1
end
@@ -178,6 +179,7 @@ function technic.register_battery_box(data)
"technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png",
"technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png"},
groups = groups,
+ connect_sides = {"bottom"},
tube = data.tube and tube or nil,
paramtype2 = "facedir",
sounds = default.node_sound_wood_defaults(),
diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua
index a1e7bc8..a7e72a3 100644
--- a/technic/machines/register/cables.lua
+++ b/technic/machines/register/cables.lua
@@ -1,177 +1,76 @@
local S = technic.getter
-local cable_itstr_to_tier = {}
+local cable_tier = {}
-function technic.register_cable(tier, size)
- local ltier = string.lower(tier)
-
- for x1 = 0, 1 do
- for x2 = 0, 1 do
- for y1 = 0, 1 do
- for y2 = 0, 1 do
- for z1 = 0, 1 do
- for z2 = 0, 1 do
- local id = technic.get_cable_id({x1, x2, y1, y2, z1, z2})
-
- cable_itstr_to_tier["technic:"..ltier.."_cable"..id] = tier
-
- local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}
- if id ~= 0 then
- groups.not_in_creative_inventory = 1
- end
-
- minetest.register_node("technic:"..ltier.."_cable"..id, {
- description = S("%s Cable"):format(tier),
- tiles = {"technic_"..ltier.."_cable.png"},
- inventory_image = "technic_"..ltier.."_cable_wield.png",
- wield_image = "technic_"..ltier.."_cable_wield.png",
- groups = groups,
- sounds = default.node_sound_wood_defaults(),
- drop = "technic:"..ltier.."_cable0",
- paramtype = "light",
- sunlight_propagates = true,
- drawtype = "nodebox",
- node_box = {
- type = "fixed",
- fixed = technic.gen_cable_nodebox(x1, y1, z1, x2, y2, z2, size)
- },
- on_construct = function()
- technic.networks = {}
- end,
- on_destruct = function()
- technic.networks = {}
- end,
- after_place_node = function(pos)
- local node = minetest.get_node(pos)
- technic.update_cables(pos, technic.get_cable_tier(node.name))
- end,
- after_dig_node = function(pos, oldnode)
- local tier = technic.get_cable_tier(oldnode.name)
- technic.update_cables(pos, tier, true)
- end
- })
- end
- end
- end
- end
- end
- end
+function technic.is_tier_cable(name, tier)
+ return cable_tier[name] == tier
end
-minetest.register_on_placenode(function(pos, node)
- for tier, machine_list in pairs(technic.machines) do
- if machine_list[node.name] ~= nil then
- technic.update_cables(pos, tier, true)
- technic.networks = {}
- end
- end
-end)
-
-
-minetest.register_on_dignode(function(pos, node)
- for tier, machine_list in pairs(technic.machines) do
- if machine_list[node.name] ~= nil then
- technic.update_cables(pos, tier, true)
- technic.networks = {}
- end
- end
-end)
-
-function technic.get_cable_id(links)
- return (links[6] * 1) + (links[5] * 2)
- + (links[4] * 4) + (links[3] * 8)
- + (links[2] * 16) + (links[1] * 32)
+function technic.get_cable_tier(name)
+ return cable_tier[name]
end
-function technic.update_cables(pos, tier, no_set, secondrun)
- local link_positions = {
+local function clear_networks(pos)
+ 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+1, z=pos.z},
{x=pos.x, y=pos.y-1, z=pos.z},
{x=pos.x, y=pos.y, z=pos.z+1},
{x=pos.x, y=pos.y, z=pos.z-1}}
-
- local links = {0, 0, 0, 0, 0, 0}
-
- for i, link_pos in pairs(link_positions) do
- local connect_type = technic.cables_should_connect(pos, link_pos, tier)
- if connect_type then
- links[i] = 1
- -- Have cables next to us update theirselves,
- -- but only once. (We don't want to update the entire
- -- network or start an infinite loop of updates)
- if not secondrun and connect_type == "cable" then
- technic.update_cables(link_pos, tier, false, true)
- end
+ for _,connected_pos in pairs(positions) do
+ if technic.cables[minetest.hash_node_position(connected_pos)] then
+ technic.networks[technic.cables[minetest.hash_node_position(connected_pos)]] = nil
end
end
- -- We don't want to set ourselves if we have been removed or we are
- -- updating a machine
- if not no_set then
- minetest.set_node(pos, {name="technic:"..string.lower(tier)
- .."_cable"..technic.get_cable_id(links)})
-
- end
end
-
-function technic.is_tier_cable(name, tier)
- return cable_itstr_to_tier[name] and cable_itstr_to_tier[name] == tier
-end
-
-
-function technic.get_cable_tier(name)
- return cable_itstr_to_tier[name]
+function technic.register_cable(tier, size)
+ local ltier = string.lower(tier)
+ cable_tier["technic:"..ltier.."_cable"] = tier
+
+ local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}
+
+ local node_box = {
+ type = "connected",
+ fixed = {-size, -size, -size, size, size, size},
+ connect_top = {-size, -size, -size, size, 0.5, size}, -- y+
+ connect_bottom = {-size, -0.5, -size, size, size, size}, -- y-
+ connect_front = {-size, -size, -0.5, size, size, size}, -- z-
+ connect_back = {-size, -size, size, size, size, 0.5 }, -- z+
+ connect_left = {-0.5, -size, -size, size, size, size}, -- x-
+ connect_right = {-size, -size, -size, 0.5, size, size}, -- x+
+ }
+
+ minetest.register_node("technic:"..ltier.."_cable", {
+ description = S("%s Cable"):format(tier),
+ tiles = {"technic_"..ltier.."_cable.png"},
+ inventory_image = "technic_"..ltier.."_cable_wield.png",
+ wield_image = "technic_"..ltier.."_cable_wield.png",
+ groups = groups,
+ sounds = default.node_sound_wood_defaults(),
+ drop = "technic:"..ltier.."_cable",
+ paramtype = "light",
+ sunlight_propagates = true,
+ drawtype = "nodebox",
+ node_box = node_box,
+ connects_to = {"technic:"..ltier.."_cable",
+ "group:technic_"..ltier, "group:technic_all_tiers"},
+ on_construct = clear_networks,
+ on_destruct = clear_networks,
+ })
end
-function technic.cables_should_connect(pos1, pos2, tier)
- local name = minetest.get_node(pos2).name
-
- if name == "technic:switching_station" then
- return pos2.y == pos1.y + 1 and "machine" or false
- elseif name == "technic:supply_converter" then
- return math.abs(pos2.y - pos1.y) == 1 and "machine" or false
- elseif technic.is_tier_cable(name, tier) then
- return "cable"
- elseif technic.machines[tier][name] then
- return "machine"
+local function clear_nets_if_machine(pos, node)
+ for tier, machine_list in pairs(technic.machines) do
+ if machine_list[node.name] ~= nil then
+ return clear_networks(pos)
+ end
end
- return false
end
-
-function technic.gen_cable_nodebox(x1, y1, z1, x2, y2, z2, size)
- -- Nodeboxes
- local box_center = {-size, -size, -size, size, size, size}
- local box_y1 = {-size, -size, -size, size, 0.5, size} -- y+
- local box_x1 = {-size, -size, -size, 0.5, size, size} -- x+
- local box_z1 = {-size, -size, size, size, size, 0.5} -- z+
- local box_z2 = {-size, -size, -0.5, size, size, size} -- z-
- local box_y2 = {-size, -0.5, -size, size, size, size} -- y-
- local box_x2 = {-0.5, -size, -size, size, size, size} -- x-
-
- local box = {box_center}
- if x1 == 1 then
- table.insert(box, box_x1)
- end
- if y1 == 1 then
- table.insert(box, box_y1)
- end
- if z1 == 1 then
- table.insert(box, box_z1)
- end
- if x2 == 1 then
- table.insert(box, box_x2)
- end
- if y2 == 1 then
- table.insert(box, box_y2)
- end
- if z2 == 1 then
- table.insert(box, box_z2)
- end
- return box
-end
+minetest.register_on_placenode(clear_nets_if_machine)
+minetest.register_on_dignode(clear_nets_if_machine)
diff --git a/technic/machines/register/centrifuge_recipes.lua b/technic/machines/register/centrifuge_recipes.lua
index 05642f5..b4db47c 100644
--- a/technic/machines/register/centrifuge_recipes.lua
+++ b/technic/machines/register/centrifuge_recipes.lua
@@ -14,6 +14,7 @@ local recipes = {
{ "technic:bronze_dust 4", "technic:copper_dust 3", "technic:tin_dust" },
{ "technic:stainless_steel_dust 4", "technic:wrought_iron_dust 3", "technic:chromium_dust" },
{ "technic:brass_dust 3", "technic:copper_dust 2", "technic:zinc_dust" },
+ { "default:dirt 4", "default:sand", "default:gravel", "default:clay_lump 2" },
}
local function uranium_dust(p)
@@ -34,5 +35,5 @@ if minetest.get_modpath("farming") then
end
for _, data in pairs(recipes) do
- technic.register_separating_recipe({ input = { data[1] }, output = { data[2], data[3] } })
+ technic.register_separating_recipe({ input = { data[1] }, output = { data[2], data[3], data[4] } })
end
diff --git a/technic/machines/register/common.lua b/technic/machines/register/common.lua
index ce0eee6..dfa2948 100644
--- a/technic/machines/register/common.lua
+++ b/technic/machines/register/common.lua
@@ -157,13 +157,13 @@ function technic.machine_after_dig_node(pos, oldnode, oldmetadata, player)
if oldmetadata.inventory.upgrade1 and oldmetadata.inventory.upgrade1[1] then
local stack = ItemStack(oldmetadata.inventory.upgrade1[1])
if not stack:is_empty() then
- minetest.item_drop(stack, "", pos)
+ minetest.add_item(pos, stack)
end
end
if oldmetadata.inventory.upgrade2 and oldmetadata.inventory.upgrade2[1] then
local stack = ItemStack(oldmetadata.inventory.upgrade2[1])
if not stack:is_empty() then
- minetest.item_drop(stack, "", pos)
+ minetest.add_item(pos, stack)
end
end
end
diff --git a/technic/machines/register/generator.lua b/technic/machines/register/generator.lua
index 31c1cef..2cdc336 100644
--- a/technic/machines/register/generator.lua
+++ b/technic/machines/register/generator.lua
@@ -18,14 +18,14 @@ function technic.register_generator(data)
local tier = data.tier
local ltier = string.lower(tier)
- local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}
- local active_groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1, not_in_creative_inventory=1}
+ local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ technic_machine=1, ["technic_"..ltier]=1}
if data.tube then
groups.tubedevice = 1
groups.tubedevice_receiver = 1
- active_groups.tubedevice = 1
- active_groups.tubedevice_receiver = 1
end
+ local active_groups = {not_in_creative_inventory = 1}
+ for k, v in pairs(groups) do active_groups[k] = v end
local generator_formspec =
"invsize[8,9;]"..
@@ -93,6 +93,7 @@ function technic.register_generator(data)
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front.png"},
paramtype2 = "facedir",
groups = groups,
+ connect_sides = {"bottom", "back", "left", "right"},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
tube = data.tube and tube or nil,
@@ -122,6 +123,7 @@ function technic.register_generator(data)
"technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front_active.png"},
paramtype2 = "facedir",
groups = active_groups,
+ connect_sides = {"bottom"},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
tube = data.tube and tube or nil,
diff --git a/technic/machines/register/grinder_recipes.lua b/technic/machines/register/grinder_recipes.lua
index 87c6ade..7eaa7d4 100644
--- a/technic/machines/register/grinder_recipes.lua
+++ b/technic/machines/register/grinder_recipes.lua
@@ -20,11 +20,12 @@ local recipes = {
{"technic:zinc_lump", "technic:zinc_dust 2"},
{"technic:lead_lump", "technic:lead_dust 2"},
{"technic:sulfur_lump", "technic:sulfur_dust 2"},
+ {"default:stone", "technic:stone_dust"},
+ {"default:sand", "technic:stone_dust"},
-- Other
{"default:cobble", "default:gravel"},
- {"default:gravel", "default:dirt"},
- {"default:stone", "default:sand"},
+ {"default:gravel", "default:sand"},
{"default:sandstone", "default:sand 2"}, -- reverse recipe can be found in the compressor
}
@@ -103,6 +104,7 @@ register_dust("Sulfur", nil)
register_dust("Tin", "moreores:tin_ingot")
register_dust("Wrought Iron", "technic:wrought_iron_ingot")
register_dust("Zinc", "technic:zinc_ingot")
+register_dust("Stone", "default:stone")
if minetest.get_modpath("gloopores") or minetest.get_modpath("glooptest") then
register_dust("Akalin", "glooptest:akalin_ingot")
register_dust("Alatro", "glooptest:alatro_ingot")
diff --git a/technic/machines/register/machine_base.lua b/technic/machines/register/machine_base.lua
index 0c46261..8cf851b 100644
--- a/technic/machines/register/machine_base.lua
+++ b/technic/machines/register/machine_base.lua
@@ -15,6 +15,8 @@ local tube = {
connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
}
+local connect_default = {"bottom", "back", "left", "right"}
+
local function round(v)
return math.floor(v + 0.5)
end
@@ -27,15 +29,13 @@ function technic.register_base_machine(data)
local tier = data.tier
local ltier = string.lower(tier)
- local groups = {cracky = 2, technic_machine = 1}
- local active_groups = {cracky = 2, technic_machine = 1, not_in_creative_inventory = 1}
+ local groups = {cracky = 2, technic_machine = 1, ["technic_"..ltier] = 1}
if data.tube then
groups.tubedevice = 1
groups.tubedevice_receiver = 1
- active_groups.tubedevice = 1
- active_groups.tubedevice_receiver = 1
end
-
+ local active_groups = {not_in_creative_inventory = 1}
+ for k, v in pairs(groups) do active_groups[k] = v end
local formspec =
"invsize[8,9;]"..
@@ -145,6 +145,7 @@ function technic.register_base_machine(data)
paramtype2 = "facedir",
groups = groups,
tube = data.tube and tube or nil,
+ connect_sides = data.connect_sides or connect_default,
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
@@ -179,6 +180,7 @@ function technic.register_base_machine(data)
paramtype2 = "facedir",
drop = "technic:"..ltier.."_"..machine_name,
groups = active_groups,
+ connect_sides = data.connect_sides or connect_default,
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
tube = data.tube and tube or nil,
diff --git a/technic/machines/register/solar_array.lua b/technic/machines/register/solar_array.lua
index 39f50d2..422bfcf 100644
--- a/technic/machines/register/solar_array.lua
+++ b/technic/machines/register/solar_array.lua
@@ -30,7 +30,7 @@ function technic.register_solar_array(data)
local charge_to_give = math.floor((light + pos.y) * data.power)
charge_to_give = math.max(charge_to_give, 0)
charge_to_give = math.min(charge_to_give, data.power * 50)
- meta:set_string("infotext", S("@1 Active (@2 EU)", machine_name, technic.prettynum(charge_to_give)))
+ meta:set_string("infotext", S("@1 Active (@2 EU)", machine_name, technic.pretty_num(charge_to_give)))
meta:set_int(tier.."_EU_supply", charge_to_give)
else
meta:set_string("infotext", S("%s Idle"):format(machine_name))
@@ -42,7 +42,8 @@ function technic.register_solar_array(data)
tiles = {"technic_"..ltier.."_solar_array_top.png", "technic_"..ltier.."_solar_array_bottom.png",
"technic_"..ltier.."_solar_array_side.png", "technic_"..ltier.."_solar_array_side.png",
"technic_"..ltier.."_solar_array_side.png", "technic_"..ltier.."_solar_array_side.png"},
- groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
+ groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1, ["technic_"..ltier]=1},
+ connect_sides = {"bottom"},
sounds = default.node_sound_wood_defaults(),
description = S("Arrayed Solar %s Generator"):format(tier),
active = false,
diff --git a/technic/machines/supply_converter.lua b/technic/machines/supply_converter.lua
index ffcd40d..a88651b 100644
--- a/technic/machines/supply_converter.lua
+++ b/technic/machines/supply_converter.lua
@@ -30,7 +30,7 @@ local run = function(pos, node)
meta:set_int(from.."_EU_supply", 0)
meta:set_int(to.."_EU_demand", 0)
meta:set_int(to.."_EU_supply", input * remain)
- meta:set_string("infotext", S("@1 (@2 @3 -> @4 @5)", machine_name, technic.prettynum(input), from, technic.prettynum(input * remain), to))
+ meta:set_string("infotext", S("@1 (@2 @3 -> @4 @5)", machine_name, technic.pretty_num(input), from, technic.pretty_num(input * remain), to))
else
meta:set_string("infotext", S("%s Has Bad Cabling"):format(machine_name))
if to then
@@ -49,28 +49,25 @@ minetest.register_node("technic:supply_converter", {
tiles = {"technic_supply_converter_top.png", "technic_supply_converter_bottom.png",
"technic_supply_converter_side.png", "technic_supply_converter_side.png",
"technic_supply_converter_side.png", "technic_supply_converter_side.png"},
- groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
+ groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ technic_machine=1, technic_all_tiers=1},
+ connect_sides = {"top", "bottom"},
sounds = default.node_sound_wood_defaults(),
- drawtype = "nodebox",
- paramtype = "light",
- 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_string("infotext", S("Supply Converter"))
meta:set_float("active", false)
end,
technic_run = run,
+ technic_on_disable = run,
})
minetest.register_craft({
output = 'technic:supply_converter 1',
recipe = {
- {'technic:fine_gold_wire', 'technic:rubber', 'technic:doped_silicon_wafer'},
- {'technic:mv_transformer', 'technic:machine_casing', 'technic:lv_transformer'},
- {'technic:mv_cable0', 'technic:rubber', 'technic:lv_cable0'},
+ {'technic:fine_gold_wire', 'technic:rubber', 'technic:doped_silicon_wafer'},
+ {'technic:mv_transformer', 'technic:machine_casing', 'technic:lv_transformer'},
+ {'technic:mv_cable', 'technic:rubber', 'technic:lv_cable'},
}
})
diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua
index d6f23a3..2051acf 100644
--- a/technic/machines/switching_station.lua
+++ b/technic/machines/switching_station.lua
@@ -32,15 +32,16 @@
-- This way the supplies are separated per network.
technic.networks = {}
+technic.cables = {}
local S = technic.getter
minetest.register_craft({
output = "technic:switching_station",
recipe = {
- {"", "technic:lv_transformer", ""},
- {"default:copper_ingot", "technic:machine_casing", "default:copper_ingot"},
- {"technic:lv_cable0", "technic:lv_cable0", "technic:lv_cable0"}
+ {"", "technic:lv_transformer", ""},
+ {"default:copper_ingot", "technic:machine_casing", "default:copper_ingot"},
+ {"technic:lv_cable", "technic:lv_cable", "technic:lv_cable"}
}
})
@@ -49,14 +50,9 @@ minetest.register_node("technic:switching_station",{
tiles = {"technic_water_mill_top_active.png", "technic_water_mill_top_active.png",
"technic_water_mill_top_active.png", "technic_water_mill_top_active.png",
"technic_water_mill_top_active.png", "technic_water_mill_top_active.png"},
- groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
+ groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_all_tiers=1},
+ connect_sides = {"bottom"},
sounds = default.node_sound_wood_defaults(),
- drawtype = "nodebox",
- paramtype = "light",
- 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_string("infotext", S("Switching Station"))
@@ -69,7 +65,8 @@ minetest.register_node("technic:switching_station",{
--------------------------------------------------
-- Add a wire node to the LV/MV/HV network
-local add_new_cable_node = function(nodes, pos)
+local add_new_cable_node = function(nodes, pos, network_id)
+ technic.cables[minetest.hash_node_position(pos)] = network_id
-- Ignore if the node has already been added
for i = 1, #nodes do
if pos.x == nodes[i].x and
@@ -83,31 +80,31 @@ local add_new_cable_node = function(nodes, pos)
end
-- Generic function to add found connected nodes to the right classification array
-local check_node_subp = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, pos, machines, tier, sw_pos, from_below)
+local check_node_subp = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, pos, machines, tier, sw_pos, from_below, network_id)
technic.get_or_load_node(pos)
local meta = minetest.get_meta(pos)
local name = minetest.get_node(pos).name
if technic.is_tier_cable(name, tier) then
- add_new_cable_node(all_nodes, pos)
+ add_new_cable_node(all_nodes, pos,network_id)
elseif machines[name] then
--dprint(name.." is a "..machines[name])
if machines[name] == technic.producer then
- add_new_cable_node(PR_nodes, pos)
+ add_new_cable_node(PR_nodes, pos, network_id)
elseif machines[name] == technic.receiver then
- add_new_cable_node(RE_nodes, pos)
+ add_new_cable_node(RE_nodes, pos, network_id)
elseif machines[name] == technic.producer_receiver then
- add_new_cable_node(PR_nodes, pos)
- add_new_cable_node(RE_nodes, pos)
+ add_new_cable_node(PR_nodes, pos, network_id)
+ add_new_cable_node(RE_nodes, pos, network_id)
elseif machines[name] == "SPECIAL" and
(pos.x ~= sw_pos.x or pos.y ~= sw_pos.y or pos.z ~= sw_pos.z) and
from_below then
-- Another switching station -> disable it
- add_new_cable_node(SP_nodes, pos)
+ add_new_cable_node(SP_nodes, pos, network_id)
meta:set_int("active", 0)
meta:set_string("active_pos", minetest.serialize(sw_pos))
elseif machines[name] == technic.battery then
- add_new_cable_node(BA_nodes, pos)
+ add_new_cable_node(BA_nodes, pos, network_id)
end
meta:set_int(tier.."_EU_timeout", 2) -- Touch node
@@ -115,7 +112,7 @@ local check_node_subp = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nod
end
-- Traverse a network given a list of machines and a cable type name
-local traverse_network = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, i, machines, tier, sw_pos)
+local traverse_network = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, i, machines, tier, sw_pos, network_id)
local pos = all_nodes[i]
local positions = {
{x=pos.x+1, y=pos.y, z=pos.z},
@@ -126,7 +123,7 @@ local traverse_network = function(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_no
{x=pos.x, y=pos.y, z=pos.z-1}}
--print("ON")
for i, cur_pos in pairs(positions) do
- check_node_subp(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, cur_pos, machines, tier, sw_pos, i == 3)
+ check_node_subp(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes, cur_pos, machines, tier, sw_pos, i == 3, network_id)
end
end
@@ -158,7 +155,7 @@ local get_network = function(sw_pos, pos1, tier)
local all_nodes = {pos1}
repeat
traverse_network(PR_nodes, RE_nodes, BA_nodes, SP_nodes, all_nodes,
- i, technic.machines[tier], tier, sw_pos)
+ i, technic.machines[tier], tier, sw_pos, minetest.hash_node_position(pos1))
i = i + 1
until all_nodes[i] == nil
technic.networks[minetest.hash_node_position(pos1)] = {tier = tier, PR_nodes = PR_nodes,
@@ -294,7 +291,7 @@ minetest.register_abm({
meta:set_string("infotext",
S("@1. Supply: @2 Demand: @3",
- machine_name, technic.prettynum(PR_eu_supply), technic.prettynum(RE_eu_demand)))
+ machine_name, technic.pretty_num(PR_eu_supply), technic.pretty_num(RE_eu_demand)))
-- If the PR supply is enough for the RE demand supply them all
if PR_eu_supply >= RE_eu_demand then
diff --git a/technic/radiation.lua b/technic/radiation.lua
new file mode 100644
index 0000000..13936f9
--- /dev/null
+++ b/technic/radiation.lua
@@ -0,0 +1,483 @@
+--[[
+Radioactivity
+
+Radiation resistance represents the extent to which a material
+attenuates radiation passing through it; i.e., how good a radiation
+shield it is. This is identified per node type. For materials that
+exist in real life, the radiation resistance value that this system
+uses for a node type consisting of a solid cube of that material is the
+(approximate) number of halvings of ionising radiation that is achieved
+by a meter of the material in real life. This is approximately
+proportional to density, which provides a good way to estimate it.
+Homogeneous mixtures of materials have radiation resistance computed
+by a simple weighted mean. Note that the amount of attenuation that
+a material achieves in-game is not required to be (and is not) the
+same as the attenuation achieved in real life.
+
+Radiation resistance for a node type may be specified in the node
+definition, under the key "radiation_resistance". As an interim
+measure, until node definitions widely include this, this code
+knows a bunch of values for particular node types in several mods,
+and values for groups of node types. The node definition takes
+precedence if it specifies a value. Nodes for which no value at
+all is known are taken to provide no radiation resistance at all;
+this is appropriate for the majority of node types. Only node types
+consisting of a fairly homogeneous mass of material should report
+non-zero radiation resistance; anything with non-uniform geometry
+or complex internal structure should show no radiation resistance.
+Fractional resistance values are permitted.
+--]]
+
+local S = technic.getter
+
+local rad_resistance_node = {
+ ["default:brick"] = 13,
+ ["default:bronzeblock"] = 45,
+ ["default:clay"] = 15,
+ ["default:coalblock"] = 9.6,
+ ["default:cobble"] = 15,
+ ["default:copperblock"] = 46,
+ ["default:desert_cobble"] = 15,
+ ["default:desert_sand"] = 10,
+ ["default:desert_stone"] = 17,
+ ["default:desert_stonebrick"] = 17,
+ ["default:diamondblock"] = 24,
+ ["default:dirt"] = 8.2,
+ ["default:dirt_with_grass"] = 8.2,
+ ["default:dirt_with_grass_footsteps"] = 8.2,
+ ["default:dirt_with_snow"] = 8.2,
+ ["default:glass"] = 17,
+ ["default:goldblock"] = 170,
+ ["default:gravel"] = 10,
+ ["default:ice"] = 5.6,
+ ["default:lava_flowing"] = 8.5,
+ ["default:lava_source"] = 17,
+ ["default:mese"] = 21,
+ ["default:mossycobble"] = 15,
+ ["default:nyancat"] = 1000,
+ ["default:nyancat_rainbow"] = 1000,
+ ["default:obsidian"] = 18,
+ ["default:obsidian_glass"] = 18,
+ ["default:sand"] = 10,
+ ["default:sandstone"] = 15,
+ ["default:sandstonebrick"] = 15,
+ ["default:snowblock"] = 1.7,
+ ["default:steelblock"] = 40,
+ ["default:stone"] = 17,
+ ["default:stone_with_coal"] = 16,
+ ["default:stone_with_copper"] = 20,
+ ["default:stone_with_diamond"] = 18,
+ ["default:stone_with_gold"] = 34,
+ ["default:stone_with_iron"] = 20,
+ ["default:stone_with_mese"] = 17,
+ ["default:stonebrick"] = 17,
+ ["default:water_flowing"] = 2.8,
+ ["default:water_source"] = 5.6,
+ ["farming:desert_sand_soil"] = 10,
+ ["farming:desert_sand_soil_wet"] = 10,
+ ["farming:soil"] = 8.2,
+ ["farming:soil_wet"] = 8.2,
+ ["glooptest:akalin_crystal_glass"] = 21,
+ ["glooptest:akalinblock"] = 40,
+ ["glooptest:alatro_crystal_glass"] = 21,
+ ["glooptest:alatroblock"] = 40,
+ ["glooptest:amethystblock"] = 18,
+ ["glooptest:arol_crystal_glass"] = 21,
+ ["glooptest:crystal_glass"] = 21,
+ ["glooptest:emeraldblock"] = 19,
+ ["glooptest:heavy_crystal_glass"] = 21,
+ ["glooptest:mineral_akalin"] = 20,
+ ["glooptest:mineral_alatro"] = 20,
+ ["glooptest:mineral_amethyst"] = 17,
+ ["glooptest:mineral_arol"] = 20,
+ ["glooptest:mineral_desert_coal"] = 16,
+ ["glooptest:mineral_desert_iron"] = 20,
+ ["glooptest:mineral_emerald"] = 17,
+ ["glooptest:mineral_kalite"] = 20,
+ ["glooptest:mineral_ruby"] = 18,
+ ["glooptest:mineral_sapphire"] = 18,
+ ["glooptest:mineral_talinite"] = 20,
+ ["glooptest:mineral_topaz"] = 18,
+ ["glooptest:reinforced_crystal_glass"] = 21,
+ ["glooptest:rubyblock"] = 27,
+ ["glooptest:sapphireblock"] = 27,
+ ["glooptest:talinite_crystal_glass"] = 21,
+ ["glooptest:taliniteblock"] = 40,
+ ["glooptest:topazblock"] = 24,
+ ["mesecons_extrawires:mese_powered"] = 21,
+ ["moreblocks:cactus_brick"] = 13,
+ ["moreblocks:cactus_checker"] = 8.5,
+ ["moreblocks:circle_stone_bricks"] = 17,
+ ["moreblocks:clean_glass"] = 17,
+ ["moreblocks:coal_checker"] = 9.0,
+ ["moreblocks:coal_glass"] = 17,
+ ["moreblocks:coal_stone"] = 17,
+ ["moreblocks:coal_stone_bricks"] = 17,
+ ["moreblocks:glow_glass"] = 17,
+ ["moreblocks:grey_bricks"] = 15,
+ ["moreblocks:iron_checker"] = 11,
+ ["moreblocks:iron_glass"] = 17,
+ ["moreblocks:iron_stone"] = 17,
+ ["moreblocks:iron_stone_bricks"] = 17,
+ ["moreblocks:plankstone"] = 9.3,
+ ["moreblocks:split_stone_tile"] = 15,
+ ["moreblocks:split_stone_tile_alt"] = 15,
+ ["moreblocks:stone_tile"] = 15,
+ ["moreblocks:super_glow_glass"] = 17,
+ ["moreblocks:tar"] = 7.0,
+ ["moreblocks:wood_tile"] = 1.7,
+ ["moreblocks:wood_tile_center"] = 1.7,
+ ["moreblocks:wood_tile_down"] = 1.7,
+ ["moreblocks:wood_tile_flipped"] = 1.7,
+ ["moreblocks:wood_tile_full"] = 1.7,
+ ["moreblocks:wood_tile_left"] = 1.7,
+ ["moreblocks:wood_tile_right"] = 1.7,
+ ["moreblocks:wood_tile_up"] = 1.7,
+ ["moreores:mineral_mithril"] = 18,
+ ["moreores:mineral_silver"] = 21,
+ ["moreores:mineral_tin"] = 19,
+ ["moreores:mithril_block"] = 26,
+ ["moreores:silver_block"] = 53,
+ ["moreores:tin_block"] = 37,
+ ["snow:snow_brick"] = 2.8,
+ ["technic:brass_block"] = 43,
+ ["technic:carbon_steel_block"] = 40,
+ ["technic:cast_iron_block"] = 40,
+ ["technic:chernobylite_block"] = 40,
+ ["technic:chromium_block"] = 37,
+ ["technic:corium_flowing"] = 40,
+ ["technic:corium_source"] = 80,
+ ["technic:granite"] = 18,
+ ["technic:lead_block"] = 80,
+ ["technic:marble"] = 18,
+ ["technic:marble_bricks"] = 18,
+ ["technic:mineral_chromium"] = 19,
+ ["technic:mineral_uranium"] = 71,
+ ["technic:mineral_zinc"] = 19,
+ ["technic:stainless_steel_block"] = 40,
+ ["technic:zinc_block"] = 36,
+ ["tnt:tnt"] = 11,
+ ["tnt:tnt_burning"] = 11,
+}
+local rad_resistance_group = {
+ concrete = 16,
+ tree = 3.4,
+ uranium_block = 500,
+ wood = 1.7,
+}
+local cache_radiation_resistance = {}
+local function node_radiation_resistance(node_name)
+ local resistance = cache_radiation_resistance[node_name]
+ if resistance then
+ return resistance
+ end
+ local def = minetest.registered_nodes[node_name]
+ if not def then
+ cache_radiation_resistance[node_name] = 0
+ return 0
+ end
+ resistance = def.radiation_resistance or
+ rad_resistance_node[node_name]
+ if not resistance then
+ resistance = 0
+ for g, v in pairs(def.groups) do
+ if v > 0 and rad_resistance_group[g] then
+ resistance = resistance + rad_resistance_group[g]
+ end
+ end
+ end
+ resistance = math.sqrt(resistance)
+ cache_radiation_resistance[node_name] = resistance
+ return resistance
+end
+
+
+--[[
+Radioactive nodes cause damage to nearby players. The damage
+effect depends on the intrinsic strength of the radiation source,
+the distance between the source and the player, and the shielding
+effect of the intervening material. These determine a rate of damage;
+total damage caused is the integral of this over time.
+
+In the absence of effective shielding, for a specific source the
+damage rate varies realistically in inverse proportion to the square
+of the distance. (Distance is measured to the player's abdomen,
+not to the nominal player position which corresponds to the foot.)
+However, if the player is inside a non-walkable (liquid or gaseous)
+radioactive node, the nominal distance could go to zero, yielding
+infinite damage. In that case, the player's body is displacing the
+radioactive material, so the effective distance should remain non-zero.
+We therefore apply a lower distance bound of sqrt(0.75), which is
+the maximum distance one can get from the node center within the node.
+
+A radioactive node is identified by being in the "radioactive" group,
+and the group value signifies the strength of the radiation source.
+The group value is the distance from a node at which an unshielded
+player will be damaged by 1 HP/s. Or, equivalently, it is the square
+root of the damage rate in HP/s that an unshielded player one node
+away will take.
+
+Shielding is assessed by adding the shielding values of all nodes
+between the source node and the player, ignoring the source node itself.
+As in reality, shielding causes exponential attenuation of radiation.
+However, the effect is scaled down relative to real life. A node with
+radiation resistance value R yields attenuation of sqrt(R) * 0.1 nepers.
+(In real life it would be about R * 0.69 nepers, by the definition
+of the radiation resistance values.) The sqrt part of this formula
+scales down the differences between shielding types, reflecting the
+game's simplification of making expensive materials such as gold
+readily available in cubes. The multiplicative factor in the
+formula scales down the difference between shielded and unshielded
+safe distances, avoiding the latter becoming impractically large.
+
+Damage is processed at rates down to 0.2 HP/s, which in the absence of
+shielding is attained at the distance specified by the "radioactive"
+group value. Computed damage rates below 0.2 HP/s result in no
+damage at all to the player. This gives the player an opportunity
+to be safe, and limits the range at which source/player interactions
+need to be considered.
+--]]
+local abdomen_offset = 1
+local cache_scaled_shielding = {}
+local rad_dmg_cutoff = 0.2
+local radiated_players = {}
+
+local armor_enabled = technic.config:get_bool("enable_radiation_protection")
+local entity_damage = technic.config:get_bool("enable_entity_radiation_damage")
+local longterm_damage = technic.config:get_bool("enable_longterm_radiation_damage")
+
+local function apply_fractional_damage(o, dmg)
+ local dmg_int = math.floor(dmg)
+ -- The closer you are to getting one more damage point,
+ -- the more likely it will be added.
+ if math.random() < dmg - dmg_int then
+ dmg_int = dmg_int + 1
+ end
+ if dmg_int > 0 then
+ local new_hp = math.max(o:get_hp() - dmg_int, 0)
+ o:set_hp(new_hp)
+ return new_hp == 0
+ end
+ return false
+end
+
+local function calculate_base_damage(node_pos, object_pos, strength)
+ local shielding = 0
+ local dist = vector.distance(node_pos, object_pos)
+
+ for ray_pos in technic.trace_node_ray(node_pos,
+ vector.direction(node_pos, object_pos), dist) do
+ local shield_name = minetest.get_node(ray_pos).name
+ shielding = shielding + node_radiation_resistance(shield_name) * 0.025
+ end
+
+ local dmg = (strength * strength) /
+ (math.max(0.75, dist * dist) * math.exp(shielding))
+
+ if dmg < rad_dmg_cutoff then return end
+ return dmg
+end
+
+local function calculate_damage_multiplier(object)
+ local ag = object.get_armor_groups and object:get_armor_groups()
+ if not ag then
+ return 0
+ end
+ if ag.immortal then
+ return 0
+ end
+ if ag.radiation then
+ return 0.01 * ag.radiation
+ end
+ if ag.fleshy then
+ return math.sqrt(0.01 * ag.fleshy)
+ end
+ return 0
+end
+
+local function calculate_object_center(object)
+ if object:is_player() then
+ return {x=0, y=abdomen_offset, z=0}
+ end
+ return {x=0, y=0, z=0}
+end
+
+local function dmg_object(pos, object, strength)
+ local obj_pos = vector.add(object:getpos(), calculate_object_center(object))
+ local mul
+ if armor_enabled or entity_damage then
+ -- we need to check may the object be damaged even if armor is disabled
+ mul = calculate_damage_multiplier(object)
+ if mul == 0 then
+ return
+ end
+ end
+ local dmg = calculate_base_damage(pos, obj_pos, strength)
+ if not dmg then
+ return
+ end
+ if armor_enabled then
+ dmg = dmg * mul
+ end
+ apply_fractional_damage(object, dmg)
+ if longterm_damage and object:is_player() then
+ local pn = object:get_player_name()
+ radiated_players[pn] = (radiated_players[pn] or 0) + dmg
+ end
+end
+
+local rad_dmg_mult_sqrt = math.sqrt(1 / rad_dmg_cutoff)
+local function dmg_abm(pos, node)
+ local strength = minetest.get_item_group(node.name, "radioactive")
+ local max_dist = strength * rad_dmg_mult_sqrt
+ for _, o in pairs(minetest.get_objects_inside_radius(pos,
+ max_dist + abdomen_offset)) do
+ if entity_damage or o:is_player() then
+ dmg_object(pos, o, strength)
+ end
+ end
+end
+
+if minetest.setting_getbool("enable_damage") then
+ minetest.register_abm({
+ nodenames = {"group:radioactive"},
+ interval = 1,
+ chance = 1,
+ action = dmg_abm,
+ })
+
+ if longterm_damage then
+ minetest.register_globalstep(function(dtime)
+ for pn, dmg in pairs(radiated_players) do
+ dmg = dmg - (dtime / 8)
+ local player = minetest.get_player_by_name(pn)
+ local killed
+ if player and dmg > rad_dmg_cutoff then
+ killed = apply_fractional_damage(player, (dmg * dtime) / 8)
+ else
+ dmg = nil
+ end
+ -- on_dieplayer will have already set this if the player died
+ if not killed then
+ radiated_players[pn] = dmg
+ end
+ end
+ end)
+
+ minetest.register_on_dieplayer(function(player)
+ radiated_players[player:get_player_name()] = nil
+ end)
+ end
+end
+
+-- Radioactive materials that can result from destroying a reactor
+local griefing = technic.config:get_bool("enable_corium_griefing")
+
+for _, state in pairs({"flowing", "source"}) do
+ minetest.register_node("technic:corium_"..state, {
+ description = S(state == "source" and "Corium Source" or "Flowing Corium"),
+ drawtype = (state == "source" and "liquid" or "flowingliquid"),
+ [state == "source" and "tiles" or "special_tiles"] = {{
+ name = "technic_corium_"..state.."_animated.png",
+ animation = {
+ type = "vertical_frames",
+ aspect_w = 16,
+ aspect_h = 16,
+ length = 3.0,
+ },
+ }},
+ paramtype = "light",
+ paramtype2 = (state == "flowing" and "flowingliquid" or nil),
+ light_source = (state == "source" and 8 or 5),
+ walkable = false,
+ pointable = false,
+ diggable = false,
+ buildable_to = true,
+ drop = "",
+ drowning = 1,
+ liquidtype = state,
+ liquid_alternative_flowing = "technic:corium_flowing",
+ liquid_alternative_source = "technic:corium_source",
+ liquid_viscosity = LAVA_VISC,
+ liquid_renewable = false,
+ damage_per_second = 6,
+ post_effect_color = {a=192, r=80, g=160, b=80},
+ groups = {
+ liquid = 2,
+ hot = 3,
+ igniter = (griefing and 1 or 0),
+ radioactive = (state == "source" and 12 or 6),
+ not_in_creative_inventory = (state == "flowing" and 1 or nil),
+ },
+ })
+end
+
+if rawget(_G, "bucket") and bucket.register_liquid then
+ bucket.register_liquid(
+ "technic:corium_source",
+ "technic:corium_flowing",
+ "technic:bucket_corium",
+ "technic_bucket_corium.png",
+ "Corium Bucket"
+ )
+end
+
+minetest.register_node("technic:chernobylite_block", {
+ description = S("Chernobylite Block"),
+ tiles = {"technic_chernobylite_block.png"},
+ is_ground_content = true,
+ groups = {cracky=1, radioactive=4, level=2},
+ sounds = default.node_sound_stone_defaults(),
+ light_source = 2,
+})
+
+minetest.register_abm({
+ nodenames = {"group:water"},
+ neighbors = {"technic:corium_source"},
+ interval = 1,
+ chance = 1,
+ action = function(pos, node)
+ minetest.remove_node(pos)
+ end,
+})
+
+minetest.register_abm({
+ nodenames = {"technic:corium_flowing"},
+ neighbors = {"group:water"},
+ interval = 1,
+ chance = 1,
+ action = function(pos, node)
+ minetest.set_node(pos, {name="technic:chernobylite_block"})
+ end,
+})
+
+minetest.register_abm({
+ nodenames = {"technic:corium_flowing"},
+ interval = 5,
+ chance = (griefing and 10 or 1),
+ action = function(pos, node)
+ minetest.set_node(pos, {name="technic:chernobylite_block"})
+ end,
+})
+
+if griefing then
+ minetest.register_abm({
+ nodenames = {"technic:corium_source", "technic:corium_flowing"},
+ interval = 4,
+ chance = 4,
+ action = function(pos, node)
+ for _, offset in ipairs({
+ vector.new(1,0,0),
+ vector.new(-1,0,0),
+ vector.new(0,0,1),
+ vector.new(0,0,-1),
+ vector.new(0,-1,0),
+ }) do
+ if math.random(8) == 1 then
+ minetest.dig_node(vector.add(pos, offset))
+ end
+ end
+ end,
+ })
+end
+
diff --git a/technic/textures/technic_stone_dust.png b/technic/textures/technic_stone_dust.png
new file mode 100644
index 0000000..ce9d9e4
--- /dev/null
+++ b/technic/textures/technic_stone_dust.png
Binary files differ
diff --git a/technic/textures/technicx32/technic_stone_dust.png b/technic/textures/technicx32/technic_stone_dust.png
new file mode 100644
index 0000000..3c49fe6
--- /dev/null
+++ b/technic/textures/technicx32/technic_stone_dust.png
Binary files differ
diff --git a/technic/tools/chainsaw.lua b/technic/tools/chainsaw.lua
index bf4efff..3653d2d 100644
--- a/technic/tools/chainsaw.lua
+++ b/technic/tools/chainsaw.lua
@@ -9,15 +9,19 @@ local chainsaw_leaves = true
-- The default trees
local timber_nodenames = {
- ["default:jungletree"] = true,
- ["default:papyrus"] = true,
- ["default:cactus"] = true,
- ["default:tree"] = true,
- ["default:apple"] = true,
- ["default:pinetree"] = true,
+ ["default:acacia_tree"] = true,
+ ["default:aspen_tree"] = true,
+ ["default:jungletree"] = true,
+ ["default:papyrus"] = true,
+ ["default:cactus"] = true,
+ ["default:tree"] = true,
+ ["default:apple"] = true,
+ ["default:pine_tree"] = true,
}
if chainsaw_leaves then
+ timber_nodenames["default:acacia_leaves"] = true
+ timber_nodenames["default:aspen_leaves"] = true
timber_nodenames["default:leaves"] = true
timber_nodenames["default:jungleleaves"] = true
timber_nodenames["default:pine_needles"] = true
diff --git a/technic/tools/mining_drill.lua b/technic/tools/mining_drill.lua
index 8a25abe..e8e9bcb 100644
--- a/technic/tools/mining_drill.lua
+++ b/technic/tools/mining_drill.lua
@@ -252,10 +252,9 @@ local function mining_drill_mk2_setmode(user,itemstack)
mode=mode+1
if mode>=5 then mode=1 end
minetest.chat_send_player(player_name, S("Mining Drill Mk%d Mode %d"):format(2, mode)..": "..mining_drill_mode_text[mode][1])
- item["name"]="technic:mining_drill_mk2_"..mode
+ itemstack:set_name("technic:mining_drill_mk2_"..mode);
meta["mode"]=mode
- item["metadata"]=minetest.serialize(meta)
- itemstack:replace(item)
+ itemstack:set_metadata(minetest.serialize(meta))
return itemstack
end
@@ -276,10 +275,9 @@ local function mining_drill_mk3_setmode(user,itemstack)
mode=mode+1
if mode>=6 then mode=1 end
minetest.chat_send_player(player_name, S("Mining Drill Mk%d Mode %d"):format(3, mode)..": "..mining_drill_mode_text[mode][1])
- item["name"]="technic:mining_drill_mk3_"..mode
+ itemstack:set_name("technic:mining_drill_mk3_"..mode);
meta["mode"]=mode
- item["metadata"]=minetest.serialize(meta)
- itemstack:replace(item)
+ itemstack:set_metadata(minetest.serialize(meta))
return itemstack
end
diff --git a/technic/tools/mining_lasers.lua b/technic/tools/mining_lasers.lua
index 4c83ae9..ef1eecb 100644
--- a/technic/tools/mining_lasers.lua
+++ b/technic/tools/mining_lasers.lua
@@ -32,75 +32,14 @@ minetest.register_craft({
}
})
--- Based on code by Uberi: https://gist.github.com/Uberi/3125280
-local function rayIter(pos, dir, range)
- local p = vector.round(pos)
- local x_step, y_step, z_step = 0, 0, 0
- local x_component, y_component, z_component = 0, 0, 0
- local x_intersect, y_intersect, z_intersect = 0, 0, 0
-
- if dir.x == 0 then
- x_intersect = math.huge
- elseif dir.x > 0 then
- x_step = 1
- x_component = 1 / dir.x
- x_intersect = x_component
- else
- x_step = -1
- x_component = 1 / -dir.x
- end
- if dir.y == 0 then
- y_intersect = math.huge
- elseif dir.y > 0 then
- y_step = 1
- y_component = 1 / dir.y
- y_intersect = y_component
- else
- y_step = -1
- y_component = 1 / -dir.y
- end
- if dir.z == 0 then
- z_intersect = math.huge
- elseif dir.z > 0 then
- z_step = 1
- z_component = 1 / dir.z
- z_intersect = z_component
- else
- z_step = -1
- z_component = 1 / -dir.z
- end
-
- return function()
- if x_intersect < y_intersect then
- if x_intersect < z_intersect then
- p.x = p.x + x_step
- x_intersect = x_intersect + x_component
- else
- p.z = p.z + z_step
- z_intersect = z_intersect + z_component
- end
- elseif y_intersect < z_intersect then
- p.y = p.y + y_step
- y_intersect = y_intersect + y_component
- else
- p.z = p.z + z_step
- z_intersect = z_intersect + z_component
- end
- if vector.distance(pos, p) > range then
- return nil
- end
- return p
- end
-end
-
local function laser_node(pos, node, player)
local def = minetest.registered_nodes[node.name]
if def and def.liquidtype ~= "none" then
minetest.remove_node(pos)
minetest.add_particle({
pos = pos,
- vel = {x=0, y=2, z=0},
- acc = {x=0, y=-1, z=0},
+ velocity = {x=0, y=2, z=0},
+ acceleration = {x=0, y=-1, z=0},
expirationtime = 1.5,
size = 6 + math.random() * 2,
texture = "smoke_puff.png^[transform" .. math.random(0, 7),
@@ -122,17 +61,17 @@ local function laser_shoot(player, range, particle_texture, sound)
local start_pos = vector.new(player_pos)
-- Adjust to head height
- start_pos.y = start_pos.y + 1.9
+ start_pos.y = start_pos.y + 1.6
minetest.add_particle({
pos = startpos,
- vel = dir,
- acc = vector.multiply(dir, 50),
+ velocity = dir,
+ acceleration = vector.multiply(dir, 50),
expirationtime = range / 11,
size = 1,
texture = particle_texture .. "^[transform" .. math.random(0, 7),
})
minetest.sound_play(sound, {pos = player_pos, max_hear_distance = range})
- for pos in rayIter(start_pos, dir, range) do
+ for pos in technic.trace_node_ray_fat(start_pos, dir, range) do
if minetest.is_protected(pos, player_name) then
minetest.record_protection_violation(pos, player_name)
break
diff --git a/technic_worldgen/nodes.lua b/technic_worldgen/nodes.lua
index a4fe2dd..f3a88e4 100644
--- a/technic_worldgen/nodes.lua
+++ b/technic_worldgen/nodes.lua
@@ -5,7 +5,7 @@ minetest.register_node( ":technic:mineral_uranium", {
description = S("Uranium Ore"),
tiles = { "default_stone.png^technic_mineral_uranium.png" },
is_ground_content = true,
- groups = {cracky=3, radioactive=1000},
+ groups = {cracky=3, radioactive=1},
sounds = default.node_sound_stone_defaults(),
drop = "technic:uranium_lump",
})
@@ -74,7 +74,7 @@ minetest.register_node(":technic:uranium_block", {
description = S("Uranium Block"),
tiles = { "technic_uranium_block.png" },
is_ground_content = true,
- groups = {uranium_block=1, cracky=1, level=2, radioactive=3000},
+ groups = {uranium_block=1, cracky=1, level=2, radioactive=2},
sounds = default.node_sound_stone_defaults()
})