Entity
Generic entitiessource
Derived types: BGBackLayerDoor, BGEggshipRoom, BGRelativeElement, BGShopEntrance, BGShopKeeperPrime, BGSurfaceStar, BGTutorialSign, BoulderSpawner, BurningRopeEffect, CameraFlash, CinematicAnchor, CrossBeam, CursedEffect, DMAlienBlast, DMSpawning, DecoRegeneratingBlock, DestructibleBG, DustWallApep, EggplantThrower, Floor, FrostBreathEffect, LimbAnchor, Liquid, LogicalAnchovyFlock, LogicalDoor, LogicalDrain, LogicalMiniGame, LogicalRegeneratingBlock, LogicalSound, LogicalTrapTrigger, Movable, OnFireEffect, OuroboroCameraAnchor, OuroboroCameraZoomin, PalaceSign, PoisonedEffect, Portal, RoomLight, ShootingStarSpawner, SplashBubbleGenerator, WetEffect
Fields
abs_x
numberread only
Absolute position in the world, even if overlaid. Might be a frame off since it's updated with apply_movement function and so it does not update if game moves the entity in different way after movement is processed.
Use get_absolute_position for precise. Read only.
abs_y
numberread only
Absolute position in the world, even if overlaid. Might be a frame off since it's updated with apply_movement function and so it does not update if game moves the entity in different way after movement is processed.
Use get_absolute_position for precise. Read only.
draw_depth
integer
Depth level that this entity is drawn on.
Don't edit this directly, use set_draw_depth function
special_offsetx
number
Special offset used for entities attached to others (or picked by others) that need to flip to the other side when the parent flips sides
sourcespecial_offsety
number
Special offset used for entities attached to others (or picked by others) that need to flip to the other side when the parent flips sides
sourcetype
Type of the entity, contains special properties etc. If you want to edit them just for this entity look at the EntityDB
sourceuid
integer
Unique id of the entity, save it to variable to check this entity later (don't use the whole Entity type as it will be replaced with a different one when this is destroyed)
sourceuser_data
anyproperty
You can put any arbitrary lua object here for custom entities or player stats, which is then saved across level transitions for players and carried items, mounts etc... This field is local to the script and multiple scripts can write different things in the same entity. The data is saved right before ON.PRE_LOAD_SCREEN from a level and loaded right before ON.POST_LOAD_SCREEN to a level or transition. It is not available yet in post_entity_spawn, but that is a good place to initialize it for new custom entities. See example for more.
sourcex
number
Position of the entity in the world, or relative to overlay if attached to something. Use get_absolute_position to get real position of anything in the game world.
y
number
Position of the entity in the world, or relative to overlay if attached to something. Use get_absolute_position to get real position of anything in the game world.
Methods
as_bgbacklayerdoor
function Entity.as_bgbacklayerdoor(): BGBackLayerDoor?Returns BGBackLayerDoor? (may be nil)
as_bgeggshiproom
function Entity.as_bgeggshiproom(): BGEggshipRoom?Returns BGEggshipRoom? (may be nil)
as_bgfloatingdebris
function Entity.as_bgfloatingdebris(): BGFloatingDebris?Returns BGFloatingDebris? (may be nil)
as_bgmovingstar
function Entity.as_bgmovingstar(): BGMovingStar?Returns BGMovingStar? (may be nil)
as_bgrelativeelement
function Entity.as_bgrelativeelement(): BGRelativeElement?Returns BGRelativeElement? (may be nil)
as_bgshootingstar
function Entity.as_bgshootingstar(): BGShootingStar?Returns BGShootingStar? (may be nil)
as_bgshopentrance
function Entity.as_bgshopentrance(): BGShopEntrance?Returns BGShopEntrance? (may be nil)
as_bgshopkeeperprime
function Entity.as_bgshopkeeperprime(): BGShopKeeperPrime?Returns BGShopKeeperPrime? (may be nil)
as_bgsurfacelayer
function Entity.as_bgsurfacelayer(): BGSurfaceLayer?Returns BGSurfaceLayer? (may be nil)
as_bgsurfacestar
function Entity.as_bgsurfacestar(): BGSurfaceStar?Returns BGSurfaceStar? (may be nil)
as_bgtutorialsign
function Entity.as_bgtutorialsign(): BGTutorialSign?Returns BGTutorialSign? (may be nil)
as_bigspeartrap
function Entity.as_bigspeartrap(): BigSpearTrap?Returns BigSpearTrap? (may be nil)
as_boulderspawner
function Entity.as_boulderspawner(): BoulderSpawner?Returns BoulderSpawner? (may be nil)
as_burningropeeffect
function Entity.as_burningropeeffect(): BurningRopeEffect?Returns BurningRopeEffect? (may be nil)
as_cavemanshopkeeper
function Entity.as_cavemanshopkeeper(): CavemanShopkeeper?Returns CavemanShopkeeper? (may be nil)
as_chainedpushblock
function Entity.as_chainedpushblock(): ChainedPushBlock?Returns ChainedPushBlock? (may be nil)
as_cinematicanchor
function Entity.as_cinematicanchor(): CinematicAnchor?Returns CinematicAnchor? (may be nil)
as_cityofgolddoor
function Entity.as_cityofgolddoor(): CityOfGoldDoor?Returns CityOfGoldDoor? (may be nil)
as_climbablerope
function Entity.as_climbablerope(): ClimbableRope?Returns ClimbableRope? (may be nil)
as_clonegunshot
function Entity.as_clonegunshot(): CloneGunShot?Returns CloneGunShot? (may be nil)
as_conveyorbelt
function Entity.as_conveyorbelt(): ConveyorBelt?Returns ConveyorBelt? (may be nil)
as_critterbeetle
function Entity.as_critterbeetle(): CritterBeetle?Returns CritterBeetle? (may be nil)
as_critterbutterfly
function Entity.as_critterbutterfly(): CritterButterfly?Returns CritterButterfly? (may be nil)
as_critterdrone
function Entity.as_critterdrone(): CritterDrone?Returns CritterDrone? (may be nil)
as_critterfirefly
function Entity.as_critterfirefly(): CritterFirefly?Returns CritterFirefly? (may be nil)
as_critterlocust
function Entity.as_critterlocust(): CritterLocust?Returns CritterLocust? (may be nil)
as_critterpenguin
function Entity.as_critterpenguin(): CritterPenguin?Returns CritterPenguin? (may be nil)
as_critterslime
function Entity.as_critterslime(): CritterSlime?Returns CritterSlime? (may be nil)
as_crittersnail
function Entity.as_crittersnail(): CritterSnail?Returns CritterSnail? (may be nil)
as_crushelevator
function Entity.as_crushelevator(): CrushElevator?Returns CrushElevator? (may be nil)
as_cursedeffect
function Entity.as_cursedeffect(): CursedEffect?Returns CursedEffect? (may be nil)
as_decorateddoor
function Entity.as_decorateddoor(): DecoratedDoor?Returns DecoratedDoor? (may be nil)
as_decoregeneratingblock
function Entity.as_decoregeneratingblock(): DecoRegeneratingBlock?Returns DecoRegeneratingBlock? (may be nil)
as_destructiblebg
function Entity.as_destructiblebg(): DestructibleBG?Returns DestructibleBG? (may be nil)
as_dmalienblast
function Entity.as_dmalienblast(): DMAlienBlast?Returns DMAlienBlast? (may be nil)
as_dummypurchasableentity
function Entity.as_dummypurchasableentity(): DummyPurchasableEntity?Returns DummyPurchasableEntity? (may be nil)
as_dustwallapep
function Entity.as_dustwallapep(): DustWallApep?Returns DustWallApep? (may be nil)
as_eggplantminister
function Entity.as_eggplantminister(): EggplantMinister?Returns EggplantMinister? (may be nil)
as_eggplantthrower
function Entity.as_eggplantthrower(): EggplantThrower?Returns EggplantThrower? (may be nil)
as_eggshipcenterjetflame
function Entity.as_eggshipcenterjetflame(): EggshipCenterJetFlame?Returns EggshipCenterJetFlame? (may be nil)
as_eggshipdoors
function Entity.as_eggshipdoors(): EggShipDoorS?Returns EggShipDoorS? (may be nil)
as_empressgrave
function Entity.as_empressgrave(): EmpressGrave?Returns EmpressGrave? (may be nil)
as_fallingplatform
function Entity.as_fallingplatform(): FallingPlatform?Returns FallingPlatform? (may be nil)
as_firebugunchained
function Entity.as_firebugunchained(): FirebugUnchained?Returns FirebugUnchained? (may be nil)
as_forestsister
function Entity.as_forestsister(): ForestSister?Returns ForestSister? (may be nil)
as_frostbreatheffect
function Entity.as_frostbreatheffect(): FrostBreathEffect?Returns FrostBreathEffect? (may be nil)
as_frozenliquid
function Entity.as_frozenliquid(): FrozenLiquid?Returns FrozenLiquid? (may be nil)
as_fxalienblast
function Entity.as_fxalienblast(): FxAlienBlast?Returns FxAlienBlast? (may be nil)
as_fxankhbrokenpiece
function Entity.as_fxankhbrokenpiece(): FxAnkhBrokenPiece?Returns FxAnkhBrokenPiece? (may be nil)
as_fxankhrotatingspark
function Entity.as_fxankhrotatingspark(): FxAnkhRotatingSpark?Returns FxAnkhRotatingSpark? (may be nil)
as_fxfireflylight
function Entity.as_fxfireflylight(): FxFireflyLight?Returns FxFireflyLight? (may be nil)
as_fxhundunneckpiece
function Entity.as_fxhundunneckpiece(): FxHundunNeckPiece?Returns FxHundunNeckPiece? (may be nil)
as_fxjellyfishstar
function Entity.as_fxjellyfishstar(): FxJellyfishStar?Returns FxJellyfishStar? (may be nil)
as_fxjetpackflame
function Entity.as_fxjetpackflame(): FxJetpackFlame?Returns FxJetpackFlame? (may be nil)
as_fxkingusliding
function Entity.as_fxkingusliding(): FxKinguSliding?Returns FxKinguSliding? (may be nil)
as_fxlamassuattack
function Entity.as_fxlamassuattack(): FxLamassuAttack?Returns FxLamassuAttack? (may be nil)
as_fxmainexitdoor
function Entity.as_fxmainexitdoor(): FxMainExitDoor?Returns FxMainExitDoor? (may be nil)
as_fxnecromancerankh
function Entity.as_fxnecromancerankh(): FxNecromancerANKH?Returns FxNecromancerANKH? (may be nil)
as_fxouroborodragonpart
function Entity.as_fxouroborodragonpart(): FxOuroboroDragonPart?Returns FxOuroboroDragonPart? (may be nil)
as_fxouroborooccluder
function Entity.as_fxouroborooccluder(): FxOuroboroOccluder?Returns FxOuroboroOccluder? (may be nil)
as_fxpickupeffect
function Entity.as_fxpickupeffect(): FxPickupEffect?Returns FxPickupEffect? (may be nil)
as_fxplayerindicator
function Entity.as_fxplayerindicator(): FxPlayerIndicator?Returns FxPlayerIndicator? (may be nil)
as_fxsalecontainer
function Entity.as_fxsalecontainer(): FxSaleContainer?Returns FxSaleContainer? (may be nil)
as_fxshotgunblast
function Entity.as_fxshotgunblast(): FxShotgunBlast?Returns FxShotgunBlast? (may be nil)
as_fxsorceressattack
function Entity.as_fxsorceressattack(): FxSorceressAttack?Returns FxSorceressAttack? (may be nil)
as_fxsparksmall
function Entity.as_fxsparksmall(): FxSparkSmall?Returns FxSparkSmall? (may be nil)
as_fxspringtrapring
function Entity.as_fxspringtrapring(): FxSpringtrapRing?Returns FxSpringtrapRing? (may be nil)
as_fxtiamathead
function Entity.as_fxtiamathead(): FxTiamatHead?Returns FxTiamatHead? (may be nil)
as_fxtiamattail
function Entity.as_fxtiamattail(): FxTiamatTail?Returns FxTiamatTail? (may be nil)
as_fxtiamattorso
function Entity.as_fxtiamattorso(): FxTiamatTorso?Returns FxTiamatTorso? (may be nil)
as_fxtornjournalpage
function Entity.as_fxtornjournalpage(): FxTornJournalPage?Returns FxTornJournalPage? (may be nil)
as_fxunderwaterbubble
function Entity.as_fxunderwaterbubble(): FxUnderwaterBubble?Returns FxUnderwaterBubble? (may be nil)
as_fxwebbedeffect
function Entity.as_fxwebbedeffect(): FxWebbedEffect?Returns FxWebbedEffect? (may be nil)
as_fxwitchdoctorhint
function Entity.as_fxwitchdoctorhint(): FxWitchdoctorHint?Returns FxWitchdoctorHint? (may be nil)
as_giantclamtop
function Entity.as_giantclamtop(): GiantClamTop?Returns GiantClamTop? (may be nil)
as_horizontalforcefield
function Entity.as_horizontalforcefield(): HorizontalForceField?Returns HorizontalForceField? (may be nil)
as_hornedlizard
function Entity.as_hornedlizard(): HornedLizard?Returns HornedLizard? (may be nil)
as_iceslidingsound
function Entity.as_iceslidingsound(): IceSlidingSound?Returns IceSlidingSound? (may be nil)
as_junglespearcosmetic
function Entity.as_junglespearcosmetic(): JungleSpearCosmetic?Returns JungleSpearCosmetic? (may be nil)
as_junglespeartrap
function Entity.as_junglespeartrap(): JungleSpearTrap?Returns JungleSpearTrap? (may be nil)
as_jungletraptrigger
function Entity.as_jungletraptrigger(): JungleTrapTrigger?Returns JungleTrapTrigger? (may be nil)
as_kapalapowerup
function Entity.as_kapalapowerup(): KapalaPowerup?Returns KapalaPowerup? (may be nil)
as_lightarrowplatform
function Entity.as_lightarrowplatform(): LightArrowPlatform?Returns LightArrowPlatform? (may be nil)
as_lightemitter
function Entity.as_lightemitter(): LightEmitter?Returns LightEmitter? (may be nil)
as_liquidsurface
function Entity.as_liquidsurface(): LiquidSurface?Returns LiquidSurface? (may be nil)
as_logicalanchovyflock
function Entity.as_logicalanchovyflock(): LogicalAnchovyFlock?Returns LogicalAnchovyFlock? (may be nil)
as_logicalconveyorbeltsound
function Entity.as_logicalconveyorbeltsound(): LogicalConveyorbeltSound?Returns LogicalConveyorbeltSound? (may be nil)
as_logicaldrain
function Entity.as_logicaldrain(): LogicalDrain?Returns LogicalDrain? (may be nil)
as_logicalliquidstreamsound
function Entity.as_logicalliquidstreamsound(): LogicalLiquidStreamSound?Returns LogicalLiquidStreamSound? (may be nil)
as_logicalminigame
function Entity.as_logicalminigame(): LogicalMiniGame?Returns LogicalMiniGame? (may be nil)
as_logicalregeneratingblock
function Entity.as_logicalregeneratingblock(): LogicalRegeneratingBlock?Returns LogicalRegeneratingBlock? (may be nil)
as_logicalsound
function Entity.as_logicalsound(): LogicalSound?Returns LogicalSound? (may be nil)
as_logicalstaticsound
function Entity.as_logicalstaticsound(): LogicalStaticSound?Returns LogicalStaticSound? (may be nil)
as_logicaltraptrigger
function Entity.as_logicaltraptrigger(): LogicalTrapTrigger?Returns LogicalTrapTrigger? (may be nil)
as_megajellyfish
function Entity.as_megajellyfish(): MegaJellyfish?Returns MegaJellyfish? (may be nil)
as_megajellyfisheye
function Entity.as_megajellyfisheye(): MegaJellyfishEye?Returns MegaJellyfishEye? (may be nil)
as_minigameasteroid
function Entity.as_minigameasteroid(): MiniGameAsteroid?Returns MiniGameAsteroid? (may be nil)
as_minigameship
function Entity.as_minigameship(): MiniGameShip?Returns MiniGameShip? (may be nil)
as_minigameshipoffset
function Entity.as_minigameshipoffset(): MiniGameShipOffset?Returns MiniGameShipOffset? (may be nil)
as_motherstatue
function Entity.as_motherstatue(): MotherStatue?Returns MotherStatue? (may be nil)
as_mummyfliessound
function Entity.as_mummyfliessound(): MummyFliesSound?Returns MummyFliesSound? (may be nil)
as_olmecfloater
function Entity.as_olmecfloater(): OlmecFloater?Returns OlmecFloater? (may be nil)
as_onfireeffect
function Entity.as_onfireeffect(): OnFireEffect?Returns OnFireEffect? (may be nil)
as_ouroborocameraanchor
function Entity.as_ouroborocameraanchor(): OuroboroCameraAnchor?Returns OuroboroCameraAnchor? (may be nil)
as_ouroborocamerazoomin
function Entity.as_ouroborocamerazoomin(): OuroboroCameraZoomin?Returns OuroboroCameraZoomin? (may be nil)
as_parachutepowerup
function Entity.as_parachutepowerup(): ParachutePowerup?Returns ParachutePowerup? (may be nil)
as_pipetravelersound
function Entity.as_pipetravelersound(): PipeTravelerSound?Returns PipeTravelerSound? (may be nil)
as_poisonedeffect
function Entity.as_poisonedeffect(): PoisonedEffect?Returns PoisonedEffect? (may be nil)
as_powerupcapable
function Entity.as_powerupcapable(): PowerupCapable?Returns PowerupCapable? (may be nil)
as_prizedispenser
function Entity.as_prizedispenser(): PrizeDispenser?Returns PrizeDispenser? (may be nil)
as_protoshopkeeper
function Entity.as_protoshopkeeper(): ProtoShopkeeper?Returns ProtoShopkeeper? (may be nil)
as_quicksandsound
function Entity.as_quicksandsound(): QuickSandSound?Returns QuickSandSound? (may be nil)
as_shootingstarspawner
function Entity.as_shootingstarspawner(): ShootingStarSpawner?Returns ShootingStarSpawner? (may be nil)
as_skulldroptrap
function Entity.as_skulldroptrap(): SkullDropTrap?Returns SkullDropTrap? (may be nil)
as_slidingwallceiling
function Entity.as_slidingwallceiling(): SlidingWallCeiling?Returns SlidingWallCeiling? (may be nil)
as_spikeballtrap
function Entity.as_spikeballtrap(): SpikeballTrap?Returns SpikeballTrap? (may be nil)
as_splashbubblegenerator
function Entity.as_splashbubblegenerator(): SplashBubbleGenerator?Returns SplashBubbleGenerator? (may be nil)
as_stretchchain
function Entity.as_stretchchain(): StretchChain?Returns StretchChain? (may be nil)
as_teleporterbackpack
function Entity.as_teleporterbackpack(): TeleporterBackpack?Returns TeleporterBackpack? (may be nil)
as_teleportingborder
function Entity.as_teleportingborder(): TeleportingBorder?Returns TeleportingBorder? (may be nil)
as_tentaclebottom
function Entity.as_tentaclebottom(): TentacleBottom?Returns TentacleBottom? (may be nil)
as_timedforcefield
function Entity.as_timedforcefield(): TimedForceField?Returns TimedForceField? (may be nil)
as_timedpowderkeg
function Entity.as_timedpowderkeg(): TimedPowderkeg?Returns TimedPowderkeg? (may be nil)
as_transferfloor
function Entity.as_transferfloor(): TransferFloor?Returns TransferFloor? (may be nil)
as_treasurehook
function Entity.as_treasurehook(): TreasureHook?Returns TreasureHook? (may be nil)
as_truecrownpowerup
function Entity.as_truecrownpowerup(): TrueCrownPowerup?Returns TrueCrownPowerup? (may be nil)
as_unchainedspikeball
function Entity.as_unchainedspikeball(): UnchainedSpikeBall?Returns UnchainedSpikeBall? (may be nil)
as_walkingmonster
function Entity.as_walkingmonster(): WalkingMonster?Returns WalkingMonster? (may be nil)
as_witchdoctorskull
function Entity.as_witchdoctorskull(): WitchDoctorSkull?Returns WitchDoctorSkull? (may be nil)
as_woodenlogtrap
function Entity.as_woodenlogtrap(): WoodenlogTrap?Returns WoodenlogTrap? (may be nil)
destroy_recursive
function Entity:destroy_recursive()function Entity:destroy_recursive(mask: MASK?, ent_types: ENT_TYPE[], rec_mode: RECURSIVE_MODE)mask:MASK?ent_types:ENT_TYPE[]rec_mode:RECURSIVE_MODE
get_hitbox
function Entity:get_hitbox(use_render_pos?: boolean): AABBuse_render_pos?:booleanoptional
Returns AABB
kill
function Entity:kill(destroy_corpse: boolean, responsible?: Entity)destroy_corpse:booleanresponsible?:Entityoptional
kill_recursive
function Entity:kill_recursive(destroy_corpse: boolean, responsible?: Entity)destroy_corpse:booleanresponsible?:Entityoptional
function Entity:kill_recursive(destroy_corpse: boolean, responsible: Entity?, mask: MASK?, ent_types: ENT_TYPE[], rec_mode: RECURSIVE_MODE)destroy_corpse:booleanresponsible:Entity?mask:MASK?ent_types:ENT_TYPE[]rec_mode:RECURSIVE_MODE
liberate_from_shop
function Entity:liberate_from_shop(clear_parent: boolean)clear_parent:boolean
function Entity:liberate_from_shop()sourceoverlaps_with
function Entity:overlaps_with(other?: Entity): booleanother?:Entityoptional
Returns boolean
function Entity:overlaps_with(hitbox: AABB): booleanhitbox:AABB
Returns boolean
function Entity:overlaps_with(rect_left: number, rect_bottom: number, rect_right: number, rect_top: number): booleanrect_left:numberrect_bottom:numberrect_right:numberrect_top:number
Returns boolean
perform_teleport
function Entity:perform_teleport(delta_x: integer, delta_y: integer)delta_x:integerdelta_y:integer
remove_item
function Entity:remove_item(entity: Entity?, autokill_check: boolean)entity:Entity?autokill_check:boolean
set_draw_depth
function Entity:set_draw_depth(draw_depth: integer, unknown?: integer)draw_depth:integerunknown?:integeroptional
optional unknown - game usually sets it to 0, doesn't appear to have any special effect (needs more reverse engineering)
sourceset_post_activate
function Entity:set_post_activate(fun: fun(self: Entity?, activator: Entity?)): integerReturns integer
Activates a button prompt (with the Use door/Buy button), e.g. buy shop item, activate drill, read sign, interact in camp, ... get_entity(<udjat socket uid>):activate(players[1]) (make sure player 1 has the udjat eye though)
set_post_apply_metadata
function Entity:set_post_apply_metadata(fun: fun(self: Entity?, metadata: integer)): integerfun:fun(self: Entity?, metadata: integer)
Returns integer
set_post_can_be_pushed
function Entity:set_post_can_be_pushed(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
set_post_create_rendering_info
function Entity:set_post_create_rendering_info(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
set_post_destroy
function Entity:set_post_destroy(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
Completely removes the entity from existence
sourceset_post_dtor
function Entity:set_post_dtor(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
set_post_flip
function Entity:set_post_flip(fun: fun(self: Entity?, left: boolean)): integerfun:fun(self: Entity?, left: boolean)
Returns integer
set_post_friction
function Entity:set_post_friction(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
Friction of this entity, affects it's contact with other entities (how fast it slows down on the floor, how fast it can move but also the other way around for floors/activefloors: how other entities can move on it)
sourceset_post_generate_damage_particles
function Entity:set_post_generate_damage_particles(fun: fun(self: Entity?, victim: Entity?, damage: integer, killing: boolean)): integerReturns integer
set_post_get_held_entity
function Entity:set_post_get_held_entity(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
set_post_get_metadata
function Entity:set_post_get_metadata(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
e.g. for turkey: stores health, poison/curse state, for mattock: remaining swings (returned value is transferred)
sourceset_post_init
function Entity:set_post_init(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
Applies changes made in entity.type
set_post_is_in_liquid
function Entity:set_post_is_in_liquid(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
Returns true if entity is in water/lava
sourceset_post_kill
function Entity:set_post_kill(fun: fun(self: Entity?, destroy_corpse: boolean, responsible: Entity?)): integerReturns integer
Kills the entity, you can set responsible to nil to ignore it
set_post_ledge_grab
function Entity:set_post_ledge_grab(fun: fun(self: Entity?, who: Entity?)): integerReturns integer
set_post_liberate_from_shop
function Entity:set_post_liberate_from_shop(fun: fun(self: Entity?, clear_parent: boolean)): integerfun:fun(self: Entity?, clear_parent: boolean)
Returns integer
It's not called when item is bought. It does not remove the item from StateMemory.room_owners.owned_items
Parameter clear_parent used only for CHAR_* entities, sets the linked_companion_parent to -1.
set_post_on_collision1
function Entity:set_post_on_collision1(fun: fun(self: Entity?, other_entity: Entity?)): integerReturns integer
Collisions with stuff that blocks you, like walls, floors, etc. Triggers for entities in it's EntityDB.collision_mask
sourceset_post_on_collision2
function Entity:set_post_on_collision2(fun: fun(self: Entity?, other_entity: Entity?)): integerReturns integer
More like on_overlap, triggers when entities touch/overlap each other. Triggers for entities in it's EntityDB.collision2_mask
sourceset_post_remove_item
function Entity:set_post_remove_item(fun: fun(self: Entity?, entity: Entity?, autokill_check: boolean)): integerReturns integer
Can be called multiple times for the same entity (for example when play throws/drops entity from it's hands)
sourceset_post_reset_draw_depth
function Entity:set_post_reset_draw_depth(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
set_post_set_as_sound_source
function Entity:set_post_set_as_sound_source(fun: fun(self: Entity?, p2: SoundMeta?)): integerReturns integer
set_post_set_draw_depth
function Entity:set_post_set_draw_depth(fun: fun(self: Entity?, draw_depth: integer, b3f: integer)): integerfun:fun(self: Entity?, draw_depth: integer, b3f: integer)
Returns integer
set_post_set_invisible
function Entity:set_post_set_invisible(fun: fun(self: Entity?, value: boolean)): integerfun:fun(self: Entity?, value: boolean)
Returns integer
set_post_stood_on
function Entity:set_post_stood_on(fun: fun(self: Entity?, entity: Entity?, p3: Vec2?)): integerReturns integer
set_post_trigger_action
function Entity:set_post_trigger_action(fun: fun(self: Entity?, user: Entity?)): integerReturns integer
Triggers weapons and other held items like teleporter, mattock etc. You can check the virtual-availability.md, if entity has open in the on_open you can use this function, otherwise it does nothing. Returns false if action could not be performed (cooldown is not 0, no arrow loaded in etc. the animation could still be played thou)
set_post_update_state_machine
function Entity:set_post_update_state_machine(fun: fun(self: Entity?)): integerfun:fun(self: Entity?)
Returns integer
set_post_virtual
function Entity:set_post_virtual(index: integer, fun: function): integer?index:integerfun:function- Callback signature not known from the code.
Returns integer? (may be nil)
set_post_walked_off
function Entity:set_post_walked_off(fun: fun(self: Entity?, walker: Entity?)): integerReturns integer
set_post_walked_on
function Entity:set_post_walked_on(fun: fun(self: Entity?, walker: Entity?)): integerReturns integer
set_pre_activate
function Entity:set_pre_activate(fun: fun(self: Entity?, activator: Entity?): boolean): integerfun:fun(self: Entity?, activator: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
Activates a button prompt (with the Use door/Buy button), e.g. buy shop item, activate drill, read sign, interact in camp, ... get_entity(<udjat socket uid>):activate(players[1]) (make sure player 1 has the udjat eye though)
set_pre_apply_metadata
function Entity:set_pre_apply_metadata(fun: fun(self: Entity?, metadata: integer): boolean): integerfun:fun(self: Entity?, metadata: integer): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_can_be_pushed
function Entity:set_pre_can_be_pushed(fun: fun(self: Entity?): boolean?): integerfun:fun(self: Entity?): boolean?- Returning nil (or nothing): the original function runs (a value replaces its result and skips it).
Returns integer
set_pre_create_rendering_info
function Entity:set_pre_create_rendering_info(fun: fun(self: Entity?): boolean): integerfun:fun(self: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_destroy
function Entity:set_pre_destroy(fun: fun(self: Entity?): boolean): integerfun:fun(self: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
Completely removes the entity from existence
sourceset_pre_dtor
function Entity:set_pre_dtor(fun: fun(self: Entity?): boolean): integerfun:fun(self: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_flip
function Entity:set_pre_flip(fun: fun(self: Entity?, left: boolean): boolean): integerfun:fun(self: Entity?, left: boolean): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_friction
function Entity:set_pre_friction(fun: fun(self: Entity?): number?): integerfun:fun(self: Entity?): number?- Returning nil (or nothing): the original function runs (a value replaces its result and skips it).
Returns integer
Friction of this entity, affects it's contact with other entities (how fast it slows down on the floor, how fast it can move but also the other way around for floors/activefloors: how other entities can move on it)
sourceset_pre_generate_damage_particles
function Entity:set_pre_generate_damage_particles(fun: fun(self: Entity?, victim: Entity?, damage: integer, killing: boolean): boolean): integerfun:fun(self: Entity?, victim: Entity?, damage: integer, killing: boolean): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_get_held_entity
function Entity:set_pre_get_held_entity(fun: fun(self: Entity?): Entity?): integerfun:fun(self: Entity?): Entity?- Returning nil (or nothing): the original function runs (a value replaces its result and skips it).
Returns integer
set_pre_get_metadata
function Entity:set_pre_get_metadata(fun: fun(self: Entity?): integer?): integerfun:fun(self: Entity?): integer?- Returning nil (or nothing): the original function runs (a value replaces its result and skips it).
Returns integer
e.g. for turkey: stores health, poison/curse state, for mattock: remaining swings (returned value is transferred)
sourceset_pre_init
function Entity:set_pre_init(fun: fun(self: Entity?): boolean): integerfun:fun(self: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
Applies changes made in entity.type
set_pre_is_in_liquid
function Entity:set_pre_is_in_liquid(fun: fun(self: Entity?): boolean?): integerfun:fun(self: Entity?): boolean?- Returning nil (or nothing): the original function runs (a value replaces its result and skips it).
Returns integer
Returns true if entity is in water/lava
sourceset_pre_kill
function Entity:set_pre_kill(fun: fun(self: Entity?, destroy_corpse: boolean, responsible: Entity?): boolean): integerfun:fun(self: Entity?, destroy_corpse: boolean, responsible: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
Kills the entity, you can set responsible to nil to ignore it
set_pre_ledge_grab
function Entity:set_pre_ledge_grab(fun: fun(self: Entity?, who: Entity?): boolean): integerfun:fun(self: Entity?, who: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_liberate_from_shop
function Entity:set_pre_liberate_from_shop(fun: fun(self: Entity?, clear_parent: boolean): boolean): integerfun:fun(self: Entity?, clear_parent: boolean): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
It's not called when item is bought. It does not remove the item from StateMemory.room_owners.owned_items
Parameter clear_parent used only for CHAR_* entities, sets the linked_companion_parent to -1.
set_pre_on_collision1
function Entity:set_pre_on_collision1(fun: fun(self: Entity?, other_entity: Entity?): boolean): integerfun:fun(self: Entity?, other_entity: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
Collisions with stuff that blocks you, like walls, floors, etc. Triggers for entities in it's EntityDB.collision_mask
sourceset_pre_on_collision2
function Entity:set_pre_on_collision2(fun: fun(self: Entity?, other_entity: Entity?): boolean): integerfun:fun(self: Entity?, other_entity: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
More like on_overlap, triggers when entities touch/overlap each other. Triggers for entities in it's EntityDB.collision2_mask
sourceset_pre_remove_item
function Entity:set_pre_remove_item(fun: fun(self: Entity?, entity: Entity?, autokill_check: boolean): boolean): integerfun:fun(self: Entity?, entity: Entity?, autokill_check: boolean): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
Can be called multiple times for the same entity (for example when play throws/drops entity from it's hands)
sourceset_pre_reset_draw_depth
function Entity:set_pre_reset_draw_depth(fun: fun(self: Entity?): boolean): integerfun:fun(self: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_set_as_sound_source
function Entity:set_pre_set_as_sound_source(fun: fun(self: Entity?, p2: SoundMeta?): boolean): integerfun:fun(self: Entity?, p2: SoundMeta?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_set_draw_depth
function Entity:set_pre_set_draw_depth(fun: fun(self: Entity?, draw_depth: integer, b3f: integer): boolean): integerfun:fun(self: Entity?, draw_depth: integer, b3f: integer): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_set_invisible
function Entity:set_pre_set_invisible(fun: fun(self: Entity?, value: boolean): boolean): integerfun:fun(self: Entity?, value: boolean): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_stood_on
function Entity:set_pre_stood_on(fun: fun(self: Entity?, entity: Entity?, p3: Vec2?): boolean): integerfun:fun(self: Entity?, entity: Entity?, p3: Vec2?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_trigger_action
function Entity:set_pre_trigger_action(fun: fun(self: Entity?, user: Entity?): boolean?): integerfun:fun(self: Entity?, user: Entity?): boolean?- Returning nil (or nothing): the original function runs (a value replaces its result and skips it).
Returns integer
Triggers weapons and other held items like teleporter, mattock etc. You can check the virtual-availability.md, if entity has open in the on_open you can use this function, otherwise it does nothing. Returns false if action could not be performed (cooldown is not 0, no arrow loaded in etc. the animation could still be played thou)
set_pre_update_state_machine
function Entity:set_pre_update_state_machine(fun: fun(self: Entity?): boolean): integerfun:fun(self: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_virtual
function Entity:set_pre_virtual(index: integer, fun: function): integer?index:integerfun:function- Callback signature not known from the code.
Returns integer? (may be nil)
set_pre_walked_off
function Entity:set_pre_walked_off(fun: fun(self: Entity?, walker: Entity?): boolean): integerfun:fun(self: Entity?, walker: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_pre_walked_on
function Entity:set_pre_walked_on(fun: fun(self: Entity?, walker: Entity?): boolean): integerfun:fun(self: Entity?, walker: Entity?): boolean- Returning nil (or nothing): treated as false: the original function runs (true skips it).
Returns integer
set_texture
function Entity:set_texture(texture_id: TEXTURE): booleantexture_id:TEXTURE
Returns boolean