Skip to content

Commit

Permalink
Merge pull request #375 from spelunky-fyi/Keys
Browse files Browse the repository at this point in the history
Hotkeys and cross tool input fixes
  • Loading branch information
Dregu authored Mar 7, 2024
2 parents 46e4655 + ea57890 commit fe5202a
Show file tree
Hide file tree
Showing 20 changed files with 834 additions and 137 deletions.
33 changes: 24 additions & 9 deletions docs/game_data/spel2.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/parse_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ def run_parse():
if not var:
continue
var = var.split(",")
if len(var) < 2:
continue
if var[0] == "sol::base_classes" or var[0] == "sol::no_constructor":
continue
if "NoDoc" in var[0]:
Expand Down
26 changes: 26 additions & 0 deletions docs/src/includes/_enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,19 @@ Name | Data | Description
[SMALL_SAD](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=GHOST_BEHAVIOR.SMALL_SAD) | GHOST_BEHAVIOR::SMALL_SAD |
[SMALL_HAPPY](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=GHOST_BEHAVIOR.SMALL_HAPPY) | GHOST_BEHAVIOR::SMALL_HAPPY |

## HOTKEY_TYPE


> Search script examples for [HOTKEY_TYPE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=HOTKEY_TYPE)


Name | Data | Description
---- | ---- | -----------
[NORMAL](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=HOTKEY_TYPE.NORMAL) | HOTKEY_TYPE::NORMAL | Suppressed when the game window is inactive or inputting text in this tool instance (get_io().wantkeyboard == true). Can't detect if OL is in a text input and script is running in PL though. Use [ImGuiIO](#ImGuiIO) if you need to do that.<br/>
[GLOBAL](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=HOTKEY_TYPE.GLOBAL) | HOTKEY_TYPE::GLOBAL | Enabled even when the game window is inactive and will capture keys even from other programs.<br/>
[INPUT](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=HOTKEY_TYPE.INPUT) | HOTKEY_TYPE::INPUT | Enabled even when inputting text and will override normal text input keys.<br/>

## HUNDUNFLAGS


Expand Down Expand Up @@ -634,6 +647,19 @@ Name | Data | Description
[A](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=KEY.A) | 65 |
...check [lua_enums.txt](game_data/lua_enums.txt)... | |

## KEY_TYPE


> Search script examples for [KEY_TYPE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=KEY_TYPE)


Name | Data | Description
---- | ---- | -----------
[ANY](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=KEY_TYPE.ANY) | KEY_TYPE::ANY |
[KEYBOARD](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=KEY_TYPE.KEYBOARD) | KEY_TYPE::KEYBOARD |
[MOUSE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=KEY_TYPE.MOUSE) | KEY_TYPE::MOUSE |

## LAYER


Expand Down
24 changes: 19 additions & 5 deletions docs/src/includes/_globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,17 @@ Set engine target frametime (1/framerate, default 1/60). Always capped by your G

Set engine target frametime when game is unfocused (1/framerate, default 1/33). Always capped by the engine frametime. Set to 0 to go as fast as possible. Call without arguments to reset.

### set_hotkey


> Search script examples for [set_hotkey](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_hotkey)
#### [CallbackId](#Aliases) set_hotkey([](function cb, [KEY](#KEY) key, [HOTKEY_TYPE](#HOTKEY_TYPE) flags)

Returns unique id >= 0 for the callback to be used in [clear_callback](#clear_callback) or -1 if the key could not be registered.
Add callback function to be called on a hotkey, using Windows hotkey api. These hotkeys will override all game and UI input and can work even when the game is unfocused. They are by design very intrusive and won't let anything else use the same key combo. Can't detect if input is active in another instance, use [ImGuiIO](#ImGuiIO) if you need Playlunky hotkeys to react to [Overlunky](#Overlunky) input state. Key is a [KEY](#KEY) combo (e.g. `KEY.OL_MOD_CTRL | KEY.X`), possibly returned by GuiDrawContext:key_picker. Doesn't work with mouse buttons.
<br/>The callback signature is nil on_hotkey([KEY](#KEY) key)

### set_infinite_loop_detection_enabled


Expand Down Expand Up @@ -2165,11 +2176,6 @@ Converts (x, y, BUTTON) to [INPUTS](#INPUTS)

Returns: [ImGuiIO](#ImGuiIO) for raw keyboard, mouse and xinput gamepad stuff.

- Note: The clicked/pressed actions only make sense in `ON.GUIFRAME`.
- Note: You can use [KEY](#KEY) or standard VK keycodes to index `keys` or the other functions.
- Note: [Overlunky](#Overlunky)/etc will eat all keys it is currently configured to use, your script will only get leftovers.
- Note: [Gamepad](#Gamepad) is basically [XINPUT_GAMEPAD](https://docs.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_gamepad) but variables are renamed and values are normalized to -1.0..1.0 range.

### get_raw_input


Expand Down Expand Up @@ -3494,6 +3500,14 @@ Will return the string of currently choosen language
Convert the hash to stringid
Check [strings00_hashed.str](https://github.com/spelunky-fyi/overlunky/blob/main/docs/game_data/strings00_hashed.str) for the hash values, or extract assets with modlunky and check those.

### key_name


> Search script examples for [key_name](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=key_name)
#### nil key_name()


### set_level_string


Expand Down
Loading

0 comments on commit fe5202a

Please sign in to comment.