sticker related APIs

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1197
Joined: Wed May 18, 2016 4:55 pm
Contact:

sticker related APIs

Post by Mooncat »

Request: APIs to know the existence of sticker on entity, and also add or remove sticker on it.

I'm looking for
LuaEntity::has_sticker(name) → boolean
LuaEntity::add_sticker(name)
LuaEntity::remove_sticker(name) → boolean (whether the entity had the said sticker so it is removed successfully)

There is so much potential for the sticker system. :P
posila
Factorio Staff
Factorio Staff
Posts: 5440
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: sticker related APIs

Post by posila »

It is already kind of possible.

Add sticker to biter

Code: Select all

biter.surface.create_entity{ name="slowdown-sticker", position=biter.position, target=biter }
Remove all stickers from biter:

Code: Select all

for _,e in pairs(biter.surface.find_entities_filtered{type="sticker", area=biter.bounding_box}) do 
  e.destroy() 
end
You got the idea.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1197
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: sticker related APIs

Post by Mooncat »

Wow, that's great! Don't know the "target" parameter can be used for sticker.

hm... I wonder the performance impact of using find_entities_filtered to remove stickers. Really not a fan of using such a search function since you already know the sticker is on the biter. :mrgreen:
But yes, I can use this before the actual implementation. Thanks! :D
Rseding91
Factorio Staff
Factorio Staff
Posts: 14913
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: sticker related APIs

Post by Rseding91 »

Mooncat wrote:Wow, that's great! Don't know the "target" parameter can be used for sticker.

hm... I wonder the performance impact of using find_entities_filtered to remove stickers. Really not a fan of using such a search function since you already know the sticker is on the biter. :mrgreen:
But yes, I can use this before the actual implementation. Thanks! :D
For such a small area a bounding box search vs a position search is almost identical performance wise.

I think biters already keep track of what stickers are attached to them so I'll just add the ability to read stickers off a biter for 0.15.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1197
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: sticker related APIs

Post by Mooncat »

Rseding91 wrote:
Mooncat wrote:Wow, that's great! Don't know the "target" parameter can be used for sticker.

hm... I wonder the performance impact of using find_entities_filtered to remove stickers. Really not a fan of using such a search function since you already know the sticker is on the biter. :mrgreen:
But yes, I can use this before the actual implementation. Thanks! :D
For such a small area a bounding box search vs a position search is almost identical performance wise.

I think biters already keep track of what stickers are attached to them so I'll just add the ability to read stickers off a biter for 0.15.
That's awesome! Thanks! :D
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2174
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: sticker related APIs

Post by Ranakastrasz »

Huh. I wonder if this would work for the player. If so, would work great for several buff-like animations I want to display.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Post Reply

Return to “Implemented mod requests”