Page 1 of 1

Allow different shapes in equipment armor

Posted: Tue Jun 18, 2019 12:14 pm
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

Re: Allow different shapes in equipment armor

Posted: Wed Jun 19, 2019 10:14 am
by Rseding91
Ok, I added support to define a shape as "manual" (a set of points) for the next version of 0.17.

Re: Allow different shapes in equipment armor

Posted: Wed Jun 19, 2019 10:23 am
by darkfrei
It's a tetris time!

Re: Allow different shapes in equipment armor

Posted: Wed Jun 19, 2019 10:36 am
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.

Re: Allow different shapes in equipment armor

Posted: Wed Jun 19, 2019 1:24 pm
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>

Re: Allow different shapes in equipment armor

Posted: Sun Jun 23, 2019 11:46 am
by lovely_santa
Thanks for the implementation! <3

Re: Allow different shapes in equipment armor

Posted: Mon Jul 01, 2019 10:07 pm
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".

Re: Allow different shapes in equipment armor

Posted: Tue Jul 02, 2019 8:43 am
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 2332 times

Re: Allow different shapes in equipment armor

Posted: Tue Jul 02, 2019 11:01 am
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

Re: Allow different shapes in equipment armor

Posted: Tue Jul 02, 2019 1:10 pm
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},}
      ]]--
    },

Re: Allow different shapes in equipment armor

Posted: Tue Jul 02, 2019 1:58 pm
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 2305 times

Re: Allow different shapes in equipment armor

Posted: Tue Jul 02, 2019 4:12 pm
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.

Re: Allow different shapes in equipment armor

Posted: Tue Jul 02, 2019 4:31 pm
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: