LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

dewiniaid
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 07, 2017 8:50 pm
Contact:

LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by dewiniaid »

So, I've found (with Bilka's help) the LuaPlayer::create_local_flying_text method in 0.17.

It's occasionally useful to be able to create stationary text. A few existing mods do this with flying-text prototypes with 0 speed. So, it would be handy to be able to either

a) Choose an entity name (that must be a flying-text prototype) rather than the default
b) Choose the speed of the flying-text.
c) See below.

Furthermore, the docs don't specify what this function returns. I assume it returns the entity.



In a similar vein, the new highlight-box supports a render_player_index to make it only visible to that player. While it wouldn't make sense to add this to everything (I can only imagine the complexities of invisible-to-you biters attacking your base), would it be possible to get it on flying-text and simple-entity?


Use case: I'm developing a mod that shows information on nearby rail signals when one is selected, and it'd be a little odd that one player selecting a rail signal causes things to suddenly be visible to other players. Current plans are to highlight rail signals that are too close (i.e. a block that can't fit an entire train after a chain signal->rail signal block) and show distance to other signals in the block.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by eradicator »

+1

Usecase 1: I find moving text difficult to read, so stationary text would be awesome. If the engine provides for a method to have it stationary and temporary at the same time that's mighty fine, otherwise i'm fine with just deleting it myself after a few seconds.

Usecase 2: Personal notes that a player can leave to themselfs without messing up other ppls screen.

Usecase 3: Displaying names of things (trains, custom entities) where each player can give the thing their own naming to better remember things.

(Currently i just mark flying text active=false to keep it stationary and perpetual. But that is ofc visible to everyone.)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Bilka
Factorio Staff
Factorio Staff
Posts: 3309
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by Bilka »

dewiniaid wrote: Fri Nov 02, 2018 8:12 pm It's occasionally useful to be able to create stationary text. A few existing mods do this with flying-text prototypes with 0 speed. So, it would be handy to be able to

b) Choose the speed of the flying-text.
Added for 0.17.
dewiniaid wrote: Fri Nov 02, 2018 8:12 pm Furthermore, the docs don't specify what this function returns. I assume it returns the entity.
It doesn't return anything. There is no entity, just a class that is used to display the text, and is not part of gamestate.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by eradicator »

Bilka wrote: Sat Nov 03, 2018 3:59 pm
dewiniaid wrote: Fri Nov 02, 2018 8:12 pm Furthermore, the docs don't specify what this function returns. I assume it returns the entity.
It doesn't return anything. There is no entity, just a class that is used to display the text, and is not part of gamestate.
So does it always vanish after a fixed amount of time? How do i know if it's still there or if i should create a new one if i want it to stay longer than the default delay? And what happens to it when the mod that created it is removed? (some mods that create customizable "sign posts" used the default flying text so it never vanishes. A proper mod uses a custom prototype that is removed from the game if the mod is removed.)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
posila
Factorio Staff
Factorio Staff
Posts: 5350
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by posila »

Bilka wrote: Sat Nov 03, 2018 3:59 pm... and is not part of gamestate.
Implication of this is that it doesn't persist through save and load. If you removed a mod, you must have reloaded the save ...

I think this is not very usable for cases you have in mind (probably it having similar name to flying-text entity creates expectations that the mechanism doesn't meet)
Bilka
Factorio Staff
Factorio Staff
Posts: 3309
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by Bilka »

eradicator wrote: Sat Nov 03, 2018 4:14 pm So does it always vanish after a fixed amount of time? How do i know if it's still there or if i should create a new one if i want it to stay longer than the default delay? And what happens to it when the mod that created it is removed? (some mods that create customizable "sign posts" used the default flying text so it never vanishes. A proper mod uses a custom prototype that is removed from the game if the mod is removed.)
You can specify the time to live when you create it. When you reload the save, the text vanishes. So, if you remove a mod, the text will vanish because you reloaded the save.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by eradicator »

posila wrote: Sat Nov 03, 2018 4:29 pm
Bilka wrote: Sat Nov 03, 2018 3:59 pm... and is not part of gamestate.
Implication of this is that it doesn't persist through save and load. If you removed a mod, you must have reloaded the save ...

I think this is not very usable for cases you have in mind (probably it having similar name to flying-text entity creates expectations that the mechanism doesn't meet)
Yep. That makes it completely unusable for most of the usecases i had in mind (probably same for @OP). If i can't know if it's there or not i obviously can't rely on it being there. Unless i wanted to go crazy and recreate it every second (which defies the whole point becaues it'd be too costly UPS wise). Makes me a bit sad that i can only use it for short temporary messages (still awesome for that, just not a super-multi-tool). Any chance of at least getting standard flying-text visible on a per-force basis?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
posila
Factorio Staff
Factorio Staff
Posts: 5350
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by posila »

eradicator wrote: Sat Nov 03, 2018 5:45 pmAny chance of at least getting standard flying-text visible on a per-force basis?
Possibly yes (not promissing it, though)
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by eradicator »

posila wrote: Sat Nov 03, 2018 5:59 pm
eradicator wrote: Sat Nov 03, 2018 5:45 pmAny chance of at least getting standard flying-text visible on a per-force basis?
Possibly yes (not promissing it, though)
I'll reserve a spot under the chrismas tree then ;).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
dewiniaid
Long Handed Inserter
Long Handed Inserter
Posts: 96
Joined: Tue Mar 07, 2017 8:50 pm
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by dewiniaid »

We discussed this some on the Discord yesterday, so I wanted to summarize and update this some:

a) create_local_flying_text with no return value is entirely worthless for my intended use, as it has no return value that can be used to destroy the text later. Thus, render_player_index on flying-text and simple-entity would be the preferred solution.

b) With the unit changes in 0.17, I suspect competitive multiplayer mods may take off -- and those will likely need force-specific options for text/simple entities/other things as well. This isn't my use case, but I predict someone will ask for it sooner or later anyways if they haven't already.

c) It sounds like Bilka or Klonan might have been working on adding this, but that's no guaruntee it'll be added unless one of them chimes in here with an update.
posila
Factorio Staff
Factorio Staff
Posts: 5350
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by posila »

eradicator wrote: Sat Nov 03, 2018 6:02 pm
posila wrote: Sat Nov 03, 2018 5:59 pm
eradicator wrote: Sat Nov 03, 2018 5:45 pmAny chance of at least getting standard flying-text visible on a per-force basis?
Possibly yes (not promissing it, though)
I'll reserve a spot under the chrismas tree then ;).
It seems like Bilka is your secret Santa this year (flying-text has now render_player_index runtime property ... not exactly what you asked for, but somewhat what OP seemed to want)
Bilka
Factorio Staff
Factorio Staff
Posts: 3309
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by Bilka »

Simple-entity-with-owner and simple-entity-with force also have the runtime render_player_index property :)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by eradicator »

Bilka wrote: Mon Nov 05, 2018 6:27 pm Simple-entity-with-owner and simple-entity-with force also have the runtime render_player_index property :)
Oh. My. Best christmas present in a long time. Let's hope it arrives in time ;).
posila wrote: Mon Nov 05, 2018 6:13 pm It seems like Bilka is your secret Santa this year (flying-text has now render_player_index runtime property ... not exactly what you asked for, but somewhat what OP seemed to want)
Yea, it's actually better than per-force. If i want per force i can just make more than one (ok, not optimal for 400 player games, but should work fine for p<10) :D
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by eradicator »

Bilka wrote: Mon Nov 05, 2018 6:27 pm Simple-entity-with-owner and simple-entity-with force also have the runtime render_player_index property :)
Just for confirmation...render_player_index implies that each text entity can only be seen by one person at a time right? No single entity being visible to an arbitrary subgroup of all players? ("Asking for a friend..." *cough*)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14280
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post by Rseding91 »

eradicator wrote: Thu Nov 08, 2018 6:20 pm
Bilka wrote: Mon Nov 05, 2018 6:27 pm Simple-entity-with-owner and simple-entity-with force also have the runtime render_player_index property :)
Just for confirmation...render_player_index implies that each text entity can only be seen by one person at a time right? No single entity being visible to an arbitrary subgroup of all players? ("Asking for a friend..." *cough*)
Correct.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Implemented mod requests”