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

Collection of random changes and improvements #380

Merged
merged 24 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5dfd248
button thing
Mr-Auto Jan 21, 2024
088ef8e
expose `level_config` thru `LevelGenSystem`
Mr-Auto Jan 21, 2024
8c2ddc0
Make sure there is only one `Memory` struct and safeguard it's members
Mr-Auto Mar 6, 2024
268359a
Merge remote-tracking branch 'origin/main' into stuff
Mr-Auto Mar 29, 2024
1693445
change small things for nicer formatting, optimise small functions by…
Mr-Auto Mar 29, 2024
8e5322c
update doc, add `inline` and `[[nodiscard]]` to the filter, move `get…
Mr-Auto Mar 30, 2024
ee02ec6
also filter out `[[maybe_unused]]`, move mask functions to `Flag func…
Mr-Auto Mar 30, 2024
11307bd
improve `fix_liquid_out_of_bounds` description
Mr-Auto Mar 30, 2024
e48587f
add clonegun, elixir and player bag, (challenge rewards) to `replace_…
Mr-Auto Mar 30, 2024
98b02ef
remove limitation in `change_sunchallenge_spawns` by using `patch_and…
Mr-Auto Mar 31, 2024
455d2ee
make `prng:random_int` always return a value, some small optimisation…
Mr-Auto Mar 31, 2024
d642e15
add `get_entities_overlaping_grid`, fix `door:unlock` not updating th…
Mr-Auto Apr 1, 2024
9616bc0
hide debug message
Mr-Auto Apr 1, 2024
ecdf6ca
fix `Movable:set_cursed` missing parameter
Mr-Auto Apr 7, 2024
021fd66
add function to add movable entity to the liquid collision (the game …
Mr-Auto Apr 7, 2024
cd7c1e9
fix lavaman's spawn logic in back layer
Mr-Auto Apr 7, 2024
88dfdeb
fix underwater bubbles logic, fix documentation, update docs, expose …
Mr-Auto Apr 13, 2024
adfde20
clang format changes
Mr-Auto Apr 13, 2024
0a00b65
force patterns to be writen as string_view to avoid null termination
Mr-Auto Apr 21, 2024
9d0c0f7
some self review stuff
Mr-Auto Apr 21, 2024
5e9488d
correct the layer size (the extra stuff was just end buckets for the …
Mr-Auto May 5, 2024
5e8b796
rephrase the description in `Generator` class
Mr-Auto May 7, 2024
040a187
add `get_liquid_layer`, update docs
Mr-Auto May 7, 2024
cdad11b
add variable to screen menu
Mr-Auto May 16, 2024
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
13 changes: 13 additions & 0 deletions docs/examples/Door.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--If you want the locked door to look like the closed exit door at Hundun

function close_hundun_door(door)
door:unlock(false)
for _, uid in pairs(get_entities_overlapping_grid(door.x, door.y, door.layer)) do
ent = get_entity(uid)
if ent.type.id == ENT_TYPE.BG_DOOR then
ent:set_texture(TEXTURE.DATA_TEXTURES_DECO_EGGPLANT_0)
return
end
end
end

97 changes: 64 additions & 33 deletions docs/game_data/spel2.lua

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ def print_lf(lf):
"dump_network",
"dump",
"dump_string",
"get_address",
]
):
cat = "Debug functions"
Expand All @@ -426,7 +427,7 @@ def print_lf(lf):
for subs in ["interval", "timeout", "callback", "set_on", "set_pre", "set_post"]
):
cat = "Callback functions"
elif any(subs in func["name"] for subs in ["flag"]):
elif any(subs in func["name"] for subs in ["flag", "clr_mask", "flip_mask", "set_mask", "test_mask"]):
cat = "Flag functions"
elif any(subs in func["name"] for subs in ["shop"]):
cat = "Shop functions"
Expand Down
3 changes: 3 additions & 0 deletions docs/generate_emmylua.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
" = nullopt": "",
"void": "",
"constexpr": "",
"inline": "",
"[[nodiscard]]": "",
"[[maybe_unused]]": "",
"...va:": "...ent_type:",
"set<": "Array<",
"span<": "Array<",
Expand Down
3 changes: 3 additions & 0 deletions docs/parse_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"constexpr": "",
"const": "",
"static": "",
"[[nodiscard]]": "",
"[[maybe_unused]]": "",
"inline": "",
# special
"variadic_args va": "ENT_TYPE, ENT_TYPE...",
"EmittedParticlesInfo": "array<Particle>",
Expand Down
149 changes: 96 additions & 53 deletions docs/src/includes/_globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,15 @@ Dump the object (table, container, class) as a recursive table, for pretty print

Hook the sendto and recvfrom functions and start dumping network data to terminal

### get_address


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

#### nil get_address(any o)

Get memory address from a lua object

### get_rva


Expand Down Expand Up @@ -448,6 +457,18 @@ Activate custom variables for speed and distance in the `ITEM_SPARK`
note: because those the variables are custom and game does not initiate them, you need to do it yourself for each spark, recommending `set_post_entity_spawn`
default game values are: speed = -0.015, distance = 3.0

### add_entity_to_liquid_collision


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

#### nil add_entity_to_liquid_collision(int uid, bool add)

Attach liquid collision to entity by uid (this is what the push blocks use)
Collision is based on the entity's hitbox, collision is removed when the entity is destroyed (bodies of killed entities will still have the collision)
Use only for entities that can move around, (for static prefer [update_liquid_collision_at](#update_liquid_collision_at) )
If entity is in back layer and liquid in the front, there will be no collision created, also collision is not destroyed when entity changes layers, so you have to handle that yourself

### apply_entity_db


Expand Down Expand Up @@ -631,10 +652,10 @@ Recommended to always set the mask, even if you look for one entity type

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

#### vector&lt;int&gt; get_entities_by_draw_depth(int draw_depth, [LAYER](#LAYER) l)

#### vector&lt;int&gt; get_entities_by_draw_depth(array<int> draw_depths, [LAYER](#LAYER) l)

#### vector&lt;int&gt; get_entities_by_draw_depth(int draw_depth, [LAYER](#LAYER) l)

Get uids of entities by draw_depth. Can also use table of draw_depths.
You can later use [filter_entities](#filter_entities) if you want specific entity

Expand All @@ -661,6 +682,15 @@ Get uids of entities matching id. This function is variadic, meaning it accepts
You can even pass a table!
This function can be slower than the [get_entities_by](#get_entities_by) with the mask parameter filled

### get_entities_overlapping_grid


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

#### vector&lt;int&gt; get_entities_overlapping_grid(float x, float y, [LAYER](#LAYER) layer)

Get uids of static entities overlaping this grid position (decorations, backgrounds etc.)

### get_entities_overlapping_hitbox


Expand Down Expand Up @@ -1102,6 +1132,15 @@ Set the visibility of a feat

Clears the nth bit in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

### clr_mask


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

#### [Flags](#Aliases) clr_mask([Flags](#Aliases) flags, [Flags](#Aliases) mask)

Clears a bitmask in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

### flip_flag


Expand All @@ -1111,6 +1150,15 @@ Clears the nth bit in a number. This doesn't actually change the variable you pa

Flips the nth bit in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

### flip_mask


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

#### [Flags](#Aliases) flip_mask([Flags](#Aliases) flags, [Flags](#Aliases) mask)

Flips the nth bit in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

### get_entity_flags


Expand Down Expand Up @@ -1174,6 +1222,15 @@ Set the nth bit in a number. This doesn't actually change the variable you pass,

Set `state.level_flags`

### set_mask


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

#### [Flags](#Aliases) set_mask([Flags](#Aliases) flags, [Flags](#Aliases) mask)

Set a bitmask in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

### test_flag


Expand All @@ -1183,6 +1240,15 @@ Set `state.level_flags`

Returns true if the nth bit is set in the number.

### test_mask


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

#### bool test_mask([Flags](#Aliases) flags, [Flags](#Aliases) mask)

Returns true if a bitmask is set in the number.

## Generic functions


Expand Down Expand Up @@ -1267,15 +1333,6 @@ Clear cache for a file path or the whole directory

Clear save state from slot 1..4.

### clr_mask


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

#### [Flags](#Aliases) clr_mask([Flags](#Aliases) flags, [Flags](#Aliases) mask)

Clears a bitmask in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

### create_image


Expand Down Expand Up @@ -1353,15 +1410,6 @@ Destroys all layers and all entities in the level. Usually a bad idea, unless yo

Disable all crust item spawns, returns whether they were already disabled before the call

### flip_mask


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

#### [Flags](#Aliases) flip_mask([Flags](#Aliases) flags, [Flags](#Aliases) mask)

Flips the nth bit in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.

### force_journal


Expand All @@ -1371,15 +1419,6 @@ Flips the nth bit in a number. This doesn't actually change the variable you pas

Force the journal to open on a chapter and entry# when pressing the journal button. Only use even entry numbers. Set chapter to `JOURNALUI_PAGE_SHOWN.JOURNAL` to reset. (This forces the journal toggle to always read from `game_manager.save_related.journal_popup_ui.entry_to_show` etc.)

### get_address


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

#### nil get_address([[maybe_unused]] any o)

Get memory address from a lua object

### get_adventure_seed


Expand Down Expand Up @@ -1479,6 +1518,15 @@ Get your sanitized script id to be used in import.

Gets the value for the specified config

### get_liquid_layer


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

#### int get_liquid_layer()

Get the current layer that the liquid is spawn in. Related function [set_liquid_layer](#set_liquid_layer)

### get_local_prng


Expand Down Expand Up @@ -1595,21 +1643,21 @@ To limit it use the parameters, so x = 10 will only grow chains from ceilings wi

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

#### nil grow_poles([LAYER](#LAYER) l, int max_lengh)

#### nil grow_poles([LAYER](#LAYER) l, int max_lengh, [AABB](#AABB) area, bool destroy_broken)

#### nil grow_poles([LAYER](#LAYER) l, int max_lengh)

Grow pole from `GROWABLE_CLIMBING_POLE` entities in a level, `area` default is whole level, `destroy_broken` default is false

### grow_vines


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

#### nil grow_vines([LAYER](#LAYER) l, int max_lengh)

#### nil grow_vines([LAYER](#LAYER) l, int max_lengh, [AABB](#AABB) area, bool destroy_broken)

#### nil grow_vines([LAYER](#LAYER) l, int max_lengh)

Grow vines from `GROWABLE_VINE` and `VINE_TREE_TOP` entities in a level, `area` default is whole level, `destroy_broken` default is false

### import
Expand Down Expand Up @@ -1964,14 +2012,16 @@ Set the value for the specified config

Setting to false disables all player logic in [SCREEN](#SCREEN).LEVEL, mainly the death screen from popping up if all players are dead or missing, but also shop camera zoom and some other small things.

### set_mask
### set_liquid_layer


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

#### [Flags](#Aliases) set_mask([Flags](#Aliases) flags, [Flags](#Aliases) mask)
#### nil set_liquid_layer([LAYER](#LAYER) l)

Set a bitmask in a number. This doesn't actually change the variable you pass, it just returns the new value you can use.
Change layer at which the liquid spawns in, THIS FUNCTION NEEDS TO BE CALLED BEFORE THE LEVEL IS BUILD, otherwise collisions and other stuff will be wrong for the newly spawned liquid
This sadly also makes lavamanders extinct, since the logic for their spawn is harcoded to front layer with bunch of other unrelated stuff (you can still spawn them with script or place them directly in level files)
Everything should be working more or less correctly (report on community discord if you find something unusual)

### set_seed

Expand Down Expand Up @@ -2096,15 +2146,6 @@ Set layer to search for storage items on

Open the journal on a chapter and page. The main Journal spread is pages 0..1, so most chapters start at 2. Use even page numbers only.

### test_mask


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

#### bool test_mask([Flags](#Aliases) flags, [Flags](#Aliases) mask)

Returns true if a bitmask is set in the number.

### toggle_journal


Expand Down Expand Up @@ -2133,9 +2174,10 @@ Gets line1_A, intersection point and line2_B and calls the 3 parameter version o

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

#### nil update_liquid_collision_at(float x, float y, bool add)
#### nil update_liquid_collision_at(float x, float y, bool add, optional<[LAYER](#LAYER)> layer = nullopt)

Updates the floor collisions used by the liquids, set add to false to remove tile of collision, set to true to add one
optional `layer` parameter to be used when liquid was moved to back layer using [set_liquid_layer](#set_liquid_layer)

### update_state

Expand Down Expand Up @@ -2645,7 +2687,9 @@ set_callback(fix_liquid_out_of_bounds, ON.FRAME)

#### nil fix_liquid_out_of_bounds()

Removes all liquid that is about to go out of bounds, which crashes the game.
Removes all liquid that is about to go out of bounds, this would normally crash the game, but playlunky/overlunky patch this bug.
The patch however does not destroy the liquids that fall pass the level bounds,
so you may still want to use this function if you spawn a lot of liquid that may fall out of the level

### game_position

Expand Down Expand Up @@ -3094,7 +3138,6 @@ Use empty table as argument to reset to the game default

Change [ENT_TYPE](#ENT_TYPE)'s spawned by `FLOOR_SUNCHALLENGE_GENERATOR`, by default there are 4:<br/>
{MONS_WITCHDOCTOR, MONS_VAMPIRE, MONS_SORCERESS, MONS_NECROMANCER}<br/>
Because of the game logic number of entity types has to be a power of 2: (1, 2, 4, 8, 16, 32), if you want say 30 types, you need to write two entities two times (they will have higher "spawn chance").
Use empty table as argument to reset to the game default

### default_spawn_is_valid
Expand Down Expand Up @@ -3325,10 +3368,10 @@ Don't overuse this, you are still restricted by the liquid pool sizes and thus m

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

#### int spawn_mushroom(float x, float y, [LAYER](#LAYER) l)

#### int spawn_mushroom(float x, float y, [LAYER](#LAYER) l, int height)

#### int spawn_mushroom(float x, float y, [LAYER](#LAYER) l)

Spawns and grows mushroom, height relates to the trunk, without it, it will roll the game default 3-5 height
Regardless, if there is not enough space, it will spawn shorter one or if there is no space even for the smallest one, it will just not spawn at all
Returns uid of the base or -1 if it wasn't able to spawn
Expand Down Expand Up @@ -3376,10 +3419,10 @@ or change it's `player_inputs` to the `input` of real player so he can control i

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

#### int spawn_tree(float x, float y, [LAYER](#LAYER) layer)

#### int spawn_tree(float x, float y, [LAYER](#LAYER) layer, int height)

#### int spawn_tree(float x, float y, [LAYER](#LAYER) layer)

Spawns and grows a tree

### spawn_unrolled_player_rope
Expand Down
Loading
Loading