Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Definition des variables
  2. mSide = "top"
  3. cellSide = "back"
  4. redstoneSide = "right"
  5. m = peripheral.wrap(mSide)
  6. cell = peripheral.wrap(cellSide)
  7. mouseWidth = 0
  8. mouseHeight = 0
  9. rsOut = 0
  10. -- Set rs output to false
  11. redstone.setOutput("right", false)
  12. -- Affichage du moniteur
  13. m.clear()
  14. m.setTextScale(0.5)
  15.  
  16. w, h = m.getSize()
  17. print(w)
  18. print(h)
  19.  
  20. m.setBackgroundColour(colours.black)
  21. m.setCursorPos(w/8,h/4)
  22. m.write("Energy :",cell.getEnergyStored(),"/",cell.getMaxEnergyStored())
  23.  
  24. m.setCursorPos(w/8,h/2)
  25. m.write("Moteurs :")
  26. m.setTextScale(1)
  27. m.setCursorPos(w/2,h/2)
  28. m.setBackgroundColour(colours.lime)
  29. m.write(" ON ")
  30. m.setCursorPos(w/2,h)
  31. m.setBackgroundColour(colours.red)
  32. m.write(" OFF ")
  33.  
  34. m.setTextScale(0.5)
  35. m.setBackgroundColour(colours.black)
  36.  
  37. function checkClickPosition()
  38.   if mouseWidth > 1 and mouseWidth < w and mouseHeight == h/2 then
  39.     -- button one clicked
  40.     redstone.setOutput(redstoneSide,false)
  41.     -- turns redstone connected to the right on
  42.   elseif mouseWidth > 1 and mouseWidth < w and mouseHeight == h then
  43.     -- button two clicked
  44.     redstone.setOutput(redstoneSide,true)
  45.     -- turns redstone connected to the left off
  46.   end -- ends the if loop
  47. end -- ends the function
  48.  
  49. while true do
  50.     m.setCursorPos(w/8,h/4)
  51.     m.write("Energy :"..cell.getEnergyStored().."/"..cell.getMaxEnergyStored())
  52.     m.setCursorPos(w/8,h/2)
  53.       event,p1,p2,p3 = os.pullEvent()
  54.   -- this line tells the computer to wait until
  55.   -- an event happens. We are waiting for a
  56.   -- touchscreen event
  57.  
  58.    if event=="monitor_touch" then
  59.    -- this checks to see if the event was a
  60.    -- touchscreen event
  61.    
  62.      mouseWidth = p2 -- sets mouseWidth
  63.      mouseHeight = p3 -- and mouseHeight
  64.      checkClickPosition() -- this runs our function
  65.      
  66.    end
  67.  
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement