mouse_scroll event

From ComputerCraft
Jump to navigation Jump to search
  • direction : number The direction that was being scrolled in. -1 is up and 1 is down.
  • x : number The X position of the mouse in the term
  • y : number The Y position of the mouse in the term

Source CC:Tweaked

Occurs every time a mousewheel scrolls.

Note Note: This event is only called on advanced terms, such as an Advanced Computer, Advanced Pocket Computer or Neural Interface.

ExampleExamplePrint coordinates
Prints the scroll direction and mouse coordinates every time the user scrolled.
local scroll_directions = { [-1] = "up", [1] = "down" }

while true do
  local event, direction, x, y = os.pullEvent("mouse_scroll")
  print("The mousewheel scrolled", scroll_directions[direction], "at", x, ",", y)