LuaPlayer::create_local_flying_text speed and create_entity's render_player_index

Post Reply
dewiniaid
Long Handed Inserter
Long Handed Inserter
Posts: 92
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 » Fri Nov 02, 2018 8:12 pm

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: 2754
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 » Fri Nov 02, 2018 8:28 pm

+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: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English

Bilka
Factorio Staff
Factorio Staff
Posts: 1743
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 » Sat Nov 03, 2018 3:59 pm

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: 2754
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 » Sat Nov 03, 2018 4:14 pm

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: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English

posila
Factorio Staff
Factorio Staff
Posts: 3379
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 » 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)

Bilka
Factorio Staff
Factorio Staff
Posts: 1743
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 » Sat Nov 03, 2018 4:44 pm

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: 2754
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 » Sat Nov 03, 2018 5:45 pm

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: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English

posila
Factorio Staff
Factorio Staff
Posts: 3379
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 » Sat Nov 03, 2018 5:59 pm

eradicator wrote:
Sat Nov 03, 2018 5:45 pm
Any 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: 2754
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 » Sat Nov 03, 2018 6:02 pm

posila wrote:
Sat Nov 03, 2018 5:59 pm
eradicator wrote:
Sat Nov 03, 2018 5:45 pm
Any 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: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English

dewiniaid
Long Handed Inserter
Long Handed Inserter
Posts: 92
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 » Sun Nov 04, 2018 7:32 pm

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: 3379
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 » Mon Nov 05, 2018 6:13 pm

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 pm
Any 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: 1743
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 » Mon Nov 05, 2018 6:27 pm

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: 2754
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 » Mon Nov 05, 2018 9:51 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 :)
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: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 2754
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 » 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*)
Author of: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English

Rseding91
Factorio Staff
Factorio Staff
Posts: 9029
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 » Thu Nov 08, 2018 6:51 pm

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”

Who is online

Users browsing this forum: No registered users