Permitting a number for ForceIdentification

Post Reply
Honktown
Smart Inserter
Smart Inserter
Posts: 1026
Joined: Thu Oct 03, 2019 7:10 am
Contact:

Permitting a number for ForceIdentification

Post by Honktown »

ForceIdentification
force_index was recently added to allow a lightweight version of force.index everywhere modders only cared for the index... but without ForceIdentification allowing the index, this results in it not being useful in some cases.

create_entity can't use it
thing.force_index is a read-only value, so it can't be modified after, which is less convenient/performant than creating with the right force, anyway
player / entity .force = index can't use it

In principle, the index shouldn't be stored and used again without making sure the force is valid and the same, but for local and immediate use it would be alright. I began writing a simple script to test something:

Code: Select all

/c
if not global.inventory then
	local player = game.player
	local surface = player.surface
	local x = player.position.x
	local y = player.position.y

	local chest = surface.create_entity{
		name = "linked-chest",
		position = {x + 5,y},
		force = player.force_index,
	}

	local inventory = chest.get_main_inventory()
	if inventory then
		global.inventory = inventory
		chest.destroy()
	end
end
and Error: Given force is not valid, it must be a string (name of the force) or a LuaForce.

This fits with how the API describes ForceIdentification, which got me thinking "well why doesn't it support an index, anyways"
I have mods! I guess!
Link

lyvgbfh
Fast Inserter
Fast Inserter
Posts: 165
Joined: Fri Jul 10, 2020 6:48 pm
Contact:

Re: Permitting a number for ForceIdentification

Post by lyvgbfh »

It's also worth noting that concepts like SurfaceIdentification and PlayerIdentification already behave in this fashion.

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2548
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Permitting a number for ForceIdentification

Post by FuryoftheStars »

I agree with this suggestion, especially considering there are other concepts that already allow the int value.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles

Post Reply

Return to “Implemented mod requests”