Monitor API

Eventmonitor_resize
Occurs every time a connected Monitor resizes, for example when a player places or destroy Monitor blocks.
Returns
  • name : string The side or network name of the Advanced Monitor that resized
Part of CC:Tweaked
ExampleNotify about resize
Notifies the user when a connected Monitor has been resized.
Code
<nowiki>
while true do
  local event, peripheral_name = os.pullEvent("monitor_resize")
  local x, y = peripheral.call(peripheral_name, "getSize")
  print("Monitor", peripheral_name, "has been resized to", x, ",", y)
end
    </nowiki>
Eventmonitor_touch
Occurs every time a player right clicks on an advanced monitor.  Note: This event is only called on Advanced Monitors.
Returns
  • name : string The side or network name of the Advanced Monitor that got touched
  • x : number The X position of the touch
  • y : number The Y position of the touch
Part of CC:Tweaked
ExamplePrint touched coordinates
Prints the touched coordinates every time a player touches a connected Advanced Monitor.
Code
<nowiki>
while true do
  local event, peripheral_name, x, y = os.pullEvent("monitor_touch")
  print("A monitor has been pressed at " .. x .. ", " .. y)
end
    </nowiki>
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.