Allow different shapes in equipment armor

Post Reply
User avatar
lovely_santa
Filter Inserter
Filter Inserter
Posts: 502
Joined: Sat Feb 18, 2017 9:41 pm
Contact:

Allow different shapes in equipment armor

Post by lovely_santa »

As of now, equipment requires to have a shape defined, but the type must be "full". I want to make different shape equipments, for example an "L" shape would be nice to have a 2x2 mk1 equipment, the mk2 could be an addon 3x3 "L" shaped armor that wraps around the 2x2 and together form a square 3x3 equipment.
With that in mind I am actualy looking for a hollow square look, where for example a 2x2 equipment could sit inside a 4x4 hollow equipment.

Kind regards
lovely_santa
You can find all my mods on the mod portal. Also helping on Arch666Angel's mods.
Image

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

Re: Allow different shapes in equipment armor

Post by Rseding91 »

Ok, I added support to define a shape as "manual" (a set of points) for the next version of 0.17.
If you want to get ahold of me I'm almost always on Discord.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Allow different shapes in equipment armor

Post by darkfrei »

It's a tetris time!

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

Re: Allow different shapes in equipment armor

Post by Rseding91 »

Note you'll have to manually make the background color on your sprite when using the manual shape since the automatic shape can't tell where borders would go unless I wrote some non-trivial amount of rendering logic which I don't currently want to do.
If you want to get ahold of me I'm almost always on Discord.

Amarula
Filter Inserter
Filter Inserter
Posts: 509
Joined: Fri Apr 27, 2018 1:29 pm
Contact:

Re: Allow different shapes in equipment armor

Post by Amarula »

Rseding91 wrote:
Wed Jun 19, 2019 10:14 am
Ok, I added support to define a shape as "manual" (a set of points) for the next version of 0.17.
You guys are so amazing! <Insert celebratory fireworks emoji here>
My own personal Factorio super-power - running out of power.

User avatar
lovely_santa
Filter Inserter
Filter Inserter
Posts: 502
Joined: Sat Feb 18, 2017 9:41 pm
Contact:

Re: Allow different shapes in equipment armor

Post by lovely_santa »

Thanks for the implementation! <3
You can find all my mods on the mod portal. Also helping on Arch666Angel's mods.
Image

Schallfalke
Fast Inserter
Fast Inserter
Posts: 162
Joined: Sun Oct 28, 2018 7:57 am
Contact:

Re: Allow different shapes in equipment armor

Post by Schallfalke »

May I ask about some sample code or syntax for this exciting new feature?
Especially on the expected range of "points", is it some relative coordinates to upper-left point?...
Is it like the equipment will span the whole width and height graphically, but only the points in the table actually occupy the grid point?

I found the description under Lua API - LuaEquipmentPrototype, but still don't know how to use it.
shape :: table [Read-only]
 Shape of this equipment prototype. It is a table:
  width :: uint
  height :: uint
  points :: array of point (optional): A point is a table with x and y values. Only set when the shape is "manual"
Wiki - Types/EquipmentShape is not updated yet, still showing:
type
 Type: Types/string
 The shape. Must be "full".

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Allow different shapes in equipment armor

Post by eradicator »

Looks like positive offsets from the upper left corner {0,0} of the equiment. And width/height as a box that defines image scale = 1.0.

Code: Select all

data.raw["generator-equipment"]["fusion-reactor-equipment"]
    .shape = {
      width = 2,
      height = 3,
      type = "manual",
      points = {
        {0,0},
        {0,1},
        {1,1},
        {0,2},
        }
      }
gridpoints.png
gridpoints.png (5.63 KiB) Viewed 2237 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.

Schallfalke
Fast Inserter
Fast Inserter
Posts: 162
Joined: Sun Oct 28, 2018 7:57 am
Contact:

Re: Allow different shapes in equipment armor

Post by Schallfalke »

eradicator wrote:
Tue Jul 02, 2019 8:43 am
Looks like positive offsets from the upper left corner {0,0} of the equiment. And width/height as a box that defines image scale = 1.0.

Code: Select all

data.raw["generator-equipment"]["fusion-reactor-equipment"]
    .shape = {
      width = 2,
      height = 3,
      type = "manual",
      points = {
        {0,0},
        {0,1},
        {1,1},
        {0,2},
        }
      }
gridpoints.png
Thanks! This is exactly the answer I wanted! :D

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

Re: Allow different shapes in equipment armor

Post by Rseding91 »

It's also on the fusion-reactor-equipment lua definition commented out:

Code: Select all

    shape =
    {
      width = 4,
      height = 4,
      type = "full"
      --[[ Can also be defined as manual (a set of points which fall within the width/height - can't be empty)
           Note: the automatic background does not work when using 'manual'.
      type = "manual",
      points = {{0, 0}, {1, 0}, {2, 0}, {3, 0},
                {0, 1},                 {3, 1},
                {0, 2},                 {3, 2},
                {0, 3}, {1, 3}, {2, 3}, {3, 3},}
      ]]--
    },
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Allow different shapes in equipment armor

Post by eradicator »

@Rsed:
Btw, the error message for too small width/height could use some better wording. "point value is too big: 1 >= 1" isn't the best way to say "all points need to be within the box size defined by widht/height".
error.png
error.png (12.14 KiB) Viewed 2210 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.

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

Re: Allow different shapes in equipment armor

Post by Rseding91 »

Heh, errors mostly just exist to prevent bad data from being used. If I change it, some time later someone else will complain about something else until eventual it's 3 paragraphs long and nobody has any idea what it means when it happens.

I'm going to leave the error as it is. You figured out what was wrong so it's good enough.
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Allow different shapes in equipment armor

Post by eradicator »

Rseding91 wrote:
Tue Jul 02, 2019 4:12 pm
You figured out what was wrong so it's good enough.
I'll take that as a compliment. :mrgreen:
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 “Implemented mod requests”