summaryrefslogtreecommitdiff
path: root/technic/machines/register
diff options
context:
space:
mode:
Diffstat (limited to 'technic/machines/register')
-rw-r--r--technic/machines/register/battery_box.lua81
-rw-r--r--technic/machines/register/cables.lua32
2 files changed, 102 insertions, 11 deletions
diff --git a/technic/machines/register/battery_box.lua b/technic/machines/register/battery_box.lua
index c04875b..84e992c 100644
--- a/technic/machines/register/battery_box.lua
+++ b/technic/machines/register/battery_box.lua
@@ -12,12 +12,59 @@ technic.register_power_tool("technic:red_energy_crystal", 50000)
technic.register_power_tool("technic:green_energy_crystal", 150000)
technic.register_power_tool("technic:blue_energy_crystal", 450000)
+-- Battery recipes:
+-- Tin-copper recipe:
minetest.register_craft({
- output = 'technic:battery',
+ output = "technic:battery",
recipe = {
- {'group:wood', 'default:copper_ingot', 'group:wood'},
- {'group:wood', 'moreores:tin_ingot', 'group:wood'},
- {'group:wood', 'default:copper_ingot', 'group:wood'},
+ {"group:wood", "default:copper_ingot", "group:wood"},
+ {"group:wood", "moreores:tin_ingot", "group:wood"},
+ {"group:wood", "default:copper_ingot", "group:wood"},
+ }
+})
+-- Sulfur-lead-water recipes:
+-- With sulfur lumps:
+-- With water:
+minetest.register_craft({
+ output = "technic:battery",
+ recipe = {
+ {"group:wood", "technic:sulfur_lump", "group:wood"},
+ {"technic:lead_ingot", "bucket:bucket_water", "technic:lead_ingot"},
+ {"group:wood", "technic:sulfur_lump", "group:wood"},
+ },
+ replacements = {
+ {"bucket:bucket_water", "bucket:bucket_empty"}
+ }
+})
+-- With oil extract:
+minetest.register_craft({
+ output = "technic:battery",
+ recipe = {
+ {"group:wood", "technic:sulfur_lump", "group:wood"},
+ {"technic:lead_ingot", "homedecor:oil_extract", "technic:lead_ingot"},
+ {"group:wood", "technic:sulfur_lump", "group:wood"},
+ }
+})
+-- With sulfur dust:
+-- With water:
+minetest.register_craft({
+ output = "technic:battery",
+ recipe = {
+ {"group:wood", "technic:sulfur_dust", "group:wood"},
+ {"technic:lead_ingot", "bucket:bucket_water", "technic:lead_ingot"},
+ {"group:wood", "technic:sulfur_dust", "group:wood"},
+ },
+ replacements = {
+ {"bucket:bucket_water", "bucket:bucket_empty"}
+ }
+})
+-- With oil extract:
+minetest.register_craft({
+ output = "technic:battery",
+ recipe = {
+ {"group:wood", "technic:sulfur_dust", "group:wood"},
+ {"technic:lead_ingot", "homedecor:oil_extract", "technic:lead_ingot"},
+ {"group:wood", "technic:sulfur_dust", "group:wood"},
}
})
@@ -35,26 +82,38 @@ minetest.register_tool("technic:battery", {
}
})
+-- x+2 + (z+2)*2
+local dirtab = {
+ [4] = 2,
+ [5] = 3,
+ [7] = 1,
+ [8] = 0
+}
+
local tube = {
insert_object = function(pos, node, stack, direction)
- if direction.y == 0 then
+ print(minetest.pos_to_string(direction), dirtab[direction.x+2+(direction.z+2)*2], node.param2)
+ if direction.y == 1
+ or (direction.y == 0 and dirtab[direction.x+2+(direction.z+2)*2] == node.param2) then
return stack
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
- if direction.y > 0 then
+ if direction.y == 0 then
return inv:add_item("src", stack)
else
return inv:add_item("dst", stack)
end
end,
can_insert = function(pos, node, stack, direction)
- if direction.y == 0 then
+ print(minetest.pos_to_string(direction), dirtab[direction.x+2+(direction.z+2)*2], node.param2)
+ if direction.y == 1
+ or (direction.y == 0 and dirtab[direction.x+2+(direction.z+2)*2] == node.param2) then
return false
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
- if direction.y > 0 then
+ if direction.y == 0 then
if meta:get_int("split_src_stacks") == 1 then
stack = stack:peek_item(1)
end
@@ -66,7 +125,7 @@ local tube = {
return inv:room_for_item("dst", stack)
end
end,
- connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
+ connect_sides = {left=1, right=1, back=1, top=1},
}
local function add_on_off_buttons(meta, ltier, charge_percent)
@@ -219,13 +278,12 @@ function technic.register_battery_box(data)
local top_tex = "technic_"..ltier.."_battery_box_top.png"..tube_entry
local front_tex = "technic_"..ltier.."_battery_box_front.png^technic_power_meter"..i..".png"
local side_tex = "technic_"..ltier.."_battery_box_side.png"..tube_entry
- local bottom_tex = "technic_"..ltier.."_battery_box_bottom.png"..tube_entry
+ local bottom_tex = "technic_"..ltier.."_battery_box_bottom.png"..cable_entry
if ltier == "lv" then
top_tex = "technic_"..ltier.."_battery_box_top.png"
front_tex = "technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png"
side_tex = "technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png"
- bottom_tex = "technic_"..ltier.."_battery_box_bottom.png"..cable_entry
end
minetest.register_node("technic:"..ltier.."_battery_box"..i, {
@@ -271,6 +329,7 @@ function technic.register_battery_box(data)
allow_metadata_inventory_take = technic.machine_inventory_take,
allow_metadata_inventory_move = technic.machine_inventory_move,
technic_run = run,
+ on_rotate = screwdriver.rotate_simple,
after_place_node = data.tube and pipeworks.after_place,
after_dig_node = technic.machine_after_dig_node,
on_receive_fields = function(pos, formname, fields, sender)
diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua
index d65c399..1e8cee9 100644
--- a/technic/machines/register/cables.lua
+++ b/technic/machines/register/cables.lua
@@ -203,12 +203,31 @@ function technic.register_cable(tier, size)
def.on_place = function(itemstack, placer, pointed_thing)
local pointed_thing_diff = vector.subtract(pointed_thing.above, pointed_thing.under)
local num
+ local changed
for k, v in pairs(pointed_thing_diff) do
if v ~= 0 then
+ changed = k
num = xyz[s(tostring(v):sub(-2, -2)..k)]
break
end
end
+ local crtl = placer:get_player_control()
+ if (crtl.aux1 or crtl.sneak) and not (crtl.aux1 and crtl.sneak) then
+ local fine_pointed = minetest.pointed_thing_to_face_pos(placer, pointed_thing)
+ fine_pointed = vector.subtract(fine_pointed, pointed_thing.above)
+ fine_pointed[changed] = nil
+ local ps = {}
+ for p, _ in pairs(fine_pointed) do
+ ps[#ps+1] = p
+ end
+ local bigger = (math.abs(fine_pointed[ps[1]]) > math.abs(fine_pointed[ps[2]]) and ps[1]) or ps[2]
+ if math.abs(fine_pointed[bigger]) < 0.3 then
+ num = num + 3
+ num = (num <= 6 and num) or num - 6
+ else
+ num = xyz[((fine_pointed[bigger] < 0 and "-") or "") .. bigger]
+ end
+ end
minetest.set_node(pointed_thing.above, {name = "technic:"..ltier.."_cable_plate_"..num})
if not (creative and creative.is_enabled_for(placer)) then
itemstack:take_item()
@@ -218,6 +237,19 @@ function technic.register_cable(tier, size)
else
def.groups.not_in_creative_inventory = 1
end
+ def.on_rotate = function(pos, node, user, mode, new_param2)
+ local dir = 0
+ if mode == screwdriver.ROTATE_FACE then -- left-click
+ dir = 1
+ elseif mode == screwdriver.ROTATE_AXIS then -- right-click
+ dir = -1
+ end
+ local num = tonumber(node.name:sub(-1))
+ num = num + dir
+ num = (num >= 1 and num) or num + 6
+ num = (num <= 6 and num) or num - 6
+ minetest.swap_node(pos, {name = "technic:"..ltier.."_cable_plate_"..num})
+ end
minetest.register_node("technic:"..ltier.."_cable_plate_"..i, def)
cable_tier["technic:"..ltier.."_cable_plate_"..i] = tier
end