←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

bad argument: int expected, got boolean...

mieper's Photo mieper 15 Jul 2012

Hi everyone!

I have a Problem with my Nuclear Controller.

The Errorcode:

Quote

test2.lua:48: bad argument: int expected, got boolean

This Code works perfectly:
local cableSide = "back"
local switch = colors.pink
local heatmin = colors.white
local heatmax = colors.red
local hot = false
local cold = false
local onoff = false
local function update()
  local hot = rs.testBundledInput(cableSide, heatmax)
  local cold = rs.testBundledInput(cableSide, heatmin)
  local onoff = rs.testBundledInput(cableSide, switch)
  term.setCursorPos(1, 1)
  term.clear()
  print (hot)
  print (cold)
  print (onoff)
  sleep(1)
end
update()
while true do update() end


The another incomplete Code with mysterious error:
--CABLE SIDE--
local cableSide = "back" --side of computer the bundled cable is on

--[[CABLES]]--
local heatmin = colors.white --input from heat sensor
local heatmax = colors.red  --input from heat sensor
local poweron = colors.black --output to control the reactor
local ice = colors.green --output to activate ice
local switch = colors.pink --switch turn on off reaktor
local flow = colors.purple --input energy flow
local danger = colors.lime --output for alarm
local two = colors.orange --empty
local companyName = "mieper Industries"
--END OF CONFIG--

--start variables
local heatmax = false
local heatmin = false
local switch = false
local hot = false
local cold = false
local onoff = false

local width, height = term.getSize() --size of the screen

local function clearScreen()
  term.clear() --Clear the screen
  --Print the program and company names
  term.setCursorPos(1, 1)
  term.write("Nuclear Reactor Control Unit")
  term.setCursorPos(width-#companyName+1, height)
  term.write(companyName)
end

local function update()
  local hot = rs.testBundledInput(cableSide, heatmax)
  local cold = rs.testBundledInput(cableSide, heatmin)
  local onoff = rs.testBundledInput(cableSide, switch)
end

local function doTick()
  update()
  clearScreen()
  term.setCursorPos(1, 3)
  term.write("Current status: ")

  if onoff then
	if hot then
	term.write("Maximum heat!")
	rs.setBundledOutput(cableSide, danger)
	else
	term.write("Online")
	rs.setBundledOutput(cableSide, poweron)
	end
  else
  term.write("Offline")
  end
sleep(1)
end

while true do doTick() end


These Lines generates the Error. But the first Code has these lines also.
  local hot = rs.testBundledInput(cableSide, heatmax)
  local cold = rs.testBundledInput(cableSide, heatmin)
  local onoff = rs.testBundledInput(cableSide, switch)

What is the Solution of this Problem?
Quote

Orwell's Photo Orwell 15 Jul 2012

Look at this page on the wiki:
http://computercraft...estBundledInput

testBundledInput takes the side as a string and the value of the bundled Cable as a number. It's not like regular redstone that can only be on or off.
But you declare the values as booleans:
local heatmax = false
local heatmin = false
local switch = false
Quote

Dirkus7's Photo Dirkus7 16 Jul 2012

rs.testBundledInput("strSide", numColor) returns true if the given color is on, and false if not. You need your variables to be "color.red" or whatever color you need. Try reading the wiki page.
Quote