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

Off and on lights

Started by Zereleth, 09 July 2016 - 09:50 PM
Zereleth #1
Posted 09 July 2016 - 11:50 PM
I'm trying to make a pretty basic computer, I just want to be able to set it so I type power on and it sends a redstone signal out the back (Which would turn my lights on) or power off to turn them off. Can anyone help me with it? Thanks
KingofGamesYami #2
Posted 10 July 2016 - 02:37 AM
You'll want to create a program called "power". Since I'm not sure of your level of competence with computercraft, I'll walk you through it.
Step 1, opening the file in the "edit" program

CraftOS 1.7 --# this might be different, depending on your version. It doesn't matter. FYI, anything after --# is a comment
> edit power
You should see a blank screen with some information at the bottom.
Next, you should type the following code into the computer*:

local tArgs = { ... } --#this captures your command-line argument to the program, either "on" or "off"
rs.setOutput( "back", tArgs[ 1 ] == "on" ) --# this sets the output on the back of the computer to true if you supplied "on", otherwise it will set it to false
*You don't have to type anything after a –#. Those are comments describing what that code does.
Edited on 10 July 2016 - 12:37 AM