Entity Settings (map editor)

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
User avatar
MakeItGraphic
Fast Inserter
Fast Inserter
Posts: 237
Joined: Sat Jan 06, 2018 7:53 am
Contact:

Entity Settings (map editor)

Post by MakeItGraphic »

These questions may be able to be answered somewhere in the Wiki or API documentation I missed but anyway;

a few questions

1. health seems to be defined in entity files as natural numbers, but in-game appear to be real numbers


https://wiki.factorio.com/Prototype/Entity

Code: Select all

    type = "container",
    name = "wooden-chest",
    icon = "__base__/graphics/icons/wooden-chest.png",
    flags = {"placeable-neutral", "player-creation"},
    minable = {mining_time = 1, result = "wooden-chest"},
    max_health = 100,
    corpse = "small-remnants",
Wall_Health001.png
Wall_Health001.png (506.38 KiB) Viewed 1133 times
The wall health is 300 however reports as 299, indicating a real number, a decimal not shown. What's the background behind this? Is there some kind of tweak you can use to see the actual number as calculated by the game?

2. what is the difficulty settings for, as per the 'API':
Although it can be done; because different difficulties can have different technology or recipe trees it's not recommended to change difficulty settings mid-game.
What would the benefit be of changing the difficulty of an entity mid-game? I'm guessing it's mainly useful during real-time scripting/testing of technologies, and recipe variants.

3. Is there a way to batch edit properties of an entity (a), or even modify the properties of an entity globally through the map editor (b)?

Ex. a. In the above picture highlight multiple fences and apply a property to all selected

4. Entity Tags

These are neat, I never seen them used before I can't speculate their use. Google just redirects me to the Rich Text page.

Any who, I could see this feature being super useful like shown below. Creating mock signs, and notes with tags.
Entity_Tag001.PNG
Entity_Tag001.PNG (252.64 KiB) Viewed 1133 times
One snag though they disappear once map editor is closed. I am thinking there has to be a toggle for this, if so is it accessible to regular players? Because I'd love to go around tagging stuff.

User avatar
MakeItGraphic
Fast Inserter
Fast Inserter
Posts: 237
Joined: Sat Jan 06, 2018 7:53 am
Contact:

Re: Entity Settings (map editor)

Post by MakeItGraphic »

3. I kind of figured out 3 in regards to modding, it doesn't answer for the map editor (but im assuming its just not possible, so modding), https://wiki.factorio.com/Prototype/SelectionTool

I know it's fully possible to select a range of entities and set

Code: Select all

entity.destructible = false
and vice versa

Code: Select all

entity.destructible = true
. Was reading through different selection tool mods, and it's beyond me but possible.

All the properties are here. https://lua-api.factorio.com/latest/Lua ... structible

Code: Select all

destructible :: boolean [Read-Write]

When the entity is not destructible it can't be damaged.

Note: An indestructible entity can still be mined.
Note: Entities that are indestructible naturally (they have no health, like smoke, resource etc) can't be set to be destructible.
minable :: boolean [Read-Write]

Note: Not minable entities can still be destroyed.
Note: Entities that are not minable naturally (like smoke, character, enemy units etc) can't be set to minable.
rotatable :: boolean [Read-Write]

When entity is not to be rotatable (inserter, transport belt etc), it can't be rotated by player using the R key.

Note: Entities that are not rotatable naturally (like chest or furnace) can't be set to be rotatable.
operable :: boolean [Read-Write]

Player can't open gui of this entity and he can't quick insert/input stuff in to the entity when it is not operable. 
So I guess that answers that question. As for the second part of it, setting entites globally to indestructible:

I found this code in the mod portal which works fine in V.17, just have to print an entity list and append it to it. It's not as configurable but works.

Code: Select all

local function print(x) game.players[1].print(tostring(x)) end

local indestructible = (function(list) local set = {} for _, l in ipairs(list) do set[l] = true end return set end)({
	"entity.name" -- enter entities here
})

script.on_event(defines.events.on_built_entity, function(event)
	local entity = event.created_entity
	if entity then
		local name = 			-- entity.name
		if indestructible[name] then
			entity.destructible = false
		end
	end
end)

local function Destructible(event)
	local entity = event.created_entity
	if entity then
		local name = entity.name
		if name:find("") or indestructible[name] then -- find("prototype type")
			entity.destructible = true
		end
	end
end

Rseding91
Factorio Staff
Factorio Staff
Posts: 13219
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Entity Settings (map editor)

Post by Rseding91 »

Entity health is stored runtime as a floating point value between 0 and 1. It's converted back for display in tooltips and in the text box. Just it isn't worth letting people type fractional values in the text box so it only shows and lets you input whole numbers.
If you want to get ahold of me I'm almost always on Discord.

User avatar
MakeItGraphic
Fast Inserter
Fast Inserter
Posts: 237
Joined: Sat Jan 06, 2018 7:53 am
Contact:

Re: Entity Settings (map editor)

Post by MakeItGraphic »

Rseding91 wrote:
Sun Mar 01, 2020 5:11 pm
Entity health is stored runtime as a floating point value between 0 and 1. It's converted back for display in tooltips and in the text box. Just it isn't worth letting people type fractional values in the text box so it only shows and lets you input whole numbers.
Thanks for this, I have heard the term 'floating point' on here quite a few times. So this makes sense.

My biggest curiosity is entity tags, I don't know your API very well and quite frankly it all confuses the hell out of me. The most programming I did in my life was python and scratch if you call that programming.
sPN7F0Dd_400x400.jpg
sPN7F0Dd_400x400.jpg (17.57 KiB) Viewed 1013 times
Is there a way to toggle these to all ways be visible even outside of map editor? and what is their actual purpose?

Post Reply

Return to “Gameplay Help”