Page 1 of 1

sticker related APIs

Posted: Tue Feb 07, 2017 1:32 pm
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

Re: sticker related APIs

Posted: Tue Feb 07, 2017 2:23 pm
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.

Re: sticker related APIs

Posted: Tue Feb 07, 2017 4:54 pm
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

Re: sticker related APIs

Posted: Tue Feb 07, 2017 5:46 pm
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.

Re: sticker related APIs

Posted: Thu Feb 09, 2017 2:59 am
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

Re: sticker related APIs

Posted: Sun Apr 09, 2017 6:38 pm
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.