Jump to content




[lua] [question] problem with redstone and message board


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

#1 DarkBebi

  • New Members
  • 2 posts

Posted 28 December 2012 - 07:16 PM

This is my first post so here goes nothing

I have a message board and it has 1 page on it full of rules and everything! looks amazing

but I want to create multiple pages or essentially messages so I attached a redstone to my comptuer and I came up with this code
local green=false
local white=false


while true do
if rs.testBundledInput("right",colors.green) then
  if not green then
    mon = peripheral.wrap("top")
    mon.clear()
    mon.setCursorPos(1,1)
    mon.write("Rule1:Blah Blah Blah Blah")
    green=true
  end
else
   green=false
end
sleep(0.1)
end

now how do I go about to pushing the same button execute a second message? I got some help from the people on the IRC channel but the code I got back was incomplete or did not work, this was their code

local presses
lastState = 0
rs.getInput("back") 
while true do
os.pullEvent("redstone")
if lastState and not rs.getInput("back") then
lastState = false
presses = presses + 1
print(presses) elseif not
lastState and rs.getInput("back") then
lastState = true
end
end

sorry if that isnt entered the right way, got it off of IRC, lol

so that code only outputs a 1 and nothing else


Now my question is how do I create a message board that when I press a button it switches to the next page?

#2 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

Posted 28 December 2012 - 07:38 PM

Well, it would seem that the code they gave you IS only supposed to print the number of presses.

Here is some code that isn't complete but you should be able to add it to your existing code without any issues.
Code:
Spoiler

Change the redstone event logic to whatever it is your setup is. I'm not all that familiar with bundled cables so I don't think I'll be much help in that department, but it looks like you should be able to handle that.

Hope I helped,
PaymentOption.

#3 DarkBebi

  • New Members
  • 2 posts

Posted 28 December 2012 - 11:17 PM

thank you so much Grim Reaper but i am a complete noob at this sort of stuff right now, my code is basically an elevator code that I whipped up, and I used multiple buttons for that to work so using 1 button to display multiple parts of text is beyond me. I have typed in your code in cc and i got a
bios:355: bad argument: string expected, got nil

don't know how to fix that, never got that problem before





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users