Beam prototype with definable lifespan

Things that already exist in the current mod API
Post Reply
kyranzor
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Oct 31, 2014 4:52 pm
Contact:

Beam prototype with definable lifespan

Post by kyranzor »

The beams used by destroyer bots are used as ammo, and has a nice action parameter for the duration of the beam in ticks and the max length etc.
When creating a beam entity by script, using create_entity(), there is no way to set the duration/lifespan of the beam.

The beam just sits there, forever, running through the animation. I have to manually add the beam to a table and keep track of it and kill it after X game ticks.

Please add an optional parameter either to the beam prototype itself for specified lifespan for automatic self-destroy, or perhaps have this as a more generic parameter added to create_entity (can have other uses) so that ANY entity spawned by create_entity can have a timed lifespan, perhaps even with optional end-of-time function call/callback or even raised in case users want to catch the timeout and add a nice swirl of magic dust or something silly.

Pic for example of never-ending beam lol. Construction units trying to 'zap' building into existence, only their beams stayed forever!
Attachments
picture showing never-ending beams after construction
picture showing never-ending beams after construction
unknown.png (624.08 KiB) Viewed 1869 times

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Beam prototype with definable lifespan

Post by posila »

You can set duration and max_lenght as fields of table that you pass to create_entity.
I can see it is not documented for beams, though.

kyranzor
Filter Inserter
Filter Inserter
Posts: 499
Joined: Fri Oct 31, 2014 4:52 pm
Contact:

Re: Beam prototype with definable lifespan

Post by kyranzor »

Ah hah! Awesome news, thank you very much. I can remove some global tables and tick logic now ;)

Post Reply

Return to “Already exists”