Page 1 of 1

Allow force color to be locked/set

Posted: Sun Mar 22, 2020 2:53 am
by aaron311
Hi,

This could quite possibly be a bad/terrible idea™ but here goes...

Issue summary:
I'd like to have a way to programmatically set/override a force's color. Or, if that's not possible/easy/advisable, lock it from alteration due to the first player in the force changing.

Details:
At present, a force's "color" appears to be automatically equivalent to the color of the first player member of the force. While this default behavior seems to make sense, there are ways to (ab)use multiple forces in the game such that players switch around to different forces temporarily. When this happens, you get a sort of "light show" where the entity colors in your base keep changing whenever player 1 moves. This can seem buggy/distracting.

Use case:
I'm experimenting with creating a mod that temporarily relocates the player to an alternative (but allied) force along with any entities that have construction requests within the player's roboport range. This effectively allows the player to hit a toggle and make his local roboport service the requests in his immediate vicinity despite possibly the nearby stationary network already trying to service those requests.

Edit: If you want to see what I mean, look for "Tactical Construction" on the mod portal and use it in a multiplayer game. If the first player toggles it on and off you'll see the base colors change around :-)

Thank you for your consideration.

Re: Allow force color to be locked/set

Posted: Wed Jul 21, 2021 11:13 am
by Heinermann
+1 on this. All the entities in my new script-controlled force are black and there doesn't appear to be a way to change it.

Re: Allow force color to be locked/set

Posted: Thu Jul 22, 2021 1:21 pm
by KeepResearchinSpoons
+1
force.default_color to have rw state we could use to set colors of turrets, and the like.


OR, better yet,
a color attribute to a all the turrets :> If nil default to the "force color".


This alone would allow this kind of stuff to go for groups of "discovered" turrets.
vid-with-color-flicker
Turns out you can't do this in mp reliably :> Or even in sp for destinct groups :>

Unless you spam dummy offline players in lan into the map beforehand. For each slot of "turret groups" you want to use.
Feels gross? Yesh it does. Very much so.
You need to escape those dummies to not delete them with player-cleaning on soft-resets? You guessed it.
Is sharing the script to spam-login "dummy-players" over the defined list of names into the headless considered against the terms of use? Probably so.
I won't show you how it is done to prevent the possible harm for both of our parties.

But well, the force.color nil to default to force.players[1].color should be just an easy getter override?
PLEASE, let us fade turret colors around like an old Dracula "bloody-red to black" pulsing cape!
We do want either Force.color or turret.color, pretty please?
Would just be awesome.

Re: Allow force color to be locked/set

Posted: Mon Jul 26, 2021 3:49 am
by KeepResearchinSpoons
You know what? I've made you a full proof-of-concept example on how to color turrets.
[edit:] With the current lua only, by populating dummy forces with dummy "core" players.[/edit]
It does not include the framework on how to deal with them further... but... You'll be fine.

Here's the 3 minute youtube vid as a short demo.

For what is worth, you might also want the code.
Here's the lua "playbook" that you can copypaste the lua part from (to get a head-start).
dummy_forces.lua
(11.52 KiB) Downloaded 190 times

here's the tricky zip. (js insied!)
spam_dummies_v1.zip
(5.42 KiB) Downloaded 192 times
It's tricky cuz it is a bit in the gray zone. Kinda on the edge of it.
Well, it auto-connects local "fake" players only, so... should be fine?

Get the zip-version of factorio, unzip it somewhere, edit the path_to_client thing to point to a new unzipped factorio and launch it when ready.
DO NOT POINT IT TO YOUR REAL GAME FOLDER :>
You can then just host a MP world (NOT PUBLIC) and (without password! we have NO option or flag to batch-connect with pass afaik).

You can see that cars and tanks do not change the color via force.
They have "personal color" that you would need to change each time "by-hand".
Guess what? you can't lock it up to a certain color either. So good luck changing the driver color, car's color back and forth :>


All these files are safely licensed to you with Apache-2.0; should Wubes visit the thread, Apache-2.0 is also "safe" as in "not copyleft".
Have fun and let's wait for the force.color together!
(anyone +1? kappa)

Re: Allow force color to be locked/set

Posted: Mon Aug 08, 2022 1:24 am
by aaron311
Yo!

This feature was added in version 1.1.64. Can a mod move this thread to the 'implemented' folder?