This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
DarkSleep's profile picture

Needing help with Big Reactor and computer craft

Started by DarkSleep, 15 March 2014 - 08:20 PM
DarkSleep #1
Posted 15 March 2014 - 09:20 PM
Hey so i am use this program

http://pastebin.com/V0eueruY

So post to look like this


-- Basic control for BigReactors-Reactor
-- BSD3 License
-- Emily Backes <lucca@accela.net>

-- Uses the first monitor it finds, if any
-- May need 3x3 or larger for that
-- No log output or printer usage yet
-- Will work on adv comps but mouse event handling
--   would need to be added below
-- Suitable for use in /startup

-- Max energy in a reactor's internal cell
local emax=10000000

-- wrap everything in an exception handler
local ok,msg=pcall(function ()
local r
local m
local redirected=false
local p

function findDev (dType)
  local d
  for _,d in pairs(peripheral.getNames()) do
    if (peripheral.getType(d) == dType) then
	  return peripheral.wrap(d)
    end
  end
  return nil, dType..": not found"
end

function setupDevs()   
  r=assert(findDev("BigReactors-Reactor"))
  if (not r.getConnected()) then
    return nil, "Computer port not connected to a valid reactor"
  end
  --if (r.getNumberOfControlRods() <1) then
  --  return nil, "Reactor seems invalid"
  --end
  r.getEnergyPercent = function ()
    return math.floor(1000 * r.getEnergyStored() / emax)/10
  end
  if r.nativeEPLT then
    r.getEnergyProducedLastTick = r.nativeEPLT
  end
  r.nativeEPLT = r.getEnergyProducedLastTick
  r.getEnergyProducedLastTick = function ()
    return math.floor(r.nativeEPLT()*1000)/1000
  end

  if redirected then
    term.restore()
    redirected = false
  end
  m=findDev("monitor")
  if m then
    m.setTextScale(0.5)
    term.clear()
    term.setCursorPos(1,1)
    print("Redirecting to attached monitor")
    term.redirect(m)
    redirected = true
  end

  term.setCursorBlink(false)
  p=findDev("printer")
end

function ft ()
  local d=os.day()
  local t=os.time()
  local h=math.floor(t)
  local m=math.floor((t-h)*60)
  return string.format("Day %d, %02d:%02d",d,h,m)
end

function log (msg)
  local stamp=ft()
  print (stamp..": "..msg)
end

function tableWidth(t)
  local width=0
  for _,v in pairs(t) do
    if #v>width then width=#v end
  end
  return width
end

function ljust(s,w)
  local pad=w-#s
  return s .. string.rep(" ",pad)
end

function rjust(s,w)
  local pad=w-#s
  return string.rep(" ",pad) .. s
end

function display()
  term.clear()
  term.setCursorPos(1,1)
  print("Reactor Status")
  print(ft())
  print("")
  local funcs={"Connected","Active","NumberOfControlRods","EnergyStored","EnergyPercent","Temperature","FuelAmount","WasteAmount","FuelAmountMax","EnergyProducedLastTick"}
  local units={"","","","RF","%","C","mB","mB","mB","RF/t"}
  local values={}
  for _,v in pairs(funcs) do
    values[#values+1] = tostring(r["get"..v]())
  end
  local funcW=tableWidth(funcs)
  local valW=tableWidth(values)
  for i,v in pairs(funcs) do
    print(rjust(v,funcW)..": "..rjust(values[i],valW).." "..units[i])
  end 
end

log("Starting")
setupDevs()
while true do
  local e=r.getEnergyStored()
  local p=math.floor(100*e/emax)
  local a=p<100
  local elt=r.getEnergyProducedLastTick()
  display()
  r.setAllControlRodLevels(p)
  r.setActive(a)
  os.startTimer(0.8333334)
  local event,p1,p2,p3,p4,p5 = os.pullEvent()
  if event == "key" then
    break
  elseif event == "peripheral_detach" or event == "peripheral" or event == "monitor_resize" then
    setupDevs()
  elseif not (event == "timer" or event=="disk" or event=="disk_eject") then
    error("received "..event)
  end
end

end)
term.restore()
error(msg)

Bug i get Big:110: attempt to call nill
I sett it all up like pic try restarting tryed new computer it keep doing the same thing

Could any one tell me were i going wrong Thanks
CometWolf #2
Posted 15 March 2014 - 11:05 PM
The error is caused when it attempts to call a function from the table r, which should be a wrapped BigReactors-Reactor, now the question is… Do you have openP installed, and did you actually turn both modems on?

Beyond that, i doubt you're gonna get much help on these forums. Ask the person who made the program.
Edited on 15 March 2014 - 10:06 PM
DarkSleep #3
Posted 16 March 2014 - 12:30 AM
The error is caused when it attempts to call a function from the table r, which should be a wrapped BigReactors-Reactor, now the question is… Do you have openP installed, and did you actually turn both modems on?

Beyond that, i doubt you're gonna get much help on these forums. Ask the person who made the program.
after in stalling OpenP and all off i still cant get any programs to work with BR but i can use turtle and computer to work
theoriginalbit #4
Posted 16 March 2014 - 03:19 AM
after in stalling OpenP and all off i still cant get any programs to work with BR but i can use turtle and computer to work
post the error messages you're getting
DarkSleep #5
Posted 16 March 2014 - 03:17 PM
after in stalling OpenP and all off i still cant get any programs to work with BR but i can use turtle and computer to work
post the error messages you're getting
i called it Big and the error is big:142: big:110: attempt to call nill

Ok so fix i down graded to the old one and all the programs work
Eiktyrner #6
Posted 23 March 2014 - 10:09 AM
Change "Temperature" to "CasingTemperature" or "FuelTemperature" on row 106.
sverd #7
Posted 10 April 2014 - 11:42 AM
Hi!
I just added both casing and fuel temp to the program, it works fine for me in tppi 1.02

http://pastebin.com/1Ph6ZdGa