83 posts
Location
Being the stereotypical kid in forums.
Posted 09 September 2014 - 09:49 PM
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,
376 posts
Location
[string "FindMe"]:23143: bad argument #1 to 'returnPos' (vector expected, got nil)
Posted 09 September 2014 - 10: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
83 posts
Location
Being the stereotypical kid in forums.
Posted 09 September 2014 - 10:05 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
Can you make it so that there is no monitor and the redstone input is bottom?
Thanks so much :D/>!
3057 posts
Location
United States of America
Posted 09 September 2014 - 10: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