I just want to point this out directly
click = { os.pullEvent("mouse_click") }
button = click[1]
xPos = click[2]
yPos = click[3]
This piece of code is incorrect, the os.pullEvent function first returns the event and then the other parameters, so this would be like this instead
local click = { os.pullEvent( "mouse_click" ) }
local button = click[2]
local xPos, yPos = click[3], click[4]
which could also be put into a single line like this
local event, button, xPos, yPos = os.pullEvent( "mouse_click" )
But one thing I don't understand is why you have multiple functions that handle events, it'd be much easier and cleaner code-wise to have it in one single function like this
local function handleEvents()
local e = { os.pullEvent() }
if e[1] == "rednet_message" then
--# handle rednet event
elseif e[1] == "mouse_click" then
--# handle mouse clicks
elseif e[1] == "key" then
--# handle key events
end
end
and then you could have a main function that would look something like this
local function main()
while true do
draw()
handleEvents()
end
end
--# Call the main function using pcall
local ok, err = pcall( main )
if not ok and err ~= "Terminated" then
print( "An unexpected error occured: " .. err )
end
And this part I'm guessing you're expecting a table
isActive = message[3][1]
fuel = message[3][2]
fuelMax = message[3][3]
energyStored = message[3][4]
RFS = message[3][5]
reactivity = message[3][6]
waste = message[3][7]
caseTemp = message[3][8]
fuelTemp = message[3][9]
you could cram that into one line aswell using unpack
local isActive, fuel, fuelMax, energyStored, RFS, reactivity, waste, caseTemp, fuelTemp = unpack( message[3] )
Something you may have noticed is that I've declared most of your variables as locals, and I have to say that it's a much better idea to declare variables as such in most cases, it makes the program run faster etc, I'm sure someone can explain it better than me.
Oh and finally I'd like to ask, are you getting an error at all? Or is it just giving you a black-screen when it exits the program?
It's hard to know what the problem is when I don't know the error, the stuff above is just advices that can help you make your code more readable for yourself, and also to give you better coding habits.