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

bad argument: int expected, got boolean - help!

Started by mieper, 15 July 2012 - 09:43 PM
mieper #1
Posted 15 July 2012 - 11:43 PM
Hi everyone!

I have a Problem with my Nuclear Controller.

The Errorcode:
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?
Orwell #2
Posted 16 July 2012 - 12:30 AM
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
Dirkus7 #3
Posted 17 July 2012 - 12:12 AM
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.