add energy transfer to AR

This commit is contained in:
LordMZTE 2021-11-14 17:38:23 +01:00
parent 036da52397
commit 85a066a1c0

View file

@ -1,11 +1,16 @@
local ar = peripheral.find "arController"
local pl_detector = peripheral.find "playerDetector"
local nrg = peripheral.find "thermal:energy_cell"
local nrg_cell = peripheral.find "thermal:energy_cell"
local nrg_in = peripheral.wrap "energyDetector_0"
local nrg_out = peripheral.wrap "energyDetector_1"
if ar == nil or pl_detector == nil or nrg == nil then
error "couldnt find all peripherals. need ar controller, player detector and energy cell"
if ar == nil or pl_detector == nil or nrg_cell == nil or nrg_in == nil or nrg_out == nil then
error "couldnt find all peripherals."
end
nrg_in.setTransferRateLimit(1000000)
nrg_out.setTransferRateLimit(1000000)
local cur_row = 0
local function draw_idx_string(string, x)
@ -42,9 +47,11 @@ while true do
draw_idx_separator(),
draw_one_line_idx_icon "minecraft:redstone_block",
draw_idx_string("Base Power:", 20),
draw_idx_string("Max: " .. nrg.getEnergyCapacity()),
draw_idx_string("Current: " .. nrg.getEnergy()),
draw_idx_string("%: " .. nrg.getEnergy() / nrg.getEnergyCapacity() * 100),
draw_idx_string("Max: " .. nrg_cell.getEnergyCapacity()),
draw_idx_string("Current: " .. nrg_cell.getEnergy()),
draw_idx_string("%: " .. nrg_cell.getEnergy() / nrg_cell.getEnergyCapacity() * 100),
draw_idx_string("Production: " .. nrg_in.getTransferRate()),
draw_idx_string("Use: " .. nrg_out.getTransferRate()),
draw_idx_separator(),
draw_one_line_idx_icon "minecraft:player_head",
draw_idx_string("Players:", 20),