Page 1 of 1

scale_entity_info_icon not in docs, and shifting info icon?

Posted: Fri Jul 20, 2018 2:50 am
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.

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

Posted: Fri Jul 20, 2018 5:59 am
by Bilka
It's documented here: https://wiki.factorio.com/Prototype/Cra ... _info_icon

There is no property for that.

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

Posted: Fri Jul 20, 2018 8:46 am
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.

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

Posted: Fri Jul 20, 2018 10:23 am
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.

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

Posted: Fri Jul 20, 2018 12:00 pm
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.

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

Posted: Fri Jul 20, 2018 2:02 pm
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.

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

Posted: Fri Jul 20, 2018 2:16 pm
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.

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

Posted: Fri Jul 20, 2018 2:42 pm
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 2695 times

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

Posted: Fri Jul 20, 2018 2:58 pm
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.

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

Posted: Fri Jul 20, 2018 3:00 pm
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.

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

Posted: Fri Jul 20, 2018 3:25 pm
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 2688 times