Jump to content




bad argument: int expected, got boolean - help!

computer utility

2 replies to this topic

#1 mieper

  • New Members
  • 5 posts

Posted 15 July 2012 - 10:43 PM

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?

#2 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 15 July 2012 - 11:30 PM

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


#3 Dirkus7

  • Members
  • 148 posts
  • Locationthe Netherlands

Posted 16 July 2012 - 11:12 PM

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users