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

ComputerCraft Control System with Touchpad

Started by maxirocker, 26 April 2014 - 03:27 PM
maxirocker #1
Posted 26 April 2014 - 05:27 PM
Hey Forum,

I've a question about a CC Program by me to Control my Nuclear Reaktor's with CC. I will turn out a rs Output with a Touchpad. But when i click on my monitor, it doesn't work.

Im sorry for my bad english, i hope you understand me!

Here The Code:


-- Anfang Einstellungen --

monitor = peripheral.wrap("top")
monitor.setTextScale(1)
monitor.setTextColor(colors.lime)

monitor.clear()

-- Ende Einstellungen --

-- Anfang Layout --

monitor.setCursorPos(1,2)
  monitor.write("==================================================")
monitor.setCursorPos(1,10)
  monitor.write("--------------------------------------------------")
monitor.setCursorPos(1,18)
  monitor.write("==================================================")
monitor.setCursorPos(26,3)
  monitor.write("-")
monitor.setCursorPos(1,4)
  monitor.write("--------------------------------------------------")
monitor.setCursorPos(26,5)
  monitor.write("-")
monitor.setCursorPos(26,6)
  monitor.write("-")
monitor.setCursorPos(26,7)
  monitor.write("-")
monitor.setCursorPos(26,8)
  monitor.write("-")
monitor.setCursorPos(26,9)
  monitor.write("-")
monitor.setCursorPos(26,11)
  monitor.write("-")
monitor.setCursorPos(26,12)
  monitor.write("-")
monitor.setCursorPos(26,13)
  monitor.write("-")
monitor.setCursorPos(26,14)
  monitor.write("-")
monitor.setCursorPos(26,15)
  monitor.write("-")
monitor.setCursorPos(1,16)
  monitor.write("--------------------------------------------------")
monitor.setCursorPos(26,17)
  monitor.write("-")

-- Ende Layout --

-- Anfang Inhalt --

monitor.setCursorPos(9,3)
  monitor.write("Reaktor 1")
monitor.setCursorPos(35,3)
  monitor.write("Reaktor 2")
monitor.setCursorPos(9,17)
  monitor.write("Reaktor 3")
monitor.setCursorPos(35,17)
  monitor.write("Reaktor 4")

-- Ende Inhalt --

-- Anfang Buttons --

monitor.setBackgroundColor(colors.orange)
monitor.setTextColor(colors.black)

monitor.setCursorPos(8,7)
  monitor.write(" ON / OFF ")
monitor.setCursorPos(34,7)
  monitor.write(" ON / OFF ")
monitor.setCursorPos(8,13)
  monitor.write(" ON / OFF ")
monitor.setCursorPos(34,13)
  monitor.write(" ON / OFF ")

monitor.setBackgroundColor(colors.black)
monitor.setTextColor(colors.lime)
monitor.setCursorPos(1,1)

-- Ende Buttons --

-- Anfang der Click Funktion --

mouseWidth = 0
mouseHeight = 0

  function checkClickPosition()
    if mouseWidth > 8 and mouseWidth < 18 and mouseHeight == 7 then
	  rs.setBundledOutput("back", colors.red)
	  sleep(1)
	  rs.setBundledOutput("back", colors.black)
	
    elseif mouseWidth > 34 and mouseWidth < 44 and mouseHeight == 7 then
	  rs.setBundledOutput("back", colors.blue)
	  sleep(1)
	  rs.setBundledOutput("back", colors.black)
	
    elseif mouseWidth > 8 and mouseWidth < 18 and mouseHeight == 13 then
	  rs.setBundledOutput("back", colors.green)
	  sleep(1)
	  rs.setBundledOutput("back",colors.black)
	
    elseif mouseWidth > 34 and mouseWidth < 44 and mouseHeight == 13 then
	  rs.setBundledOutput("back", colors.yellow)
	  sleep(1)
	  rs.setBundledOutput("back",colors.black)
	
    end
  end

-- Ende der Click Funktion --

-- Anfang der Click Einstellungen --

repeat

  event,p1,p2,p3 = os.pullEvent()

  if event == "monitor_touch" then

    mouseWidth = p2
    mouseHeight = p3
    checkClickPosition()
  end

until event == "char" and p1 == ("x")

-- Ende der Click Einstellungen --


w,h=monitor.getSize()

print(w)
print(h)

You can ignore my personal notices.

Thanks for help
YoYoYonnY #2
Posted 26 April 2014 - 09:00 PM
Please re-install project red. If you replace rs.setBundledOutput with rs.setOutput it works fine.
BTW I have no idea if project red works together with ComputerCraft ( project red ~= redpower ).

-- Anfang Einstellungen --

monitor = peripheral.wrap("top")
monitor.setTextScale(1)
monitor.setTextColor(colors.lime)

monitor.clear()

-- Ende Einstellungen --

-- Anfang Layout --

monitor.setCursorPos(1,2)
  monitor.write("==================================================")
monitor.setCursorPos(1,10)
  monitor.write("--------------------------------------------------")
monitor.setCursorPos(1,18)
  monitor.write("==================================================")
monitor.setCursorPos(26,3)
  monitor.write("-")
monitor.setCursorPos(1,4)
  monitor.write("--------------------------------------------------")
monitor.setCursorPos(26,5)
  monitor.write("-")
monitor.setCursorPos(26,6)
  monitor.write("-")
monitor.setCursorPos(26,7)
  monitor.write("-")
monitor.setCursorPos(26,8)
  monitor.write("-")
monitor.setCursorPos(26,9)
  monitor.write("-")
monitor.setCursorPos(26,11)
  monitor.write("-")
monitor.setCursorPos(26,12)
  monitor.write("-")
monitor.setCursorPos(26,13)
  monitor.write("-")
monitor.setCursorPos(26,14)
  monitor.write("-")
monitor.setCursorPos(26,15)
  monitor.write("-")
monitor.setCursorPos(1,16)
  monitor.write("--------------------------------------------------")
monitor.setCursorPos(26,17)
  monitor.write("-")

-- Ende Layout --

-- Anfang Inhalt --

monitor.setCursorPos(9,3)
  monitor.write("Reaktor 1")
monitor.setCursorPos(35,3)
  monitor.write("Reaktor 2")
monitor.setCursorPos(9,17)
  monitor.write("Reaktor 3")
monitor.setCursorPos(35,17)
  monitor.write("Reaktor 4")

-- Ende Inhalt --

-- Anfang Buttons --

monitor.setBackgroundColor(colors.orange)
monitor.setTextColor(colors.black)

monitor.setCursorPos(8,7)
  monitor.write(" ON / OFF ")
monitor.setCursorPos(34,7)
  monitor.write(" ON / OFF ")
monitor.setCursorPos(8,13)
  monitor.write(" ON / OFF ")
monitor.setCursorPos(34,13)
  monitor.write(" ON / OFF ")

monitor.setBackgroundColor(colors.black)
monitor.setTextColor(colors.lime)
monitor.setCursorPos(1,1)

-- Ende Buttons --

-- Anfang der Click Funktion --

mouseWidth = 0
mouseHeight = 0

  function checkClickPosition()
    if mouseWidth > 8 and mouseWidth < 18 and mouseHeight == 7 then
          rs.setOutput("back", true)
          sleep(1)
          rs.setOutput("back", false)
        
    elseif mouseWidth > 34 and mouseWidth < 44 and mouseHeight == 7 then
          rs.setOutput("back", true)
          sleep(1)
          rs.setOutput("back", false)
        
    elseif mouseWidth > 8 and mouseWidth < 18 and mouseHeight == 13 then
          rs.setOutput("back", true)
          sleep(1)
          rs.setOutput("back",false)
        
    elseif mouseWidth > 34 and mouseWidth < 44 and mouseHeight == 13 then
          rs.setOutput("back", true)
          sleep(1)
          rs.setOutput("back",false)
        
    end
  end

-- Ende der Click Funktion --

-- Anfang der Click Einstellungen --

repeat

  event,p1,p2,p3 = os.pullEvent()

  if event == "monitor_touch" then

    mouseWidth = p2
    mouseHeight = p3
    checkClickPosition()
  end

until event == "char" and p1 == ("x")

-- Ende der Click Einstellungen --


w,h=monitor.getSize()

print(w)
print(h)
Bomb Bloke #3
Posted 26 April 2014 - 10:38 PM
But when i click on my monitor, it doesn't work.

You forgot to explain what DOES happen.

What sort of cables are you using, and which version of ComputerCraft?
maxirocker #4
Posted 27 April 2014 - 10:27 AM
I'm sorry.

I use the Computercraft for Minecraft 1.6.4 (FTB Monster) [Edit by Bubba: CC 1.58]. At the back from the computer are Bundled Cable.
When i click on my monitor, it doesn't give a Redstone Output - Why?.

I'm sorry for my bad english.
Edited on 27 April 2014 - 02:35 PM
maxirocker #5
Posted 01 May 2014 - 06:54 PM
My question ist up-to-date!
OczkoSX #6
Posted 01 May 2014 - 08:45 PM
ComputerCraft doesn't like ProjectRed's bundled cables, only red alloy wire :<
Bomb Bloke #7
Posted 02 May 2014 - 02:02 AM
If it's ComputerCraft 1.58, then RedNet cable from MineFactory Reloaded should work.
maxirocker #8
Posted 06 May 2014 - 07:29 PM
Okay, thank you everybody very much for quick help :)/>