Jump to content




Electric Counter


  • You cannot reply to this topic
3 replies to this topic

#1 X3ME

  • Members
  • 82 posts
  • LocationBeing the stereotypical kid in forums.

Posted 09 September 2014 - 08: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,

#2 Agent Silence

  • Members
  • 319 posts
  • Location[string "FindMe"]:23143: bad argument #1 to 'returnPos' (vector expected, got nil)

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 X3ME

  • Members
  • 82 posts
  • LocationBeing the stereotypical kid in forums.

Posted 09 September 2014 - 09:05 PM

View PostAgent 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 :D!

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

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