Jump to content




BigReactors - Troubleshooting

peripheral wireless

2 replies to this topic

#1 isolatedvirus

  • Members
  • 4 posts

Posted 17 July 2018 - 07:04 AM

I last used these back in 2014/2015, and after a few years hiatus I've come back to play and found the scripts aren't working. Perhaps they were never working, and im remembering wrong, but one things for certain. I'm not sure how to further troubleshoot the issues below:

The setup for this is two computers, one set to display and the other set to reactor.

The display side doesnt display anything. its just a blank screen, and should atleast complain about not seeing messages from the reactor side.

The reactor side throws the error: parallel :22: rednet :54: Expected number.
-running the command <lua> i can manually pull the information found in the function "reactorPoll"


-- THIS VARIABLE MUST BE SET TO PROPERLY CONFIGURE THE PROGRAM!
-- Valid choices are:
-- reactor, turbine, display

mode = "setme"

if mode == "setme" then
	    print("The mode has not been set!")
	    print("Please set the mode and try again.")
	    exit()
end

-- Variables
-- These can be changed according to your setup

-- Communications variables
local reactorInfo = "reactInfo" -- protocol used to send information
local reactorCmd = "reactCmd" -- protocol used to receive commands


-- Reactor Variables:
local reactorComputerPortSide = "back" --Side that the reactor's computer port is on
local reactorComputerModemSide = "top" --Side the wireless modem is on (for the computer connected to reactor)

-- Reactor Monitor Variables:

local rmonMonitorSide = "top" --Side the monitor is on for the display of reactor stats
local rmonModemSide = "back" --Side the wireless modem is on for the computer displaying stats

-- General Use Functions
function round(val, decimal)
  if (decimal) then
    return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
  else
    return math.floor(val+0.5)
  end
end

-- WRM - information sender

function reactorPoll()
rednet.open(reactorComputerModemSide)
reactor = peripheral.wrap(reactorComputerPortSide)
connected = reactor.getConnected()
if connected == false then
rednet.broadcast(connected,reactorInfo)
sleep(0.1)
else
local reactorResults = {
active = reactor.getActive(),
rodcount = reactor.getNumberOfControlRods(),
energystored = reactor.getEnergyStored(),
fueltemp = reactor.getFuelTemperature(),
casingtemp = reactor.getCasingTemperature(),
fuelamount = reactor.getFuelAmount(),
wasteamount = reactor.getWasteAmount(),
maxfuel = reactor.getFuelAmountMax(),
rodlevel = reactor.getControlRodLevel(0),
energyproduction = reactor.getEnergyProducedLastTick(),
coolantamount = reactor.getCoolantAmount(),
coolanttype = reactor.getCoolantType(),
hotfluidamount = reactor.getHotFluidAmount(),
hotfluidtype = reactor.getHotFluidType(),
fuelreactivity = reactor.getFuelReactivity(),
fuelconsumed = reactor.getFuelConsumedLastTick(),
reactortype = reactor.isActivelyCooled()
}
rednet.broadcast(reactorResults,reactorInfo)
sleep(0.1)
end
end


function reactorPowerChange()

local id, msg, proto = rednet.receive(reactorCmd,0.1)

if msg == "poweron" then

if reactor.getActive() == true then
reactor.setActive(false)
elseif reactor.getActive() == false then
reactor.setActive(true)
end

end

end

function reactorCRodChange()
local e = reactor.getControlRodLevel(0)
local id, msg, proto = rednet.receive(reactorCmd,0.1)

if msg == "minus" then
local e = e+1
reactor.setAllControlRodLevels(e)


elseif msg == "minusten" then
local e = e+10
reactor.setAllControlRodLevels(e)


elseif msg == "plusten" then
local e = e-10
reactor.setAllControlRodLevels(e)


elseif msg == "plus" then
local e = e-1
reactor.setAllControlRodLevels(e)

elseif msg == "zero" then
local e = 100
reactor.setAllControlRodLevels(e)

elseif msg == "sto" then
local e = 0
reactor.setAllControlRodLevels(e)
end
end

-- Wireless Reactor Monitoring (receiver)

function printdataorig() -- original printdata code (not in use)
local id, msg, proto = rednet.receive(reactInfo)
term.redirect(mon)
term.clear()
mon.setTextScale(0.5)
term.setCursorPos(1,1)
if msg == false then
write("STATUS: ")
mon.setBackgroundColour(colors.red)
write("ERROR")
mon.setBackgroundColour(colors.black)
print()
print()
print("Something is wrong with program or reactor setup")
print("Press Ctrl+T to terminate program")
else
write("STATUS: ")
if msg.active == true then
mon.setBackgroundColour(colors.lime)
write("ACTIVE")
elseif msg.active == false then
mon.setBackgroundColour(colors.yellow)
write("NOT ACTIVE")
end
mon.setBackgroundColour(colors.black)
print()
print()
print("Rods Level:	    " .. 100-tostring(msg.rodlevel) .." %")
print("Energy Production: " .. math.floor(msg.energylasttick,0) .. " RF/t")
print("Energy Stored:	 " .. msg.energystored .. " RF")
print()
print("Fuel:			  " .. msg.fuelamount .. "/" .. msg.fuelmax .. " mB")
print("Fuel Usage:	    " .. math.ceil(msg.fueleatlasttick*100)/100 .. " mB/t")
print("Fuel Temperature:  " .. math.floor(msg.fueltemp,1) .. " C")
print("Fuel Reactivity:   " .. math.floor(msg.fuelreact,1) .. " %")
print("Waste:			 " .. msg.wasteamount .. " mB")
print()
print("Casing Temperature:" .. math.floor(msg.casingtemp,1) .. " C")
print()
mon.setBackgroundColour(colors.orange)
write("POWER ")
mon.setBackgroundColour(colors.black)
write(" ")
mon.setBackgroundColour(colors.gray)
write("   RODS LEVEL   ")
print()
mon.setBackgroundColour(colors.orange)
write("SWITCH")
mon.setBackgroundColour(colors.black)
write(" ")
mon.setBackgroundColour(colors.gray)
write("|<")
mon.setBackgroundColour(colors.black)
write(" ")
mon.setBackgroundColour(colors.gray)
write("<<")
mon.setBackgroundColour(colors.black)
write(" ")
mon.setBackgroundColour(colors.gray)
write("<")
mon.setBackgroundColour(colors.black)
write("  ")
mon.setBackgroundColour(colors.gray)
write(">")
mon.setBackgroundColour(colors.black)
write(" ")
mon.setBackgroundColour(colors.gray)
write(">>")
mon.setBackgroundColour(colors.black)
write(" ")
mon.setBackgroundColour(colors.gray)
write(">|")
mon.setBackgroundColour(colors.black)

end
sleep(0.11)
end


function reactorPowerControl() -- original reactor controls. (not in use and not rewritten yet)

local event, par1, tx, ty = os.pullEvent()
if event == "monitor_touch"  then

if tx == 8 or tx == 9 and ty == 16 then
rednet.broadcast("zero",reactCmd)

elseif tx == 11 or tx == 12 and ty == 16 then
rednet.broadcast("minusten",reactCmd)

elseif tx == 14 and ty == 16 then
rednet.broadcast("minus",reactCmd)

elseif tx == 17 and ty == 16 then
rednet.broadcast("plus",reactCmd)

elseif tx == 19 or tx == 20 and ty == 16 then
rednet.broadcast("plusten",reactCmd)

elseif tx == 22 or tx == 24 and ty == 16 then
rednet.broadcast("sto",reactCmd)

elseif tx<7 and ty == 15 or tx<7 and ty == 16 then
rednet.broadcast("poweron",reactCmd)
end
end
end


function printdata() -- Passive reactor completed, need active and turbine
rednet.open(rmonModemSide)
local mon = peripheral.wrap(rmonMonitorSide)
local monX ,monY = mon.getSize()
local id, msg, proto = rednet.receive(reactInfo)
term.redirect(mon)
term.clear()
mon.setTextScale(1)
term.setCursorPos(1,1)
if msg == false then
write("STATUS: ")
mon.setBackgroundColour(colors.red)
write("ERROR")
mon.setBackgroundColour(colors.black)
print()
print()
print("Something is wrong with program or reactor setup")
print("Press Ctrl+T to terminate program")
elseif msg.reactortype == false then -- Passive Reactor stat display
write("PASSIVE REACTOR: ")
if msg.active == true then
mon.setBackgroundColour(colors.lime)
write("ONLINE")
elseif msg.active == false then
mon.setBackgroundColour(colors.yellow)
write("OFFLINE")
end
mon.setBackgroundColour(colors.black)
mon.setCursorPos(30,1)
write("CORE REACTIVITY: " .. math.floor(msg.fuelreactivity,1) .. "%")
print()
print("TEMPERATURE")
print(" CORE:		 " .. math.floor(msg.fueltemp,1) .. " C")
print(" CASING:	   " .. math.floor(msg.casingtemp,1) .. " C")
print()
print("ENERGY")
print(" PRODUCED: " .. math.floor(msg.energyproduction,0) .. " RF/t")
print(" STORED:   " .. msg.energystored .. " RF")
print("			 " .. round(msg.energystored/10000000*100,2) .. "%")
--print()
print("FUEL")
print(" LEVEL:	  " .. round(msg.fuelamount/msg.maxfuel*100,2) .. "%")
print(" USAGE:	   " .. round(msg.fuelconsumed,3) .. " mB/t")
print(" WASTE:	    " .. round(msg.wasteamount/1000,3) .. " mB")
print()
print("CONTROL ROD")
print(" COUNT:		 " .. msg.rodcount)
print(" INSERTION:	 " .. msg.rodlevel .. " %")
elseif msg.reactortype == false then -- active Reactor stat display
write("ACTIVE REACTOR: ")
if msg.active == true then
mon.setBackgroundColour(colors.lime)
write("ONLINE")
elseif msg.active == false then
mon.setBackgroundColour(colors.yellow)
write("OFFLINE")
end

end
sleep(0.11)
end


if mode == "reactor" then
--REACTOR LOOP
    while true do
	    parallel.waitForAll(reactorPoll, reactorPowerChange, reactorCRodChange)
    end
elseif mode == "display" then
--MONITOR LOOP
    while true do
	    parallel.waitForAny(printdata,reactorPowerControl)
    end
elseif mode == "turbine" then
--TURBINE LOOP
    print("Coding for turbines has not been completed (yet)")
end


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 18 July 2018 - 12:03 PM

This script makes use of rednet protocols, which require CC 1.6 or later. Judging by the error, you've got an older version of the mod.

#3 isolatedvirus

  • Members
  • 4 posts

Posted 18 July 2018 - 04:18 PM

View PostBomb Bloke, on 18 July 2018 - 12:03 PM, said:

This script makes use of rednet protocols, which require CC 1.6 or later. Judging by the error, you've got an older version of the mod.

wow, great catch!

guess ill have to rewrite this to remove the protocols.

Thanks!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users