update doc/*/scripting/user-input.md
This commit is contained in:
parent
cb5d191d2f
commit
ef2c0b2370
@ -42,12 +42,21 @@ input.add_callback(bindname: str, callback: function)
|
|||||||
```
|
```
|
||||||
|
|
||||||
Add binding activation callback. Example:
|
Add binding activation callback. Example:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
input.add_callback("hud.inventory", function ()
|
input.add_callback("hud.inventory", function ()
|
||||||
print("Inventory open key pressed")
|
print("Inventory open key pressed")
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Callback may be added to a key.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
input.add_callback("key:space", function ()
|
||||||
|
print("Space pressed")
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
|
||||||
```python
|
```python
|
||||||
input.get_mouse_pos() -> {int, int}
|
input.get_mouse_pos() -> {int, int}
|
||||||
```
|
```
|
||||||
|
|||||||
@ -40,12 +40,21 @@ input.add_callback(bindname: str, callback: function)
|
|||||||
```
|
```
|
||||||
|
|
||||||
Назначает функцию, которая будет вызываться при активации привязки. Пример:
|
Назначает функцию, которая будет вызываться при активации привязки. Пример:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
input.add_callback("hud.inventory", function ()
|
input.add_callback("hud.inventory", function ()
|
||||||
print("Inventory open key pressed")
|
print("Inventory open key pressed")
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Можно назначить функцию на нажатие клавиши.
|
||||||
|
|
||||||
|
```lua
|
||||||
|
input.add_callback("key:space", function ()
|
||||||
|
print("Space pressed")
|
||||||
|
end)
|
||||||
|
```
|
||||||
|
|
||||||
```python
|
```python
|
||||||
input.get_mouse_pos() -> {int, int}
|
input.get_mouse_pos() -> {int, int}
|
||||||
```
|
```
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user