1214 posts
Location
The Sammich Kingdom
Posted 14 December 2012 - 07:02 AM
My suggestion is that os.pullEvent will tell you the x and y position the key was pressed in. This will allow use to make cool menus where you hover over a location, press a certain button and something will happen.
The format should be like this:
event, key, x, y = os.pullEvent("key")
if key == key.s and x == 1 and y == 1 then
print("Yay!")
end
I just know Cloudy is going to come in and be a smartass… but that is why we love him :D/>
1054 posts
Posted 14 December 2012 - 07:04 AM
You can press keys with you mouse not even over the screen. I would rather suggest to have a simple Mouse API that you can query for current mouse coordinates and maybe button state. I think it's best to try and keep key and mouse stuff seperated.
1214 posts
Location
The Sammich Kingdom
Posted 14 December 2012 - 07:07 AM
You can press keys with you mouse not even over the screen. I would rather suggest to have a simple Mouse API that you can query for current mouse coordinates and maybe button state. I think it's best to try and keep key and mouse stuff seperated.
Hasn't that been suggested and Cloudy said they cannot do it because of multi-player problems?
3790 posts
Location
Lincoln, Nebraska
Posted 14 December 2012 - 07:17 AM
I don't think that could work…
How would you collect the mouse x,y events; without clicking? I think that you would have to constantly get the mouse position for every tick. Wouldn't that cause some major problems java side? I have no idea how that could be coded in.
1214 posts
Location
The Sammich Kingdom
Posted 14 December 2012 - 07:19 AM
I don't think that could work…
How would you collect the mouse x,y events; without clicking? I think that you would have to constantly get the mouse position for every tick. Wouldn't that cause some major problems java side? I have no idea how that could be coded in.
I was suggesting that when a key is pressed it grabs the mouse position and returns it.
1054 posts
Posted 14 December 2012 - 07:28 AM
I don't think that could work…
How would you collect the mouse x,y events; without clicking? I think that you would have to constantly get the mouse position for every tick. Wouldn't that cause some major problems java side? I have no idea how that could be coded in.
I was suggesting that when a key is pressed it grabs the mouse position and returns it.
Implementation wise, that would indeed be better. You couldn't know which mouse position you need without a reference, and the player pressing the key could be that reference. But it just doesn't seem right to receive mouse info through a key press event…
2447 posts
Posted 14 December 2012 - 08:51 AM
Mouse and keyboard should be separate IMO - and a function to get where a players mouse isn't going to happen. Not really feasible in a multi user environment.
1214 posts
Location
The Sammich Kingdom
Posted 14 December 2012 - 08:58 AM
Mouse and keyboard should be separate IMO - and a function to get where a players mouse isn't going to happen. Not really feasible in a multi user environment.
That is why I suggested this. I thought getting the mouse position with key events would eliminate the problems with multiple users. But I do see that keyboard and mouse support should be separate.