scale_entity_info_icon not in docs, and shifting info icon?

Place to get help with not working mods / modding interface.
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

scale_entity_info_icon not in docs, and shifting info icon?

Post by Avacado »

I'm using scale_entity_info_icon = true in my entities (makes the recipe icon bigger for my giant 17x17 assembly machines), which appears to be missing from the documentation (I can't find it in on either lua-api.factorio.com or in the wiki under entity prototypes, so maybe it is missing from those?).

Also, the results is a little low on the entity, is there a way for me to shift the info_icon? I'd like to shift the icon up a bit so it is more centered. I can't find that in the docs either, but maybe it is missing (or just in a place I'm not looking?) for the same reason as the scale flag is.
Bilka
Factorio Staff
Factorio Staff
Posts: 3470
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: scale_entity_info_icon not in docs, and shifting info icon?

Post by Bilka »

It's documented here: https://wiki.factorio.com/Prototype/Cra ... _info_icon

There is no property for that.
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: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: scale_entity_info_icon not in docs, and shifting info icon?

Post by eradicator »

Avacado wrote:Also, the results is a little low on the entity, is there a way for me to shift the info_icon? I'd like to shift the icon up a bit so it is more centered. I can't find that in the docs either, but maybe it is missing (or just in a place I'm not looking?) for the same reason as the scale flag is.
If the icon is centered on (0,0) of the collision box as i suspect (or at least relative to it), you could hackily work around it by decentering your collision_box. I.e {{-9,-9},{8,8}}. But you'd have to write a migration to compensate on all existing factories.
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.
Bilka
Factorio Staff
Factorio Staff
Posts: 3470
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: scale_entity_info_icon not in docs, and shifting info icon?

Post by Bilka »

eradicator wrote:If the icon is centered on (0,0) of the collision box as i suspect (or at least relative to it), you could hackily work around it by decentering your collision_box. I.e {{-9,-9},{8,8}}. But you'd have to write a migration to compensate on all existing factories.
Why would you need a migration? The game can migrate bounding box changes just fine without migration, for example the boiler size change in 0.15 or the turret size change in some old version.
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: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: scale_entity_info_icon not in docs, and shifting info icon?

Post by eradicator »

Bilka wrote:
eradicator wrote:If the icon is centered on (0,0) of the collision box as i suspect (or at least relative to it), you could hackily work around it by decentering your collision_box. I.e {{-9,-9},{8,8}}. But you'd have to write a migration to compensate on all existing factories.
Why would you need a migration? The game can migrate bounding box changes just fine without migration, for example the boiler size change in 0.15 or the turret size change in some old version.
Because you'd need to correct the position of all entities. Otherwise they'd be in the wrong place. As the "position" (= center) doesn't change, while the bounding box does.
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.
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: scale_entity_info_icon not in docs, and shifting info icon?

Post by Avacado »

@Bilka,

Crafting machine wasn't one of the places I manually looked (though in retrospect it maybe should've been), and when I searched "info_icon" on the wiki it returned no results, though now I see if I search the entire thing "scale_entity_info_icon" I do get results. Why is this field only on the wiki and not lua-api.factorio.com?

@eradicator,

I tried adjusting all the boxes (collision_box, selection_box, and drawing_box), none of them moved the icon, so I think it must be basing the position off of parts of .animation or something else. I did find module_info_icon_shift, but I don't think there is an equivalent shift for the recipe info icon. Maybe if I add some blank space to the bottom of the images that are being used I can change the center, if that is what it is actually based on.
Bilka
Factorio Staff
Factorio Staff
Posts: 3470
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: scale_entity_info_icon not in docs, and shifting info icon?

Post by Bilka »

Avacado wrote:Crafting machine wasn't one of the places I manually looked (though in retrospect it maybe should've been), and when I searched "info_icon" on the wiki it returned no results, though now I see if I search the entire thing "scale_entity_info_icon" I do get results. Why is this field only on the wiki and not lua-api.factorio.com?
Because it's a prototype property and lua-api.factorio.com does not document the prototypes.
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: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: scale_entity_info_icon not in docs, and shifting info icon?

Post by eradicator »

The usual pattern.
  1. Some modder posts a question of the forum.
  2. I speculate about a possible solution.
  3. Some modder answer that solution didn't work.
  4. I don't believe and try it myself. And it works.

@Avacado:
Err, no it's based off the position of the entity, just like i expected. 8-)

Code: Select all

data.raw['assembling-machine']['assembling-machine-1'].collision_box =
    { {x = 0,y = 0}, {x = 2.9,y = 2.9}}
  
worksthough.jpg
worksthough.jpg (73.33 KiB) Viewed 2690 times
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.
Avacado
Long Handed Inserter
Long Handed Inserter
Posts: 94
Joined: Fri Jul 22, 2016 3:17 pm
Contact:

Re: scale_entity_info_icon not in docs, and shifting info icon?

Post by Avacado »

@eradicator

Yeah, you're right, I misread it as centered in the center of the collision box, and my experiments reflected that (I, for example, changing the -y to half the value, which didn't move the icon), but the visual explained it really well. That also explains the need for migration, which I also didn't follow, but yeah, actually moving the 0,0 point would need migration. Thank you for your help and my apologies for not reading your original more carefully.

That doesn't move the icon relative to the entity sprite, which is why I stated that it was in .animation, since that is where I would have to make a change to move the icon relative to the entity sprite, but what you stated was still correct.
Last edited by Avacado on Fri Jul 20, 2018 3:02 pm, edited 1 time in total.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: scale_entity_info_icon not in docs, and shifting info icon?

Post by eradicator »

Hope you get it to work. Fourtunately find_entities_filtered has a whole-surface mode, and teleporting machines is a thing these days.

Edit why would you need to change the animation? You just .shift={x,y} that down too.
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.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: scale_entity_info_icon not in docs, and shifting info icon?

Post by eradicator »

Code: Select all

  local this = data.raw['assembling-machine']['assembling-machine-1']
  this.collision_box = {left_top = {x = -8.9/2,y = -3},right_bottom = {x = 8.9/2,y = 5.9} }
  this.scale_entity_info_icon = true
  for k,v in pairs(this.animation.layers) do
    v.shift            =  util.by_pixel(0, 48*1)
    v.scale = 3/2
    v.hr_version.shift =  util.by_pixel(0, 48*1)
    v.hr_version.scale = 3/2
    end
Shifting works...but scale_entity_info_icon doesn't do anything for me?
scale.jpg
scale.jpg (204.96 KiB) Viewed 2683 times
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.
Post Reply

Return to “Modding help”