Posted 26 August 2016 - 02:20 AM
I'm writing my first program, which is for Big Reactors. And when i want to write out some of the data it won't work.
I can easily get it to write out if the reactor is on, if i don't put it in my "draw_text" function, but when i do i get the error (lasse:25: attempt to concatenate string and boolean) Everything else in the code works though.
Here is the code.
I can easily get it to write out if the reactor is on, if i don't put it in my "draw_text" function, but when i do i get the error (lasse:25: attempt to concatenate string and boolean) Everything else in the code works though.
Here is the code.
while true do
local reactor = peripheral.wrap("BigReactors-Reactor_6")
local mon = peripheral.wrap("monitor_8")
mon.clear()
mon.setBackgroundColor(colors.black)
mon.setTextScale(1.75)
------ Functions ------
-- Text --
function draw_text(x, y, text, text_color)
mon.setTextColor(text_color)
mon.setCursorPos(x,y)
mon.write(text)
end
------ Screen ------
-- Name of program --
draw_text(6, 1, "Reactor Controle", colors.orange)
-- Active --
local ReactorActive = reactor.getActive()
draw_text(1, 2, "Active: ".. ReactorActive, colors.lime) -- It is here the problem is i think, as it is line 25
if ReactorActive == 0 then do
draw_text(1, 2, "Active: ".. ReactorActive, colors.red)
end
-- Fuel amount --
local FuelAmount = math.floor(reactor.getFuelAmount() /1000)
local MaxFuelAmount = math.floor(reactor.getFuelAmountMax() /1000)
local FuelTogether = FuelAmount .." / ".. MaxFuelAmount
draw_text(1, 3, "Fuel: ".. FuelTogether, colors.lime)
if FuelAmount / MaxFuelAmount <= 0.1 then do
draw_text(1, 3, "Fuel: ".. FuelTogether, colors.red)
end
end
sleep(5)
end
end
Edited on 26 August 2016 - 12:24 AM