| | |
| | | |
| | | local S = technic.getter |
| | | |
| | | technic.register_power_tool("technic:battery", 10000) |
| | | technic.register_power_tool("technic:red_energy_crystal", 100000) |
| | | technic.register_power_tool("technic:green_energy_crystal", 250000) |
| | | technic.register_power_tool("technic:blue_energy_crystal", 500000) |
| | | |
| | | minetest.register_craft({ |
| | | output = 'technic:battery', |
| | | recipe = { |
| | | {'group:wood', 'default:copper_ingot', 'group:wood'}, |
| | | {'group:wood', 'moreores:tin_ingot', 'group:wood'}, |
| | | {'group:wood', 'default:copper_ingot', 'group:wood'}, |
| | | } |
| | | }) |
| | | |
| | | minetest.register_tool("technic:battery", { |
| | | description = S("RE Battery"), |
| | | inventory_image = "technic_battery.png", |
| | | tool_capabilities = { |
| | | charge = 0, |
| | | max_drop_level = 0, |
| | | groupcaps = { |
| | | fleshy = {times={}, uses=10000, maxlevel=0} |
| | | } |
| | | } |
| | | }) |
| | | |
| | | |
| | | function technic.register_battery_box(data) |
| | | local tier = data.tier |
| | | local ltier = string.lower(tier) |
| | |
| | | charge_count = math.max(charge_count, 0) |
| | | local last_count = meta:get_float("last_side_shown") |
| | | if charge_count ~= last_count then |
| | | hacky_swap_node(pos,"technic:"..ltier.."_battery_box"..charge_count) |
| | | technic.swap_node(pos,"technic:"..ltier.."_battery_box"..charge_count) |
| | | meta:set_float("last_side_shown", charge_count) |
| | | end |
| | | |
| | |
| | | return batt_charge |
| | | end |
| | | local srcstack = inv:get_stack("src", 1) |
| | | local src_meta = get_item_meta(srcstack:get_metadata()) |
| | | local src_meta = minetest.deserialize(srcstack:get_metadata()) |
| | | |
| | | local toolname = srcstack:get_name() |
| | | if not technic.power_tools[toolname] then |
| | | return batt_charge |
| | | end |
| | | -- Set meta data for the tool if it didn't do it itself |
| | | src_meta = get_item_meta(srcstack:get_metadata()) |
| | | src_meta = minetest.deserialize(srcstack:get_metadata()) |
| | | src_meta = src_meta or {} |
| | | if not src_meta.charge then |
| | | src_meta.charge = 0 |
| | |
| | | batt_charge = batt_charge - charge_step |
| | | technic.set_RE_wear(srcstack, tool_charge, item_max_charge) |
| | | src_meta.charge = tool_charge |
| | | srcstack:set_metadata(set_item_meta(src_meta)) |
| | | srcstack:set_metadata(minetest.serialize(src_meta)) |
| | | inv:set_stack("src", 1, srcstack) |
| | | return batt_charge |
| | | end |
| | |
| | | return batt_charge |
| | | end |
| | | -- Set meta data for the tool if it didn't do it itself :-( |
| | | local src_meta = get_item_meta(srcstack:get_metadata()) |
| | | local src_meta = minetest.deserialize(srcstack:get_metadata()) |
| | | src_meta = src_meta or {} |
| | | if not src_meta.charge then |
| | | src_meta.charge = 0 |
| | |
| | | batt_charge = batt_charge + charge_step |
| | | technic.set_RE_wear(srcstack, tool_charge, item_max_charge) |
| | | src_meta.charge = tool_charge |
| | | srcstack:set_metadata(set_item_meta(src_meta)) |
| | | srcstack:set_metadata(minetest.serialize(src_meta)) |
| | | inv:set_stack("dst", 1, srcstack) |
| | | return batt_charge |
| | | end |