Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Definition des variables
- mSide = "top"
- cellSide = "back"
- redstoneSide = "right"
- m = peripheral.wrap(mSide)
- cell = peripheral.wrap(cellSide)
- mouseWidth = 0
- mouseHeight = 0
- rsOut = 0
- -- Set rs output to false
- redstone.setOutput("right", false)
- -- Affichage du moniteur
- m.clear()
- m.setTextScale(1)
- w, h = m.getSize()
- print(w)
- print(h)
- m.setBackgroundColour(colours.black)
- m.setCursorPos(w/8,h/4)
- m.write("Energy :",cell.getEnergyStored(),"/",cell.getMaxEnergyStored())
- m.setCursorPos(w/8,h/2)
- m.write("Moteurs :")
- m.setCursorPos(w/6,h/1.5)
- m.setBackgroundColour(colours.lime)
- m.write(" ON ")
- m.setCursorPos(w/2,h/1)
- m.setBackgroundColour(colours.red)
- m.write(" OFF ")
- m.setBackgroundColour(colours.black)
- function checkClickPosition()
- if mouseWidth > 1 and mouseWidth < w and mouseHeight == h/1.5 then
- -- button one clicked
- redstone.setOutput(redstoneSide,false)
- -- turns redstone connected to the right on
- elseif mouseWidth > 1 and mouseWidth < w and mouseHeight == h/1 then
- -- button two clicked
- redstone.setOutput(redstoneSide,true)
- -- turns redstone connected to the left off
- end -- ends the if loop
- end -- ends the function
- while true do
- m.setCursorPos(w/8,h/4)
- m.write("Energy :"..cell.getEnergyStored().."/"..cell.getMaxEnergyStored())
- m.setCursorPos(w/8,h/2)
- event,p1,p2,p3 = os.pullEvent()
- -- this line tells the computer to wait until
- -- an event happens. We are waiting for a
- -- touchscreen event
- if event=="monitor_touch" then
- -- this checks to see if the event was a
- -- touchscreen event
- mouseWidth = p2 -- sets mouseWidth
- mouseHeight = p3 -- and mouseHeight
- checkClickPosition() -- this runs our function
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement