From 987cc5a6a425b1f9bcd9000608dc389a45c675a1 Mon Sep 17 00:00:00 2001 From: you <ovvv@web.de> Date: Mon, 05 Jun 2017 16:51:59 +0200 Subject: [PATCH] Add api documentation (#361) --- technic/machines/register/battery_box.lua | 49 +++++++++++++++++++++++++++++++++++-------------- 1 files changed, 35 insertions(+), 14 deletions(-) diff --git a/technic/machines/register/battery_box.lua b/technic/machines/register/battery_box.lua index bb9c29d..f176395 100644 --- a/technic/machines/register/battery_box.lua +++ b/technic/machines/register/battery_box.lua @@ -35,26 +35,38 @@ } }) +-- 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 +78,7 @@ 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) @@ -133,7 +145,14 @@ end local run = function(pos, node) + local below = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}) local meta = minetest.get_meta(pos) + + if not technic.is_tier_cable(below.name, tier) then + meta:set_string("infotext", S("%s Battery Box Has No Network"):format(tier)) + return + end + local eu_input = meta:get_int(tier.."_EU_input") local current_charge = meta:get_int("internal_EU_charge") @@ -209,24 +228,25 @@ groups.tubedevice_receiver = 1 end + 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 tentry = tube_entry - local bentry = tube_entry + local side_tex = "technic_"..ltier.."_battery_box_side.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" - tentry = "" - bentry = cable_entry + side_tex = "technic_"..ltier.."_battery_box_side.png^technic_power_meter"..i..".png" end minetest.register_node("technic:"..ltier.."_battery_box"..i, { description = S("%s Battery Box"):format(tier), tiles = { - "technic_"..ltier.."_battery_box_top.png"..tentry, - "technic_"..ltier.."_battery_box_bottom.png"..bentry, - "technic_"..ltier.."_battery_box_side.png"..tentry, - "technic_"..ltier.."_battery_box_side.png"..tentry, - "technic_"..ltier.."_battery_box_side.png"..tentry, + top_tex, + bottom_tex, + side_tex, + side_tex, + side_tex, front_tex}, groups = groups, connect_sides = {"bottom"}, @@ -262,6 +282,7 @@ 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) -- Gitblit v1.8.0