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

Redstone program.

Started by trainey, 05 January 2013 - 06:38 AM
trainey #1
Posted 05 January 2013 - 07:38 AM
Can someone help me write this program. I imagin it to be easy but I am very new to computer craft. I want help writing a program that detects if it gets a Redstone pulse. Whenever it gets a Redstone pulse I want it to show how many times it got one on the monitor located to the right.
Viproz #2
Posted 05 January 2013 - 07:48 AM
we will not code it for you, go check the wiki : http://computercraft...i/Redstone_(API)
ChunLing #3
Posted 05 January 2013 - 10:02 AM
To be precise, the purpose of this forum is more to help you learn how to program rather than provide custom programs without effort on your part.

Most of the time, people will offer code, but it is expected that you are making an effort to understand how the code works so that you can maintain and modify it yourself. This is more in keeping with the spirit of this forum and with the overall spirit of the CC mod.

If you just want a program coded without having to understand it, then search through the Programs forum (and Turtle Programs, if you're looking for a turtle program, which this isn't). People post lots and lots of complete programs there.

Not all of them really work very well.
Lyqyd #4
Posted 05 January 2013 - 11:19 AM
This one is pretty easy. We don't generally provide code, but since I'm bored on break:


local redState = {}
local mon = peripheral.wrap("right")
local pulseCount = 0

for _, side in ipairs(rs.getSides()) do
  redState[side] = rs.getInput(side)
end

local function pulseReceived()
  for _, side in ipairs(rs.getSides()) do
    if redState[side] ~= rs.getInput(side) then
      redState[side] = rs.getInput(side)
      if not redState[side] then
        return true
      end
    end
  end
  return false
end

while true do
  os.pullEvent("redstone")
  if pulseReceived() then
    pulseCount = pulseCount + 1
    mon.clear()
    mon.setCursorPos(1,1)
    mon.write(pulseCount)
  end
end
trainey #5
Posted 05 January 2013 - 11:58 AM
I know I have been looking though YouTube videos to try to learn it but it makes very little sence to me
Zambonie #6
Posted 05 January 2013 - 01:11 PM
But youll learn eventully,like me.And maybe you should start with small stuff.Like password doors.Or like an To-Do list or something,then you could get to making stuff like calculaters,like me.