Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I guess we're doing UI again #345

Merged
merged 32 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
43fc95c
add levelgen flags
Dregu Oct 8, 2023
6767fa8
Merge branch 'main' into UI
Dregu Oct 11, 2023
b166e9f
Use destroy_grid in ui delete
Dregu Oct 11, 2023
ff63713
hitbox color fixes
Dregu Oct 11, 2023
3be15a4
Merge branch 'main' into UI
Dregu Oct 11, 2023
2dd67d9
add ui warp buttons to special game screens
Dregu Oct 11, 2023
26e3165
Add unload level callbacks
Dregu Oct 11, 2023
eeeeabf
rename unload_level and add pre_spawn_level
Dregu Oct 11, 2023
fdfd1ad
layer init hooks
Dregu Oct 11, 2023
0c3b6c7
add set_death_enabled
Dregu Oct 11, 2023
28337d4
add ui options to disable death and respawn players
Dregu Oct 11, 2023
6560ecb
Merge branch 'main' into UI
Dregu Oct 12, 2023
0e3294e
fix get_procedural_chance logic
Dregu Oct 12, 2023
c19bb9d
add procedural chances to ui
Dregu Oct 12, 2023
646a07b
ui chances fixes
Dregu Oct 12, 2023
e70b5cb
thank you for the useless warning
Dregu Oct 12, 2023
54a993a
run level gen callbacks for transitions
Dregu Oct 12, 2023
a312d78
testing cutscene_behavior
Dregu Oct 13, 2023
f3cdf00
fix spawn_player position
Dregu Oct 13, 2023
a9c1f3e
add layer hack to spawn_player
Dregu Oct 13, 2023
20eeb43
uglier hack that works better
Dregu Oct 14, 2023
07f6968
make it not stupid
Dregu Oct 14, 2023
a449568
remove defaults
Dregu Oct 14, 2023
5425ab7
fix docs
Dregu Oct 14, 2023
3b62a27
add patterns for new patterns
Dregu Oct 14, 2023
55584e9
fix clear_callback in movable virtual hooks
Dregu Oct 14, 2023
0aedff0
change some patterns to vtable offsets
Dregu Oct 14, 2023
27df88c
fix spawn_player uid
Dregu Oct 14, 2023
2fd3f4b
update docs
Dregu Oct 14, 2023
d375795
remove cutscenes, add some input helpers
Dregu Oct 14, 2023
1a100fd
fix crash when destroying layer with players
Dregu Oct 14, 2023
56a7322
rename and document death
Dregu Oct 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions docs/game_data/spel2.lua

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

4 changes: 3 additions & 1 deletion docs/parse_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@

cpp_type_exceptions = [
"Players",
"CutsceneBehavior",
"CustomCutsceneBehavior",
]
not_functions = [
"players",
Expand Down Expand Up @@ -892,7 +894,7 @@ def run_parse():
if not var:
continue
var = var.split(",")
if(len(var) > 1):
if len(var) > 1:
vars.append({"name": var[0], "type": var[1]})
enums.append({"name": name, "vars": vars})
data = open(file, "r").read()
Expand Down
10 changes: 9 additions & 1 deletion docs/src/includes/_enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ Name | Data | Description
[SAVE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.SAVE) | ON::SAVE | Params: [SaveContext](#SaveContext) save_ctx<br/>Runs at the same times as [ON](#ON).[SCREEN](#SCREEN), but receives the save_ctx<br/>
[LOAD](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.LOAD) | ON::LOAD | Params: [LoadContext](#LoadContext) load_ctx<br/>Runs as soon as your script is loaded, including reloads, then never again<br/>
[PRE_LOAD_LEVEL_FILES](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.PRE_LOAD_LEVEL_FILES) | ON::PRE_LOAD_LEVEL_FILES | Params: [PreLoadLevelFilesContext](#PreLoadLevelFilesContext) load_level_ctx<br/>Runs right before level files would be loaded<br/>
[PRE_LEVEL_GENERATION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.PRE_LEVEL_GENERATION) | ON::PRE_LEVEL_GENERATION | Runs before any level generation, no entities should exist at this point<br/>
[PRE_LEVEL_GENERATION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.PRE_LEVEL_GENERATION) | ON::PRE_LEVEL_GENERATION | Runs before any level generation, no entities should exist at this point. Does not work in all level-like screens. Return true to stop normal level generation.<br/>
[PRE_LOAD_SCREEN](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.PRE_LOAD_SCREEN) | ON::PRE_LOAD_SCREEN | Runs right before loading a new screen based on screen_next. Return true from callback to block the screen from loading.<br/>
[POST_ROOM_GENERATION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.POST_ROOM_GENERATION) | ON::POST_ROOM_GENERATION | Params: [PostRoomGenerationContext](#PostRoomGenerationContext) room_gen_ctx<br/>Runs right after all rooms are generated before entities are spawned<br/>
[POST_LEVEL_GENERATION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.POST_LEVEL_GENERATION) | ON::POST_LEVEL_GENERATION | Runs right after level generation is done, before any entities are updated<br/>
Expand Down Expand Up @@ -818,6 +818,14 @@ Name | Data | Description
[PRE_UPDATE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.PRE_UPDATE) | ON::PRE_UPDATE | Runs before the State is updated, runs always (menu, settings, camp, game, arena, online etc.) with the game engine, typically 60FPS<br/>Return behavior: return true to stop futher PRE_UPDATE callbacks from executing and don't update the state (this will essentially freeze the game engine)<br/>
[POST_UPDATE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.POST_UPDATE) | ON::POST_UPDATE | Runs right after the State is updated, runs always (menu, settings, camp, game, arena, online etc.) with the game engine, typically 60FPS<br/>
[USER_DATA](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.USER_DATA) | ON::USER_DATA | Params: [Entity](#Entity) ent<br/>Runs on all changes to [Entity](#Entity).user_data, including after loading saved user_data in the next level and transition. Also runs the first time user_data is set back to nil, but nil won't be saved to bother you on future levels.<br/>
[PRE_LEVEL_CREATION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.PRE_LEVEL_CREATION) | ON::PRE_LEVEL_CREATION | Runs right before the front layer is created. Runs in all screens that usually have entities, or when creating a layer manually.<br/>
[POST_LEVEL_CREATION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.POST_LEVEL_CREATION) | ON::POST_LEVEL_CREATION | Runs right after the back layer has been created and you can start spawning entities in it. Runs in all screens that usually have entities, or when creating a layer manually.<br/>
[PRE_LAYER_CREATION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.PRE_LAYER_CREATION) | ON::PRE_LAYER_CREATION | Params: [LAYER](#LAYER) layer<br/>Runs right before a layer is created. Runs in all screens that usually have entities, or when creating a layer manually.<br/>
[POST_LAYER_CREATION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.POST_LAYER_CREATION) | ON::POST_LAYER_CREATION | Params: [LAYER](#LAYER) layer<br/>Runs right after a layer has been created and you can start spawning entities in it. Runs in all screens that usually have entities, or when creating a layer manually.<br/>
[PRE_LEVEL_DESTRUCTION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.PRE_LEVEL_DESTRUCTION) | ON::PRE_LEVEL_DESTRUCTION | Runs right before the current level is unloaded and any entities destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destoyed is in state.screen_last.<br/>
[POST_LEVEL_DESTRUCTION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.POST_LEVEL_DESTRUCTION) | ON::POST_LEVEL_DESTRUCTION | Runs right after the current level has been unloaded and all entities destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destoyed is in state.screen_last.<br/>
[PRE_LAYER_DESTRUCTION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.PRE_LAYER_DESTRUCTION) | ON::PRE_LAYER_DESTRUCTION | Params: [LAYER](#LAYER) layer<br/>Runs right before a layer is unloaded and any entities there destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destoyed is in state.screen_last.<br/>
[POST_LAYER_DESTRUCTION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.POST_LAYER_DESTRUCTION) | ON::POST_LAYER_DESTRUCTION | Params: [LAYER](#LAYER) layer<br/>Runs right after a layer has been unloaded and any entities there destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destoyed is in state.screen_last.<br/>

## PARTICLEEMITTER

Expand Down
58 changes: 57 additions & 1 deletion docs/src/includes/_events.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Params: [PreLoadLevelFilesContext](#PreLoadLevelFilesContext) load_level_ctx<br/

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

Runs before any level generation, no entities should exist at this point<br/>
Runs before any level generation, no entities should exist at this point. Does not work in all level-like screens. Return true to stop normal level generation.<br/>

## ON.PRE_LOAD_SCREEN

Expand Down Expand Up @@ -549,3 +549,59 @@ Runs right after the State is updated, runs always (menu, settings, camp, game,
> Search script examples for [ON.USER_DATA](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ON.USER_DATA)

Params: [Entity](#Entity) ent<br/>Runs on all changes to [Entity](#Entity).user_data, including after loading saved user_data in the next level and transition. Also runs the first time user_data is set back to nil, but nil won't be saved to bother you on future levels.<br/>

## ON.PRE_LEVEL_CREATION


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

Runs right before the front layer is created. Runs in all screens that usually have entities, or when creating a layer manually.<br/>

## ON.POST_LEVEL_CREATION


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

Runs right after the back layer has been created and you can start spawning entities in it. Runs in all screens that usually have entities, or when creating a layer manually.<br/>

## ON.PRE_LAYER_CREATION


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

Params: [LAYER](#LAYER) layer<br/>Runs right before a layer is created. Runs in all screens that usually have entities, or when creating a layer manually.<br/>

## ON.POST_LAYER_CREATION


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

Params: [LAYER](#LAYER) layer<br/>Runs right after a layer has been created and you can start spawning entities in it. Runs in all screens that usually have entities, or when creating a layer manually.<br/>

## ON.PRE_LEVEL_DESTRUCTION


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

Runs right before the current level is unloaded and any entities destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destoyed is in state.screen_last.<br/>

## ON.POST_LEVEL_DESTRUCTION


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

Runs right after the current level has been unloaded and all entities destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destoyed is in state.screen_last.<br/>

## ON.PRE_LAYER_DESTRUCTION


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

Params: [LAYER](#LAYER) layer<br/>Runs right before a layer is unloaded and any entities there destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destoyed is in state.screen_last.<br/>

## ON.POST_LAYER_DESTRUCTION


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

Params: [LAYER](#LAYER) layer<br/>Runs right after a layer has been unloaded and any entities there destroyed. Runs in pretty much all screens, even ones without entities. The screen has already changed at this point, meaning the screen being destoyed is in state.screen_last.<br/>
47 changes: 46 additions & 1 deletion docs/src/includes/_globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,24 @@ Depending on the image size, this can take a moment, preferably don't create the
Create image from file, cropped to the geometry provided. Returns a tuple containing id, width and height.
Depending on the image size, this can take a moment, preferably don't create them dynamically, rather create all you need in global scope so it will load them as soon as the game starts

### create_layer


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

#### nil create_layer(int layer)

Initializes an empty layer that doesn't currently exist.

### create_level


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

#### nil create_level()

Initializes an empty front and back layer that don't currently exist. Does nothing(?) if layers already exist.

### destroy_grid


Expand All @@ -1217,6 +1235,24 @@ Depending on the image size, this can take a moment, preferably don't create the
Destroy the grid entity (by uid or position), and its item entities, removing them from the grid without dropping particles or gold.
Will also destroy monsters or items that are standing on a linked activefloor or chain, though excludes [MASK](#MASK).PLAYER to prevent crashes

### destroy_layer


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

#### nil destroy_layer(int layer)

Destroys a layer and all entities in it.

### destroy_level


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

#### nil destroy_level()

Destroys all layers and all entities in the level. Usually a bad idea, unless you also call create_level and spawn the player back in.

### disable_floor_embeds


Expand Down Expand Up @@ -1593,6 +1629,15 @@ Set the current adventure seed pair

Same as `Player.set_heart_color`

### set_death_enabled


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

#### nil set_death_enabled(bool enable)

Setting to false disables the death screen from popping up for any usual reason, can still load manually

### set_ending_unlock


Expand Down Expand Up @@ -2995,7 +3040,7 @@ Short for [spawn_entity_over](#spawn_entity_over)

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

#### nil spawn_player(int player_slot, float x, float y)
#### int spawn_player(int player_slot, optional<float> x, optional<float> y, optional<[LAYER](#LAYER)> layer)

Spawn a player in given location, if player of that slot already exist it will spawn clone, the game may crash as this is very unexpected situation
If you want to respawn a player that is a ghost, set in his [Inventory](#Inventory) `health` to above 0, and `time_of_death` to 0 and call this function, the ghost entity will be removed automatically
Expand Down
Loading
Loading