From 4da0fa83dc7a2d421388ef7fba2ec87ba701162a Mon Sep 17 00:00:00 2001
From: Mr-Auto <36127424+Mr-Auto@users.noreply.github.com>
Date: Sat, 14 Dec 2024 19:23:22 +0100
Subject: [PATCH] rename `acquire` -> `equip`, changes the comment, update docs
---
docs/game_data/spel2.lua | 18 +++++++++---------
docs/src/includes/_enums.md | 2 +-
docs/src/includes/_types.md | 18 +++++++++---------
src/game_api/entities_items.hpp | 6 +++---
.../script/usertypes/entities_items_lua.cpp | 4 ++--
src/game_api/script/usertypes/vtables_lua.cpp | 2 +-
6 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/docs/game_data/spel2.lua b/docs/game_data/spel2.lua
index 4e373567a..c18426065 100644
--- a/docs/game_data/spel2.lua
+++ b/docs/game_data/spel2.lua
@@ -2802,8 +2802,8 @@ function Entity:destroy_recursive() end
---@field set_post_picked_up fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil picked_up(Movable self)`
Virtual function docs:
Called for entity that just has been picked up
---@field set_pre_release fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool release(Movable self)`
Virtual function docs:
Called for entity that just has been thrown/dropped
---@field set_post_release fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil release(Movable self)`
Virtual function docs:
Called for entity that just has been thrown/dropped
- ---@field set_pre_generate_fall_poof_particles fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool generate_fall_poof_particles(Movable self)`
- ---@field set_post_generate_fall_poof_particles fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil generate_fall_poof_particles(Movable self)`
+ ---@field set_pre_generate_landing_effects fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool generate_landing_effects(Movable self)`
Virtual function docs:
Only for landing on the floor or activefloor, generates "poof" particle and plays sfx (note: when stunned, sfx is played by the damage function)
+ ---@field set_post_generate_landing_effects fun(self, fun: fun(self: Movable): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil generate_landing_effects(Movable self)`
Virtual function docs:
Only for landing on the floor or activefloor, generates "poof" particle and plays sfx (note: when stunned, sfx is played by the damage function)
---@field set_pre_fall fun(self, fun: fun(self: Movable, number: number): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool fall(Movable self, number number)`
Virtual function docs:
Applies gravity to entity. Disable to float like on hoverpack.
---@field set_post_fall fun(self, fun: fun(self: Movable, number: number): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil fall(Movable self, number number)`
Virtual function docs:
Applies gravity to entity. Disable to float like on hoverpack.
---@field set_pre_apply_friction fun(self, fun: fun(self: Movable, number: , vertical: boolean, number: ): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool apply_friction(Movable self, number, boolean vertical, number)`
@@ -2945,10 +2945,10 @@ function Movable:generic_update_world(move, sprint_factor, disable_gravity, on_r
---@field set_pre_virtual fun(self, entry: ENTITY_OVERRIDE, fun: function): CallbackId @Hooks before the virtual function at index `entry`.
---@field set_post_virtual fun(self, entry: ENTITY_OVERRIDE, fun: function): CallbackId @Hooks after the virtual function at index `entry`.
---@field clear_virtual fun(self, callback_id: CallbackId): nil @Clears the hook given by `callback_id`, alternatively use `clear_callback()` inside the hook.
- ---@field set_pre_enter_attempt fun(self, fun: fun(self: Door, Entity: ): number?): CallbackId @Hooks before the virtual function.
The callback signature is `optional enter_attempt(Door self, Entity)`
- ---@field set_post_enter_attempt fun(self, fun: fun(self: Door, Entity: ): number?): CallbackId @Hooks after the virtual function.
The callback signature is `nil enter_attempt(Door self, Entity)`
- ---@field set_pre_hide_hud fun(self, fun: fun(self: Door, Entity: ): number?): CallbackId @Hooks before the virtual function.
The callback signature is `optional hide_hud(Door self, Entity)`
- ---@field set_post_hide_hud fun(self, fun: fun(self: Door, Entity: ): number?): CallbackId @Hooks after the virtual function.
The callback signature is `nil hide_hud(Door self, Entity)`
+ ---@field set_pre_enter_attempt fun(self, fun: fun(self: Door, who: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool enter_attempt(Door self, Entity who)`
+ ---@field set_post_enter_attempt fun(self, fun: fun(self: Door, who: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil enter_attempt(Door self, Entity who)`
+ ---@field set_pre_hide_hud fun(self, fun: fun(self: Door, who: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool hide_hud(Door self, Entity who)`
+ ---@field set_post_hide_hud fun(self, fun: fun(self: Door, who: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil hide_hud(Door self, Entity who)`
---@field set_pre_enter fun(self, fun: fun(self: Door, who: Entity): integer?): CallbackId @Hooks before the virtual function.
The callback signature is `optional enter(Door self, Entity who)`
Virtual function docs:
Returns the entity state / behavior id to set the entity to after the entering animation.
---@field set_post_enter fun(self, fun: fun(self: Door, who: Entity): integer?): CallbackId @Hooks after the virtual function.
The callback signature is `nil enter(Door self, Entity who)`
Virtual function docs:
Returns the entity state / behavior id to set the entity to after the entering animation.
---@field set_pre_light_level fun(self, fun: fun(self: Door): number?): CallbackId @Hooks before the virtual function.
The callback signature is `optional light_level(Door self)`
Virtual function docs:
Returns the darkest light level used to fade the entity when entering or exiting. 0 = black, 1 = no change
@@ -3825,12 +3825,12 @@ function Movable:generic_update_world(move, sprint_factor, disable_gravity, on_r
---@class Projectile : Movable
---@class Purchasable : Movable
- ---@field acquire fun(self, who: Entity): nil @Be aware that for pickable items like weapons, the item will be automatically picked up by the player (unless he already holds something), the ownership transfer is a little bit slow, so it might trigger the shop keeper if you're not inside the shop.
does not consume money
+ ---@field equip fun(self, who: Entity): nil @Is called after purchase, changes the DummyPurchasableEntity into the real entity plus tries to equip it, or pick it up (for stuff like weapons), or give the powerup.
Nothing else happens, by itself it does not remove item from shop etc.
---@field set_pre_virtual fun(self, entry: ENTITY_OVERRIDE, fun: function): CallbackId @Hooks before the virtual function at index `entry`.
---@field set_post_virtual fun(self, entry: ENTITY_OVERRIDE, fun: function): CallbackId @Hooks after the virtual function at index `entry`.
---@field clear_virtual fun(self, callback_id: CallbackId): nil @Clears the hook given by `callback_id`, alternatively use `clear_callback()` inside the hook.
- ---@field set_pre_acquire fun(self, fun: fun(self: Purchasable, who: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool acquire(Purchasable self, Entity who)`
Virtual function docs:
Be aware that for pickable items like weapons, the item will be automatically picked up by the player (unless he already holds something), the ownership transfer is a little bit slow, so it might trigger the shop keeper if you're not inside the shop.
does not consume money
- ---@field set_post_acquire fun(self, fun: fun(self: Purchasable, who: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil acquire(Purchasable self, Entity who)`
Virtual function docs:
Be aware that for pickable items like weapons, the item will be automatically picked up by the player (unless he already holds something), the ownership transfer is a little bit slow, so it might trigger the shop keeper if you're not inside the shop.
does not consume money
+ ---@field set_pre_acquire fun(self, fun: fun(self: Purchasable, who: Entity): boolean): CallbackId @Hooks before the virtual function.
The callback signature is `bool acquire(Purchasable self, Entity who)`
Virtual function docs:
Is called after purchase, changes the DummyPurchasableEntity into the real entity plus tries to equip it, or pick it up (for stuff like weapons), or give the powerup.
Nothing else happens, by itself it does not remove item from shop etc.
+ ---@field set_post_acquire fun(self, fun: fun(self: Purchasable, who: Entity): boolean): CallbackId @Hooks after the virtual function.
The callback signature is `nil acquire(Purchasable self, Entity who)`
Virtual function docs:
Is called after purchase, changes the DummyPurchasableEntity into the real entity plus tries to equip it, or pick it up (for stuff like weapons), or give the powerup.
Nothing else happens, by itself it does not remove item from shop etc.
---@class DummyPurchasableEntity : Purchasable
---@field replace_entity Entity
diff --git a/docs/src/includes/_enums.md b/docs/src/includes/_enums.md
index 74ffffd4a..3e7319d9c 100644
--- a/docs/src/includes/_enums.md
+++ b/docs/src/includes/_enums.md
@@ -286,7 +286,7 @@ Name | Data | Description
[PROCESS_INPUT](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.PROCESS_INPUT) | 78 |
[PICKED_UP](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.PICKED_UP) | 80 |
[RELEASE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.RELEASE) | 81 |
-[GENERATE_FALL_POOF_PARTICLES](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.GENERATE_FALL_POOF_PARTICLES) | 82 |
+[GENERATE_LANDING_EFFECTS](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.GENERATE_LANDING_EFFECTS) | 82 |
[FALL](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.FALL) | 83 |
[APPLY_FRICTION](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.APPLY_FRICTION) | 84 |
[CAN_BREAK_BLOCK](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ENTITY_OVERRIDE.CAN_BREAK_BLOCK) | 85 |
diff --git a/docs/src/includes/_types.md b/docs/src/includes/_types.md
index 4ffae4ff0..fd45dfc35 100644
--- a/docs/src/includes/_types.md
+++ b/docs/src/includes/_types.md
@@ -3812,10 +3812,10 @@ nil | [unlock(bool unlock)](https://github.com/spelunky-fyi/overlunky/search?l=L
[CallbackId](#Aliases) | [set_pre_virtual(ENTITY_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_virtual) | Hooks before the virtual function at index `entry`.
[CallbackId](#Aliases) | [set_post_virtual(ENTITY_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_virtual) | Hooks after the virtual function at index `entry`.
nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=clear_virtual) | Clears the hook given by `callback_id`, alternatively use `clear_callback()` inside the hook.
-[CallbackId](#Aliases) | [set_pre_enter_attempt(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_enter_attempt) | Hooks before the virtual function.
The callback signature is `optional enter_attempt(Door self, Entity)`
-[CallbackId](#Aliases) | [set_post_enter_attempt(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_enter_attempt) | Hooks after the virtual function.
The callback signature is `nil enter_attempt(Door self, Entity)`
-[CallbackId](#Aliases) | [set_pre_hide_hud(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_hide_hud) | Hooks before the virtual function.
The callback signature is `optional hide_hud(Door self, Entity)`
-[CallbackId](#Aliases) | [set_post_hide_hud(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_hide_hud) | Hooks after the virtual function.
The callback signature is `nil hide_hud(Door self, Entity)`
+[CallbackId](#Aliases) | [set_pre_enter_attempt(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_enter_attempt) | Hooks before the virtual function.
The callback signature is `bool enter_attempt(Door self, Entity who)`
+[CallbackId](#Aliases) | [set_post_enter_attempt(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_enter_attempt) | Hooks after the virtual function.
The callback signature is `nil enter_attempt(Door self, Entity who)`
+[CallbackId](#Aliases) | [set_pre_hide_hud(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_hide_hud) | Hooks before the virtual function.
The callback signature is `bool hide_hud(Door self, Entity who)`
+[CallbackId](#Aliases) | [set_post_hide_hud(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_hide_hud) | Hooks after the virtual function.
The callback signature is `nil hide_hud(Door self, Entity who)`
[CallbackId](#Aliases) | [set_pre_enter(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_enter) | Hooks before the virtual function.
The callback signature is `optional enter(Door self, Entity who)`
Virtual function docs:
Returns the entity state / behavior id to set the entity to after the entering animation.
[CallbackId](#Aliases) | [set_post_enter(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_enter) | Hooks after the virtual function.
The callback signature is `nil enter(Door self, Entity who)`
Virtual function docs:
Returns the entity state / behavior id to set the entity to after the entering animation.
[CallbackId](#Aliases) | [set_pre_light_level(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_light_level) | Hooks before the virtual function.
The callback signature is `optional light_level(Door self)`
Virtual function docs:
Returns the darkest light level used to fade the entity when entering or exiting. 0 = black, 1 = no change
@@ -7078,8 +7078,8 @@ nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/ov
[CallbackId](#Aliases) | [set_post_picked_up(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_picked_up) | Hooks after the virtual function.
The callback signature is `nil picked_up(Movable self)`
Virtual function docs:
Called for entity that just has been picked up
[CallbackId](#Aliases) | [set_pre_release(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_release) | Hooks before the virtual function.
The callback signature is `bool release(Movable self)`
Virtual function docs:
Called for entity that just has been thrown/dropped
[CallbackId](#Aliases) | [set_post_release(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_release) | Hooks after the virtual function.
The callback signature is `nil release(Movable self)`
Virtual function docs:
Called for entity that just has been thrown/dropped
-[CallbackId](#Aliases) | [set_pre_generate_fall_poof_particles(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_generate_fall_poof_particles) | Hooks before the virtual function.
The callback signature is `bool generate_fall_poof_particles(Movable self)`
-[CallbackId](#Aliases) | [set_post_generate_fall_poof_particles(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_generate_fall_poof_particles) | Hooks after the virtual function.
The callback signature is `nil generate_fall_poof_particles(Movable self)`
+[CallbackId](#Aliases) | [set_pre_generate_landing_effects(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_generate_landing_effects) | Hooks before the virtual function.
The callback signature is `bool generate_landing_effects(Movable self)`
Virtual function docs:
Only for landing on the floor or activefloor, generates "poof" particle and plays sfx (note: when stunned, sfx is played by the damage function)
+[CallbackId](#Aliases) | [set_post_generate_landing_effects(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_generate_landing_effects) | Hooks after the virtual function.
The callback signature is `nil generate_landing_effects(Movable self)`
Virtual function docs:
Only for landing on the floor or activefloor, generates "poof" particle and plays sfx (note: when stunned, sfx is played by the damage function)
[CallbackId](#Aliases) | [set_pre_fall(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_fall) | Hooks before the virtual function.
The callback signature is `bool fall(Movable self, float float)`
Virtual function docs:
Applies gravity to entity. Disable to float like on hoverpack.
[CallbackId](#Aliases) | [set_post_fall(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_fall) | Hooks after the virtual function.
The callback signature is `nil fall(Movable self, float float)`
Virtual function docs:
Applies gravity to entity. Disable to float like on hoverpack.
[CallbackId](#Aliases) | [set_pre_apply_friction(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_apply_friction) | Hooks before the virtual function.
The callback signature is `bool apply_friction(Movable self, float, bool vertical, float)`
@@ -7278,12 +7278,12 @@ Derived from [Entity](#Entity) [Movable](#Movable)
Type | Name | Description
---- | ---- | -----------
-nil | [acquire(Entity who)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=acquire) | Be aware that for pickable items like weapons, the item will be automatically picked up by the player (unless he already holds something), the ownership transfer is a little bit slow, so it might trigger the shop keeper if you're not inside the shop.
does not consume money
+nil | [equip(Entity who)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=equip) | Is called after purchase, changes the [DummyPurchasableEntity](#DummyPurchasableEntity) into the real entity plus tries to equip it, or pick it up (for stuff like weapons), or give the powerup.
Nothing else happens, by itself it does not remove item from shop etc.
[CallbackId](#Aliases) | [set_pre_virtual(ENTITY_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_virtual) | Hooks before the virtual function at index `entry`.
[CallbackId](#Aliases) | [set_post_virtual(ENTITY_OVERRIDE entry, function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_virtual) | Hooks after the virtual function at index `entry`.
nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=clear_virtual) | Clears the hook given by `callback_id`, alternatively use `clear_callback()` inside the hook.
-[CallbackId](#Aliases) | [set_pre_acquire(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_acquire) | Hooks before the virtual function.
The callback signature is `bool acquire(Purchasable self, Entity who)`
Virtual function docs:
Be aware that for pickable items like weapons, the item will be automatically picked up by the player (unless he already holds something), the ownership transfer is a little bit slow, so it might trigger the shop keeper if you're not inside the shop.
does not consume money
-[CallbackId](#Aliases) | [set_post_acquire(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_acquire) | Hooks after the virtual function.
The callback signature is `nil acquire(Purchasable self, Entity who)`
Virtual function docs:
Be aware that for pickable items like weapons, the item will be automatically picked up by the player (unless he already holds something), the ownership transfer is a little bit slow, so it might trigger the shop keeper if you're not inside the shop.
does not consume money
+[CallbackId](#Aliases) | [set_pre_acquire(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_acquire) | Hooks before the virtual function.
The callback signature is `bool acquire(Purchasable self, Entity who)`
Virtual function docs:
Is called after purchase, changes the DummyPurchasableEntity into the real entity plus tries to equip it, or pick it up (for stuff like weapons), or give the powerup.
Nothing else happens, by itself it does not remove item from shop etc.
+[CallbackId](#Aliases) | [set_post_acquire(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_acquire) | Hooks after the virtual function.
The callback signature is `nil acquire(Purchasable self, Entity who)`
Virtual function docs:
Is called after purchase, changes the DummyPurchasableEntity into the real entity plus tries to equip it, or pick it up (for stuff like weapons), or give the powerup.
Nothing else happens, by itself it does not remove item from shop etc.
### PushBlock
diff --git a/src/game_api/entities_items.hpp b/src/game_api/entities_items.hpp
index 7245214ff..caecf8891 100644
--- a/src/game_api/entities_items.hpp
+++ b/src/game_api/entities_items.hpp
@@ -100,9 +100,9 @@ class VladsCape : public Cape
class Purchasable : public Movable
{
public:
- /// Be aware that for pickable items like weapons, the item will be automatically picked up by the player (unless he already holds something), the ownership transfer is a little bit slow, so it might trigger the shop keeper if you're not inside the shop.
- /// does not consume money
- virtual void acquire(Entity* who) = 0;
+ /// Is called after purchase, changes the DummyPurchasableEntity into the real entity plus tries to equip it, or pick it up (for stuff like weapons), or give the powerup.
+ /// Nothing else happens, by itself it does not remove item from shop etc.
+ virtual void equip(Entity* who) = 0;
};
class DummyPurchasableEntity : public Purchasable
diff --git a/src/game_api/script/usertypes/entities_items_lua.cpp b/src/game_api/script/usertypes/entities_items_lua.cpp
index 045d38c2b..dd8c8ed44 100644
--- a/src/game_api/script/usertypes/entities_items_lua.cpp
+++ b/src/game_api/script/usertypes/entities_items_lua.cpp
@@ -155,8 +155,8 @@ void register_usertypes(sol::state& lua)
lua.new_usertype(
"Purchasable",
- "acquire",
- &Purchasable::acquire,
+ "equip",
+ &Purchasable::equip,
sol::base_classes,
sol::bases());
diff --git a/src/game_api/script/usertypes/vtables_lua.cpp b/src/game_api/script/usertypes/vtables_lua.cpp
index 227f4924b..b2827c2a4 100644
--- a/src/game_api/script/usertypes/vtables_lua.cpp
+++ b/src/game_api/script/usertypes/vtables_lua.cpp
@@ -194,7 +194,7 @@ void register_usertypes(sol::state& lua)
Entity,
CallbackType::Entity,
EntityVTable,
- VTableEntry<"acquire", 93, MemFun<&Purchasable::acquire>>>;
+ VTableEntry<"acquire", 93, MemFun<&Purchasable::equip>>>;
static PurchasableVTable purchasable_vtable(lua, lua["Purchasable"], "ENTITY_OVERRIDE");
using DummyPurchasableEntityVTable = HookableVTable<