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

[openPeripheral]CommandRedstone-use a command to turn on redstone!

Started by Jappards, 15 June 2013 - 08:14 AM
Jappards #1
Posted 15 June 2013 - 10:14 AM
when the openperipheral terminal glasses came out i created a test program, but then i maked it my main program and then i decided to release it for other people.

this program triggers redstone on top of it if one of the following commands are typed
Spoiler

$$toggle--toggles the redstone state
$$pulse--changes the redstone state for 4 seconds and then goes back to before this command
it also displays the state of the redstone

how to use:
Spoiler1. place the terminal glasses bridge
2.place the computer on top off the terminal glasses bridge
3.place the redstone on top off the computer
4.get terminal glasses(or if you also have MPS installed, get the terminal glasses module on your power helmet)
5.right click the terminal glasses bridge
6.pastebin the program: pastebin get vXryjxUK# CommandRedstone
7.????
8.PROFIT!

code:
http://pastebin.com/9sWKnPS0

pastebin get 9sWKnPS0 CommandRedstone

Note:this program requires openPeripheral:http://www.computerc...711#entry120711

suggestions: if you have any suggestions please post them below.

updater:
pastebin get r3WdEVUm CR updater

code:
http://pastebin.com/r3WdEVUm

credit:
Mikeemoo for openPeripheral
theoriginalbit for fixing some bugs

authors:
Xiretza
Jappards
superaxander #2
Posted 15 June 2013 - 10:21 AM
Nice and simple. Well done!
theoriginalbit #3
Posted 15 June 2013 - 10:30 AM
nice and simple.

one code improvement though that jumped straight out at me.
this:

if command == "toggle" then
  if redstoneState == false then
   rs.setOutput("top",true)
   redstoneState = true
  else
   rs.setOutput("top",false)
   redstoneState = false
  end
end
can become

if command == "toggle" then
  redstoneState = not redstoneState --# this line toggles the boolean variable, see quote below for more info
  rs.setOutput("top", redstoneState)
end
this is how the not operator works
not true = false
not false = true
Jappards #4
Posted 15 June 2013 - 11:00 AM
thanks!
Spoilernice and simple.

one code improvement though that jumped straight out at me.
this:

if command == "toggle" then
  if redstoneState == false then
   rs.setOutput("top",true)
   redstoneState = true
  else
   rs.setOutput("top",false)
   redstoneState = false
  end
end
can become

if command == "toggle" then
  redstoneState = not redstoneState --# this line toggles the boolean variable, see quote below for more info
  rs.setOutput("top", redstoneState)
end
this is how the not operator works
not true = false
not false = true

thanks for noticing it me, the thread code is already updated, i will now be updating the pastebin.

Edit: pastebin updated, if you have any suggestions, please post it below
theoriginalbit #5
Posted 15 June 2013 - 11:03 AM
thanks for noticing it me, the thread code is already updated, i will now be updating the pastebin.
No problems. You could use a similar method for the pulse command too

if command == "pulse" then
  rs.setOutput("top", not redstoneState)
  sleep(4)
  rs.setOutput("top", redstoneState)
end
Jappards #6
Posted 15 June 2013 - 11:16 AM
i already updated it on this thread and pastebin
Xiretza #7
Posted 15 June 2013 - 12:39 PM
Ok, made a little better (I hope :P/>) version, changed some things… http://pastebin.com/GkTuNmwS
Changes:
1. You can now tell the program where the RS output and the glassesbridge is
2. LOTS of changes in the background, just have a look at it :P/>
Jappards #8
Posted 15 June 2013 - 01:03 PM
thanks, i will update it, it does miss the clear command thought, but i can just add that to your version
Xiretza #9
Posted 15 June 2013 - 01:14 PM
it does miss the clear command thought
Why should it clear? The redstone signal is either on or off, you don't have to clear anything… And on startup it clears automatically.
Jappards #10
Posted 15 June 2013 - 01:21 PM
well, in case bugs mess the screen up
Xiretza #11
Posted 15 June 2013 - 01:47 PM
well, in case bugs mess the screen up
Bugs?! In my programs are no bugs :D/>
Xiretza #12
Posted 15 June 2013 - 09:23 PM
Sorry, but I had to do that. New termglassRS: http://pastebin.com/UGTKZhLP New updater: http://pastebin.com/JyYgs2Ys
Made it so you only have to run the updater, it detects what the name of the program was previously and replaces it (And if it fails, it has a save copy called "[filename]_old"). Had to add a bunch off stuff, but I think it's worth it.
Jappards #13
Posted 16 June 2013 - 03:35 AM
no problem, but i have a problem connecting to pastebin.