diff --git a/docs/game_data/spel2.lua b/docs/game_data/spel2.lua index fae909481..63eef3c97 100644 --- a/docs/game_data/spel2.lua +++ b/docs/game_data/spel2.lua @@ -1371,16 +1371,16 @@ function set_character_heart_color(type_id, color) end ---@return CustomMovableBehavior function make_custom_behavior(behavior_name, state_id, base_behavior) end ---Get the [ParticleDB](https://spelunky-fyi.github.io/overlunky/#ParticleDB) details of the specified ID ----@param id integer +---@param id PARTICLEEMITTER ---@return ParticleDB function get_particle_type(id) end ---Generate particles of the specified type around the specified entity uid (use e.g. `local emitter = generate_world_particles(PARTICLEEMITTER.PETTING_PET, players[1].uid)`). You can then decouple the emitter from the entity with `emitter.entity_uid = -1` and freely move it around. See the `particles.lua` example script for more details. ----@param particle_emitter_id integer +---@param particle_emitter_id PARTICLEEMITTER ---@param uid integer ---@return ParticleEmitterInfo function generate_world_particles(particle_emitter_id, uid) end ---Generate particles of the specified type at a certain screen coordinate (use e.g. `local emitter = generate_screen_particles(PARTICLEEMITTER.CHARSELECTOR_TORCHFLAME_FLAMES, 0.0, 0.0)`). See the `particles.lua` example script for more details. ----@param particle_emitter_id integer +---@param particle_emitter_id PARTICLEEMITTER ---@param x number ---@param y number ---@return ParticleEmitterInfo @@ -3610,7 +3610,7 @@ function Movable:generic_update_world(move, sprint_factor, disable_gravity, on_r ---@field emitted_light Illumination ---@class FlameSize : Flame - ---@field flame_size number @if changed, gradually goes down (0.03 per frame) to the default size + ---@field flame_size number @if changed, gradually goes down (0.03 per frame) to the default size, it's the base value for `entity.width` and `entity.height` ---@class ClimbableRope : Movable ---@field segment_nr_inverse integer @@ -4367,7 +4367,7 @@ function MovableBehavior:get_state_id() end ---@field set_get_next_state_id fun(self, get_next_state_id: fun(movable: Movable, base_fun: function): integer): nil @Set the `get_next_state_id` function of a `CustomMovableBehavior`, this will be called every frame when
the movable is updated. If an `get_next_state_id` is already set it will be overridden. The signature
of the function is `int get_next_state_id(Movable movable, function base_fun))`, use this to move to another state, return `nil`.
or this behaviors `state_id` to remain in this behavior. If no base behavior is set `base_fun` will be `nil`. ---@class ParticleDB - ---@field id integer + ---@field id PARTICLEEMITTER ---@field spawn_count_min integer ---@field spawn_count integer ---@field lifespan_min integer @@ -4400,6 +4400,7 @@ function MovableBehavior:get_state_id() end ---@class ParticleEmitterInfo ---@field particle_type ParticleDB + ---@field particle_type2 ParticleDB ---@field particle_count integer ---@field particle_count_back_layer integer ---@field entity_uid integer @@ -4407,6 +4408,8 @@ function MovableBehavior:get_state_id() end ---@field y number ---@field offset_x number ---@field offset_y number + ---@field layer integer + ---@field draw_depth integer ---@field emitted_particles Particle[] ---@field emitted_particles_back_layer Particle[] @@ -5348,6 +5351,7 @@ function VanillaRenderContext:draw_world_poly_filled(points, color) end ---@field y number ---@field rotate fun(self, angle: number, px: number, py: number): Vec2 ---@field distance_to fun(self, other: Vec2): number @Just simple pythagoras theorem + ---@field set fun(self, other: Vec2): Vec2 ---@field split fun(self): number, number ---@class AABB @@ -5362,6 +5366,7 @@ function VanillaRenderContext:draw_world_poly_filled(points, color) end ---@field center fun(self): number, number @Short for `(aabb.left + aabb.right) / 2.0f, (aabb.top + aabb.bottom) / 2.0f`. ---@field width fun(self): number @Short for `aabb.right - aabb.left`. ---@field height fun(self): number @Short for `aabb.top - aabb.bottom`. + ---@field set fun(self, other: AABB): AABB ---@field split fun(self): number, number, number, number local AABB = nil ---Grows or shrinks the AABB by the given amount in all directions. @@ -5393,6 +5398,7 @@ function AABB:is_point_inside(x, y) end ---@field get_angles fun(self): number, number, number @Returns ABC, BCA, CAB angles in radians ---@field scale fun(self, scale: number): Triangle ---@field area fun(self): number + ---@field set fun(self, other: Triangle): Triangle ---@field split fun(self): Vec2, Vec2, Vec2 @Returns the corner points local Triangle = nil ---@param off Vec2 @@ -5428,6 +5434,7 @@ function Triangle:is_point_inside(x, y, epsilon) end ---@field rotate fun(self, angle: number, px: number, py: number): Quad @Rotates a Quad by an angle, px/py are not offsets, use `:get_AABB():center()` to get approximated center for simetrical quadrangle ---@field flip_horizontally fun(self): Quad ---@field flip_vertically fun(self): Quad + ---@field set fun(self, other: Quad): Quad ---@field split fun(self): Vec2, Vec2, Vec2, Vec2 @Returns the corners in order: bottom_left, bottom_right, top_right, top_left local Quad = nil ---Check if point lies inside of triangle @@ -5833,7 +5840,7 @@ function Quad:is_point_inside(x, y, epsilon) end ---@field page_timer integer ---@field fade_timer integer ---@field opacity integer - ---@field pages JournalPage[] @Stores pages loaded into memeory. It's not cleared after the journal is closed or when you go back to the main (menu) page.
Use `:get_type()` to chcek page type and cast it correctly (see ON.[RENDER_POST_DRAW_DEPTH](#ON-RENDER_PRE_JOURNAL_PAGE)) + ---@field pages JournalPage[] @Stores pages loaded into memeory. It's not cleared after the journal is closed or when you go back to the main (menu) page.
Use `:get_type()` to chcek page type and cast it correctly (see ON.[RENDER_PRE_JOURNAL_PAGE](#ON-RENDER_PRE_JOURNAL_PAGE)) ---@class JournalPage ---@field background TextureRenderingInfo @@ -6339,6 +6346,14 @@ function EntityDB:new(other) end ---@return EntityDB function EntityDB:new(other) end +ParticleDB = nil +---@param other ParticleDB +---@return ParticleDB +function ParticleDB:new(other) end +---@param particle_id PARTICLEEMITTER +---@return ParticleDB +function ParticleDB:new(particle_id) end + CustomTheme = nil ---Create a new theme with an id and base theme, overriding defaults. Check [theme functions that are default enabled here](https://github.com/spelunky-fyi/overlunky/blob/main/src/game_api/script/usertypes/level_lua.cpp). ---@param theme_id_ integer diff --git a/docs/src/includes/_globals.md b/docs/src/includes/_globals.md index 85141bcde..fb4b69e9b 100644 --- a/docs/src/includes/_globals.md +++ b/docs/src/includes/_globals.md @@ -2417,7 +2417,7 @@ Extinguish a particle emitter (use the return value of `generate_world_particles > Search script examples for [generate_screen_particles](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=generate_screen_particles) -#### [ParticleEmitterInfo](#ParticleEmitterInfo) generate_screen_particles(int particle_emitter_id, float x, float y) +#### [ParticleEmitterInfo](#ParticleEmitterInfo) generate_screen_particles([PARTICLEEMITTER](#PARTICLEEMITTER) particle_emitter_id, float x, float y) Generate particles of the specified type at a certain screen coordinate (use e.g. `local emitter = generate_screen_particles(PARTICLEEMITTER.CHARSELECTOR_TORCHFLAME_FLAMES, 0.0, 0.0)`). See the `particles.lua` example script for more details. @@ -2426,7 +2426,7 @@ Generate particles of the specified type at a certain screen coordinate (use e.g > Search script examples for [generate_world_particles](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=generate_world_particles) -#### [ParticleEmitterInfo](#ParticleEmitterInfo) generate_world_particles(int particle_emitter_id, int uid) +#### [ParticleEmitterInfo](#ParticleEmitterInfo) generate_world_particles([PARTICLEEMITTER](#PARTICLEEMITTER) particle_emitter_id, int uid) Generate particles of the specified type around the specified entity uid (use e.g. `local emitter = generate_world_particles(PARTICLEEMITTER.PETTING_PET, players[1].uid)`). You can then decouple the emitter from the entity with `emitter.entity_uid = -1` and freely move it around. See the `particles.lua` example script for more details. @@ -2435,7 +2435,7 @@ Generate particles of the specified type around the specified entity uid (use e. > Search script examples for [get_particle_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_particle_type) -#### [ParticleDB](#ParticleDB) get_particle_type(int id) +#### [ParticleDB](#ParticleDB) get_particle_type([PARTICLEEMITTER](#PARTICLEEMITTER) id) Get the [ParticleDB](#ParticleDB) details of the specified ID @@ -3946,7 +3946,7 @@ Use this only when no other approach works, this call can be expensive if overus > Search script examples for [generate_particles](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=generate_particles) -#### [ParticleEmitterInfo](#ParticleEmitterInfo) generate_particles(int particle_emitter_id, int uid) +#### [ParticleEmitterInfo](#ParticleEmitterInfo) generate_particles([PARTICLEEMITTER](#PARTICLEEMITTER) particle_emitter_id, int uid) Use `generate_world_particles` diff --git a/docs/src/includes/_types.md b/docs/src/includes/_types.md index f33db0fe8..40963f3e2 100644 --- a/docs/src/includes/_types.md +++ b/docs/src/includes/_types.md @@ -571,6 +571,7 @@ float | [width()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=width float | [height()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=height) | Short for `aabb.top - aabb.bottom`. bool | [is_point_inside(Vec2 p)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | Checks if point lies between left/right and top/bottom bool | [is_point_inside(float x, float y)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | +[AABB](#AABB) | [set(AABB other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set) | tuple<float, float, float, float> | [split()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=split) | ### BackgroundMusic @@ -810,6 +811,7 @@ float | [top_left_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=to [Quad](#Quad) | [flip_vertically()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flip_vertically) | bool | [is_point_inside(Vec2 p, optional epsilon)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | Check if point lies inside of triangle
Because of the imprecise nature of floating point values, the `epsilon` value is needed to compare the floats, the default value is `0.00001` bool | [is_point_inside(float x, float y, optional epsilon)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | +[Quad](#Quad) | [set(Quad other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set) | tuple<[Vec2](#Vec2), [Vec2](#Vec2), [Vec2](#Vec2), [Vec2](#Vec2)> | [split()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=split) | Returns the corners in order: bottom_left, bottom_right, top_right, top_left ### RenderInfo @@ -925,6 +927,7 @@ tuple<float, float, float> | [get_angles()](https://github.com/spelunky-fy float | [area()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=area) | bool | [is_point_inside(Vec2 p, optional epsilon)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | Check if point lies inside of triangle
Because of the imprecise nature of floating point values, the `epsilon` value is needed to compare the floats, the default value is `0.0001` bool | [is_point_inside(float x, float y, optional epsilon)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=is_point_inside) | +[Triangle](#Triangle) | [set(Triangle other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set) | tuple<[Vec2](#Vec2), [Vec2](#Vec2), [Vec2](#Vec2)> | [split()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=split) | Returns the corner points ### UdpServer @@ -946,6 +949,7 @@ float | [x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=x) | float | [y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=y) | [Vec2](#Vec2) | [rotate(float angle, float px, float py)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=rotate) | float | [distance_to(Vec2 other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=distance_to) | Just simple pythagoras theorem +[Vec2](#Vec2) | [set(Vec2 other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set) | tuple<float, float> | [split()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=split) | ## Input types @@ -1661,7 +1665,9 @@ Used in [ParticleDB](#ParticleDB), [get_particle_type](#get_particle_type) Type | Name | Description ---- | ---- | ----------- -int | [id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=id) | +[ParticleDB](#ParticleDB) | [new(ParticleDB other)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ParticleDB) | +[ParticleDB](#ParticleDB) | [new(PARTICLEEMITTER particle_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ParticleDB) | +[PARTICLEEMITTER](#PARTICLEEMITTER) | [id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=id) | int | [spawn_count_min](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_count_min) | int | [spawn_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=spawn_count) | int | [lifespan_min](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=lifespan_min) | @@ -1700,6 +1706,7 @@ Used in [ScreenCharacterSelect](#ScreenCharacterSelect), [ScreenTitle](#ScreenTi Type | Name | Description ---- | ---- | ----------- [ParticleDB](#ParticleDB) | [particle_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=particle_type) | +[ParticleDB](#ParticleDB) | [particle_type2](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=particle_type2) | int | [particle_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=particle_count) | int | [particle_count_back_layer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=particle_count_back_layer) | int | [entity_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=entity_uid) | @@ -1707,6 +1714,8 @@ float | [x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=x) | float | [y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=y) | float | [offset_x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset_x) | float | [offset_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset_y) | +int | [layer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=layer) | +int | [draw_depth](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=draw_depth) | array<[Particle](#Particle)> | [emitted_particles](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=emitted_particles) | array<[Particle](#Particle)> | [emitted_particles_back_layer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=emitted_particles_back_layer) | @@ -1849,7 +1858,7 @@ int | [max_page_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q= int | [page_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=page_timer) | int | [fade_timer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=fade_timer) | int | [opacity](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=opacity) | -vector<[JournalPage](#JournalPage)> | [pages](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pages) | Stores pages loaded into memeory. It's not cleared after the journal is closed or when you go back to the main (menu) page.
Use `:get_type()` to chcek page type and cast it correctly (see ON.[RENDER_POST_DRAW_DEPTH](#ON-RENDER_PRE_JOURNAL_PAGE)) +vector<[JournalPage](#JournalPage)> | [pages](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=pages) | Stores pages loaded into memeory. It's not cleared after the journal is closed or when you go back to the main (menu) page.
Use `:get_type()` to chcek page type and cast it correctly (see ON.[RENDER_PRE_JOURNAL_PAGE](#ON-RENDER_PRE_JOURNAL_PAGE)) ### OnlineLobbyScreenPlayer @@ -6037,7 +6046,7 @@ Derived from [Entity](#Entity) [Movable](#Movable) [Flame](#Flame) Type | Name | Description ---- | ---- | ----------- -float | [flame_size](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flame_size) | if changed, gradually goes down (0.03 per frame) to the default size +float | [flame_size](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=flame_size) | if changed, gradually goes down (0.03 per frame) to the default size, it's the base value for `entity.width` and `entity.height` ### Fly diff --git a/src/game_api/script/usertypes/particles_lua.cpp b/src/game_api/script/usertypes/particles_lua.cpp index bf35a1b90..4c426b1dd 100644 --- a/src/game_api/script/usertypes/particles_lua.cpp +++ b/src/game_api/script/usertypes/particles_lua.cpp @@ -44,8 +44,7 @@ void register_usertypes(sol::state& lua) lua["generate_particles"] = generate_world_particles; /// Used in ParticleDB, [get_particle_type](#get_particle_type) - auto particledb_type = lua.new_usertype("ParticleDB"); - particledb_type["new"] = sol::constructors(); + auto particledb_type = lua.new_usertype("ParticleDB", sol::constructors()); particledb_type["id"] = &ParticleDB::id; particledb_type["spawn_count_min"] = &ParticleDB::spawn_count_min; particledb_type["spawn_count"] = &ParticleDB::spawn_count;