Hi,
I am looking for a bit complex program that can count redstone pluses infinitly and dyspla the count on screen:
For eitch redpulse it adds one...
Thanks,
Electric Counter
Started by X3ME, Sep 09 2014 08:49 PM
3 replies to this topic
#1
Posted 09 September 2014 - 08:49 PM
#2
Posted 09 September 2014 - 09:03 PM
for i,v in pairs(rs.getSides()) do
if peripheral.isPresent(v) == true and peripheral.getType(v) == "monitor" then
side = v
end
end
local function centerText(text)
local x,y = p.getSize()
local x2,y2 = p.getCursorPos()
p.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
write(text)
end
p = peripheral.wrap(side)
pulses = 0
while true do
for i,v in pairs(rs.getSides()) do
if rs.getInput(v) then
pulses = pulses + 1
p.clear()
centerText("Pulses : "..pulses)
end
end
end
sorry for the mess
#3
Posted 09 September 2014 - 09:05 PM
Agent Silence, on 09 September 2014 - 09:03 PM, said:
for i,v in pairs(rs.getSides()) do
if peripheral.isPresent(v) == true and peripheral.getType(v) == "monitor" then
side = v
end
end
local function centerText(text)
local x,y = p.getSize()
local x2,y2 = p.getCursorPos()
p.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
write(text)
end
p = peripheral.wrap(side)
pulses = 0
while true do
for i,v in pairs(rs.getSides()) do
if rs.getInput(v) then
pulses = pulses + 1
p.clear()
centerText("Pulses : "..pulses)
end
end
end
sorry for the mess
Can you make it so that there is no monitor and the redstone input is bottom?
Thanks so much
#4
Posted 09 September 2014 - 09:34 PM
This isn't that hard if you don't center the text.
local count = 0 while true do os.pullEvent( "redstone" ) if rs.getInput( "bottom" ) then count = count + 1 end term.clear() term.setCursorPos( 1, 1 ) term.write( "Pulses: " .. count ) end
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











