You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: library/evt.lua
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -13,10 +13,10 @@ event = {
13
13
--> This event is sent every time a key is pressed, and continuously re-sent if they key is held down. This event should be used if you want to have a key shortcut; The textinput event should be used instead if you want to handle text input / Unicode.<br>
-->> key is the key code, a number that is usually the ascii value for the key, but for non-printable characters it may be a high number. You can find a list of key codes here: https://wiki.libsdl.org/SDLKeycodeLookup<br>
17
-
-->> scan is the scan code. This is a number that represents the physical location of a key on a keyboard. You can find a list of scan codes here: https://wiki.libsdl.org/SDLScancodeLookup<br>
18
-
-->> repeat is a boolean that tells whether this is a key repeat event (sent every so often when the key is held down). You may want to ignore this event when it is just a key repeat event<br>
19
-
-->> shift / ctrl / alt are booleans that will tell you whether those modifiers are currently held<br>
16
+
-->> **key** is the key code. This is a number that represents the symbol that may be printed on a key on a keyboard. The relation of these numbers to physical keys varies wildly across systems and keyboard layouts. The interface API provides constants you can use to compare this with: you can find a list of key codes [here](https://github.com/The-Powder-Toy/The-Powder-Toy/blob/master/src/lua/LuaSDLKeys.h) (the ones starting with SDLK, for example, interface.SDLK_a)<br>
17
+
-->> **scan** is the scan code. This is a number that represents the physical location of a key on a keyboard. You can find a list of scan codes here: https://wiki.libsdl.org/SDLScancodeLookup<br>
18
+
-->> **repeat** is a boolean that tells whether this is a key repeat event (sent every so often when the key is held down). You may want to ignore this event when it is just a key repeat event<br>
19
+
-->> **shift / ctrl / alt** are booleans that will tell you whether those modifiers are currently held<br>
20
20
KEYPRESS=2,
21
21
22
22
--### keyrelease<br>
@@ -41,31 +41,31 @@ event = {
41
41
--> This event is sent whenever the mouse is clicked.<br>
42
42
--> This event can be canceled<br>
43
43
--> Arguments: x, y, button<br>
44
-
-->> x and y will not be adjusted for the zoom window. See sim.adjustCoords for that. Coordinates may be outside of the simulation bounds (clicks outside the simulation area are still sent)<br>
45
-
-->> button is the mouse button pressed. 1 is left click, 2 is middle click, 3 is right click. There may also be higher mouse buttons like 4 and 5.<br>
44
+
-->> **x and **y** will not be adjusted for the zoom window. See sim.adjustCoords for that. Coordinates may be outside of the simulation bounds (clicks outside the simulation area are still sent)<br>
45
+
-->> **button** is the mouse button pressed. 1 is left click, 2 is middle click, 3 is right click. There may also be higher mouse buttons like 4 and 5.<br>
46
46
MOUSEDOWN=4,
47
47
48
48
--### mouseup<br>
49
49
--> This event is sent whenever the mouse is released. There are also other some special cases this event may be sent,<br>
50
50
--> This event can be canceled (only when reason = 0)<br>
51
51
--> Arguments: x, y, button, reason<br>
52
-
-->> x, y, and button function the same as the mousedown event<br>
53
-
-->> reason is a number that describes what type of mouseup event this is (basically, hacks we sent mouseup events on anyway). reason 0 is for normal mouseup events. reason 1 is used when another interface is opened and a blur event is sent. This is how tpt ensures that the mouse isn't "stuck" down forever if you release the mouse after opening another interface. reason 2 is used when the mouse moves inside or outside of the zoom window. This is how tpt cancels mouse drawing with zoom windows to ensure a big line isn't drawn across the screen. The normal reason = 0 event will still be sent later.<br>
52
+
-->> **x**, **y**, and **button** function the same as the mousedown event<br>
53
+
-->> **reason** is a number that describes what type of mouseup event this is (basically, hacks we sent mouseup events on anyway). reason 0 is for normal mouseup events. reason 1 is used when another interface is opened and a blur event is sent. This is how tpt ensures that the mouse isn't "stuck" down forever if you release the mouse after opening another interface. reason 2 is used when the mouse moves inside or outside of the zoom window. This is how tpt cancels mouse drawing with zoom windows to ensure a big line isn't drawn across the screen. The normal reason = 0 event will still be sent later.<br>
54
54
MOUSEUP=5,
55
55
56
56
--### mousemove<br>
57
57
--> This event is sent every time the mouse is moved. It is only sent when the mouse is inside the tpt window, unless the mouse is held, in which case it can also be sent outside of the tpt window until the mouse is released. Coordinates from outside the tpt window bounds (including negative coordinates) can be sent in that case.<br>
58
58
--> This event can be canceled<br>
59
59
--> Arguments: x, y, dx, dy<br>
60
-
-->> x and y are the mouse coordinates. dx and dy are the diff from the previous coordinates to the current ones.<br>
60
+
-->> **x** and **y** are the mouse coordinates. **dx** and **dy** are the diff from the previous coordinates to the current ones.<br>
61
61
MOUSEMOVE=6,
62
62
63
63
--### mousewheel<br>
64
64
--> This event is sent whenever the mousewheel is scrolled.<br>
65
65
--> This event can be canceled<br>
66
66
--> Arguments: x, y, d<br>
67
-
-->> x and y are the mouse position where the wheel was scrolled<br>
68
-
-->> d is the distance the mouse was scrolled. On nearly all mice this will be 1 or -1, but in certain situations it may be higher. You most likely want to treat higher values as 1 or -1 anyway. Horizontal scrolling is not supported at the moment, in the meantime d will be 0 for horizontal scrolling.<br>
67
+
-->> **x** and **y** are the mouse position where the wheel was scrolled<br>
68
+
-->> **d** is the distance the mouse was scrolled. On nearly all mice this will be 1 or -1, but in certain situations it may be higher. You most likely want to treat higher values as 1 or -1 anyway. Horizontal scrolling is not supported at the moment, in the meantime d will be 0 for horizontal scrolling.<br>
Copy file name to clipboardExpand all lines: library/sim.lua
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,7 @@ simulation = {}
68
68
--```
69
69
--number[] sim.partNeighbors(number x, number y, number radius, [number type])
70
70
--```
71
+
--Returns an array of indices of particles that neighbour the given coordinates and match the given type (if it is specified). The resulting array does not contain the particle at the specified position.<br>
0 commit comments