8 posts
Posted 05 November 2013 - 01:29 PM
Hey guys,i just wanted to make my own OS.So i need help with Events.especially with Mouse Click Events
Im not asking you an Entire Code i just need to Know how to Use them.I Have Some Experience with Lua Programming
I'm doing this for over a Month and i know how to Handle Several API's.Including Paintutils,Textutils,Term,Os(Not Events)
Colors,RS etc.
Please show me how to make Events…
NOTE - Dont Ask why i Put Capitals on Almost all Words :ph34r:/>
1522 posts
Location
The Netherlands
Posted 05 November 2013 - 02:27 PM
1852 posts
Location
Sweden
Posted 06 November 2013 - 09:21 AM
Let me know if this was of any use
Events
Lets start with this
local evt, p1, mX, mY = os.pullEvent()
NOTE: evt or whatever can be named to something else and are just examples
Params
evt
evt is the event that is pulled and returned from os.pullEvent
local evt = os.pullEvent()
print(evt)
List of Events
- char
- key
- mouse_click
- mouse_drag
- mouse_scroll
- monitor_touch
- monitor_resize
- disk
- disk_eject
- peripheral
- peripheral_detach
- timer
- alarm
- redstone
- terminate
- rednet_message
- modem_message
- http_success
- http_failure
- turtle_inventory
returns a string
p1
Hmm.. What is p1? Well it is the key value that is returned from the os.pullEvent function.
For the mouse the 'key values' for the buttons is 1,2 and 3 ( And for mouse scroll it's 1 and -1 )
Well 1 is basically the left mouse button, 2 is the right button and ofcourse 3 is the middle button.
For mouse scroll events the 'key values' 1 is down and -1 is up
local evt, p1 = os.pullEvent("mouse_click")
if p1 == 1 then
print("You clicked the left mouse button!")
elseif p1 == 2 then
print("You clicked the right mouse button!")
end
returns a key value
mX and mY
mX is the x position you clicked on the screen with the mouse cursor and mY is the y position
local evt, p1, mX, mY = os.pullEvent("mouse_click")
print("Clicked: " .. mX .. ":" ..mY)
returns numbers
To check key values and stuff you can run this code in the Lua prompt or a program
while true do
print(os.pullEvent())
end