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

Help with creating a program

Started by SurRainbow, 14 July 2015 - 12:35 PM
SurRainbow #1
Posted 14 July 2015 - 02:35 PM
Hi there! I'd like to have a computer that when it receives a signal from either top, behind, right or left it will display information on a monitor.

For example, when a chest is full I'd like it to say Chest full or when the backup power is empty I'd like it to say backup power empty and is it possible to have redstone inputs from more than 1 side?

Thanks!
- SurRainbow
KingofGamesYami #2
Posted 14 July 2015 - 07:33 PM
It is possible to have redstone inputs from multiple sides, that is why there is an argument for rs.getInput.


while true do
  term.clear()
  term.setCursorPos( 1, 1 )
  for i, side in pair( rs.getSides() ) do
    print( side .. ": " .. rs.getInput( side ) )
  end
end
Edited on 14 July 2015 - 05:34 PM
SurRainbow #3
Posted 19 July 2015 - 04:18 AM
Is this only on the computer though? Is there any other ways it can read a signal? I need about 8

Thanks!
- SurRainbow
ebernerd #4
Posted 19 July 2015 - 04:47 AM
If by "read a signal" you mean tell whether it is on or off, then you can get six values; one on top, bottom, left, right, front, and back of the computer.

The code above shows which sides have something on or off. You could assign a variable to each side and if it's on (the value would be true) or off (the value would be false) you could write the program accordingly.
KingofGamesYami #5
Posted 19 July 2015 - 04:51 AM
If available you could use bundled cable, depending on your version of CC and the mod supplying the bundled cable. That allows you to have 8 inputs per side, per computer.
Edited on 19 July 2015 - 02:51 AM
H4X0RZ #6
Posted 19 July 2015 - 05:34 AM
If available you could use bundled cable, depending on your version of CC and the mod supplying the bundled cable. That allows you to have 8 inputs per side, per computer.
Wasn't it 16 inputs per bundled cable, one for every color?
SurRainbow #7
Posted 13 October 2016 - 08:40 AM
Hey there… Sorry to bump the post… but a year later I've gotten back into the game and still with little knowledge about this mod…

Would you guys pretty please write a code that when there's a signal to the front of the computer it displays a message on the monitor that's behind it? and also displays a message when there's no signal?

Thank you!
- SurRainbow
Larry84 #8
Posted 13 October 2016 - 06:59 PM

mon=peripheral.wrap("back")
if rs.getInput("front") then --Sorry. Correcteded the do
  mon.write("your text here")
else
  mon.write("your text here")
end
Now it's up to you to adjust this ;)/>
Edited on 13 October 2016 - 07:33 PM
KingofGamesYami #9
Posted 13 October 2016 - 07:08 PM
Minor modification to Larry's code (because it will error…)


local mon = peripheral.wrap( 'back' )
term.redirect( mon )
while true do
  if rs.getInput( "front" ) then
    print( "Redstone: ON" )
  else
    print( "Redstone: OFF" )
  end
  os.pullEvent( "redstone" )
end
Larry84 #10
Posted 13 October 2016 - 08:39 PM
Minor modification to Larry's code (because it will error…)

local mon = peripheral.wrap( 'back' )
term.redirect( mon )
while true do
if rs.getInput( "front" ) then
print( "Redstone: ON" )
else
print( "Redstone: OFF" )
end
os.pullEvent( "redstone" )
end
Ops… I've made a pretty obvious mistake… :shame :P/>
Edited on 13 October 2016 - 06:39 PM