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

it doesnt work

Started by SkyKun, 25 September 2014 - 08:09 PM
SkyKun #1
Posted 25 September 2014 - 10:09 PM
hello i dont know much about computercraft but i have this code

while true do
data = m.get(right)
if data(chest full) then
rs.setoutput(down, 60)
end
end

i have a chest on the right that i want to emit a redstone down when the chest is full but this code doesnt work
and i dont know whats wrong so if someone could help it would be much appriciated.
Dragon53535 #2
Posted 25 September 2014 - 10:53 PM
First, you should show the rest of your code if you have more, because at the moment we have no idea what m is, so we don't know what m.get() will return. Also you're probably calling that wrong as right should be "right".

Your rs.setOutput() is wrong as well, setoutput should be setOutput and the arguments that you're calling it with are also incorrect. rs.setOutput(Side,Boolean) so rs.setOutput("down",true) would turn on the output on the bottom, rs.setOutput("down",false) will turn it off.

Boolean's are always just true or false. Any direction you want something to look at or interact with needs to be a string and not a variable, unless of course you've already set down to be "down"

Post the rest of the code (and any api's it's utilizing) and i'll attempt to help you further once i have that information.
KingofGamesYami #3
Posted 25 September 2014 - 11:47 PM
Your rs.setOutput() is wrong as well, setoutput should be setOutput and the arguments that you're calling it with are also incorrect. rs.setOutput(Side,Boolean) so rs.setOutput("down",true) would turn on the output on the bottom, rs.setOutput("down",false) will turn it off.

Correction: "down" is not a valid side. "bottom" is the direction you are looking for.
Bomb Bloke #4
Posted 26 September 2014 - 12:52 AM
I'd use a comparator with rs.getAnalogInput(), assuming a comparator on its own isn't good enough for what you want. Eg:

while true do  -- Start a loop that repeats indefinitely.
	-- Sends a signal out the bottom depending on whether the signal coming from the right is at full strength:
	rs.setOutput("bottom", rs.getAnalogInput("right") == 15)

	-- Sits and waits until there's a change in redstone input:
	os.pullEvent("redstone")
end

If you specifically wanted the signal to last 60 seconds it'd look like this:

while true do  -- Start a loop that repeats indefinitely.
	if rs.getAnalogInput("right") == 15 then  -- If the comparator is at full strength,
		rs.setOutput("bottom", true)      -- enable the lower signal,
		sleep(60)                         -- then wait a minute.
	else
		rs.setOutput("bottom", false)     -- Or if it isn't, disable the signal,
		while rs.getAnalogInput("right") < 15 do
			os.pullEvent("redstone")  -- then wait until it is.
		end
	end
end