LuaPlayer::create_local_flying_text speed and create_entity's render_player_index
LuaPlayer::create_local_flying_text speed and create_entity's render_player_index
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.
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.
- eradicator
- 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
+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.)
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index
Added for 0.17.
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.
- eradicator
- 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
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index
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)
Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index
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.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.)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
- eradicator
- 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
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?posila wrote: ↑Sat Nov 03, 2018 4:29 pmImplication 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)
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index
Possibly yes (not promissing it, though)eradicator wrote: ↑Sat Nov 03, 2018 5:45 pmAny chance of at least getting standard flying-text visible on a per-force basis?
- eradicator
- 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
I'll reserve a spot under the chrismas tree then ;).posila wrote: ↑Sat Nov 03, 2018 5:59 pmPossibly yes (not promissing it, though)eradicator wrote: ↑Sat Nov 03, 2018 5:45 pmAny 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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index
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.
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.
Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index
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)eradicator wrote: ↑Sat Nov 03, 2018 6:02 pmI'll reserve a spot under the chrismas tree then .posila wrote: ↑Sat Nov 03, 2018 5:59 pmPossibly yes (not promissing it, though)eradicator wrote: ↑Sat Nov 03, 2018 5:45 pmAny chance of at least getting standard flying-text visible on a per-force basis?
Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index
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.
- eradicator
- 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
Oh. My. Best christmas present in a long time. Let's hope it arrives in time ;).
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
- eradicator
- 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
Just for confirmation...render_player_index implies that each
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: LuaPlayer::create_local_flying_text speed and create_entity's render_player_index
Correct.eradicator wrote: ↑Thu Nov 08, 2018 6:20 pmJust for confirmation...render_player_index implies that eachtextentity 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*)
If you want to get ahold of me I'm almost always on Discord.