Picture positioning

Place to get help with not working mods / modding interface.
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Picture positioning

Post by gheift »

Hello there,

I am trying to create a website on which you can edit saved blueprints. But currently I am stucked at displaying the blueprint. I use the information from data/base/prototypes/entity/demo-entities.lua etc. namly entity.selection_box, entitiy.drawing_box, entity.pictures.filename, entity.pictures.width and entity.pictures.height. I already found out that the base unit for the pictures is 32 pixels. But currently the pictures are not shiftet by entity.pictures.shift, because every variation on how to use these values does not result in a correct preview.

Can anybody help me with entity.picture.shift?

To give you an idea of what I am doing: https://ght.io/factorio/blueprint/
In this example especially the accumulators and the radar is misplaced.

Legal Question: Is it allowed to use the graphics and scripts in raw or preprocessed way on a third party website?

Thanks,
Gerhard

(Example copied from https://forums.factorio.com/forum/vie ... 168#p39903)
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: Picture positioning

Post by rk84 »

I used paint to aid me.
Left accumulator: Factorio places center of image in center of entity and shift is used to tweak image position.
Right accumulator: This is what I believe to be your case. topleft corners of selectionbox and image in same position.
basic-accumulator.png
basic-accumulator.png (30.64 KiB) Viewed 2640 times
Not sure if this aligns right but. If you replace this

Code: Select all

if false and g.shift then
  gra.style.marginLeft = -g.shift[1] .. 'em'
  gra.style.marginTop =  g.shift[1] .. 'em'
with this

Code: Select all

if g.shift then
  gra.style.marginLeft = g.shift[1] - left - g.width / 64 .. 'em'
  gra.style.marginTop = g.shift[2] - top - g.height / 64 .. 'em'
How does it look?
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: Picture positioning

Post by gheift »

Thanks, that was the missing information I was not able to find… now I try to import the infos from the factorio data.lua files.
Zuzak
Inserter
Inserter
Posts: 33
Joined: Sat Oct 04, 2014 6:09 pm
Contact:

Re: Picture positioning

Post by Zuzak »

This is Awesome.
I copy pasted some of my blueprints into it and seen parts of them graphically outside of game.
When you finish this, Wow.

A suggestion: instead of red squares: have text in a box with entity name as shown in code
eventually, direct base/mod folder access
Possibly by saving the webpage to the Factorio folder and run it from there?
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: Picture positioning

Post by gheift »

Post Reply

Return to “Modding help”