Reassembly

Reassembly

Not enough ratings
A Rough Guide to Shapes.lua
By ‼
Want to make your own shapes, but feel intimidated by shapes.lua's lack of readability? I'll help you break it down
   
Award
Favorite
Favorited
Unfavorite
Intro
Reassembly's May 20th update gave modders the ability to create their own custom shapes to use within a mod, rather than create blocks using only pre-existing shapes already defined within the internal files. This can be accomplished by including a shapes.lua file within a mod package. An example file that shows the definitions of all the standard shapes can be found in Reassembly\data.


Throughout this guide, I will be using the THRUSTER shape as an example due to it's simple shape, and it's property of containing non-default ports.

This graph will be used to visually represent the code in order to aid in understanding. Points in this graph will represent a single unit of distance, going up to 5 in any direction




It is easy to feel overwhelmed by the sheer size of the example file shapes.lua (The region describing the square alone is 33 lines line), but once broken down, it is suprisingly simple to understand. The incredible size of shapes.lua is mostly caused by reassembly's requirement to have every possible scale of a shape have it's own definition (The smallest scale of square is defined in only one line).
Verts
The rules concerning vertices, as described at the start of shapes.lua, are:
-- vertices must be in clockwise order and must define a convex shape.
In addition, vertices are automatically assigned a "VTX_IDX", or ID number starting at 0 based on their order within the code.

This means that you are allowed to plot the vertices of your shape starting at any point as long as remaining points are then listed in clockwise order.
The rule concerning convex shapes isn't as strict, as it is possible to make shapes containing concave sections (Such as SENSOR) -- but these can cause the console to spew out errors, or even potentially cause crashes.

Vertices are to be listed in the format of coordinates, and are to be strictly ordered clockwise around the orgin (0,0).

For example, the code...
verts={ {2.772, -2.071}, {-2.772, -4.367}, {-2.772, 4.367}, {2.772, 2.071} }
...creates the following shape that looks like just the block it will create in game!
Ports
The rules concerning ports, as described at the start of shapes.lua, are:
-- port format is {VTX_IDX, LERP, TYPE}. LERP is between 0 and 1. Type defaults to NORMAL -- the port position is interpolated between the specified vertex and the following vertex based on LERP


The format means that a port is defined first by it's VTX_IDX, or ID, that is assigned by it's order within the code.

LERP defines a ports position between the vertex specificed, and the next vertex in order -- looping back to 0. LERP can be a value from 0 to 1, which represents a precentage of the distance between the vertices

TYPE defines how a port interacts and what it does. If left unspecified, the port will be set to the NORMAL type. The following are valid port types:
NORMAL: Allows the block to connect to other NORMAL type ports at that point

THRUSTER_IN: Allows the block to connect to a NORMAL type port, or to a THRUSTER_OUT type port

THRUSTER_OUT: Creates a specific point where thruster effects are emitted from

MISSILE: Defines where a replicant block will try to connect to the replicator block

LAUNCHER: Defines a point where a block can be replicated

WEAPON_IN: Allows the block to connect to a NORMAL type port, or to a WEAPON_OUT type port

WEAPON_OUT: Creates a specific point were cannon fire is emitted from

ROOT: Allows the block to connect to a NORMAL type port on a seperate entity

NONE: Does not create a port

Note that it is not neccesary to use the NONE type, since if an VTX_IDX does not have an associated port defined, it will simply not create a port.


For example, the code...
ports={ {3, 0.5, THRUSTER_IN}, {1, 0.5, THRUSTER_OUT} }
...creates the following shape that behaves like just the block it will create in game!
13 Comments
Neon 29 Jul, 2018 @ 5:00pm 
What cvar do you have to change to generate the shapes.lua file?
EpicMadness 3 Jun, 2018 @ 1:46pm 
on a side note, THRUSTER_OUT doesn't affect where forward push aims towards, it seems to be hard-coded in an absolute 0degree vector with reference to the template.

meaning, regardless of how you draw the shape or where you put THRUSTER_OUT, the propulsion will always go "east" of the template.
RandomMcSomethin 5 Aug, 2017 @ 3:44pm 
@stormageddon
Go to C:\Users\(NAME)\Saved Games\Reassembly\data to find the cvars.txt file you need to tweak to generate shapes.lua. Also, don't forget to remove the pound signs from the front of any values you modify, otherwise they'll be interpreted as comments and won't actually change the values. Apologies for the late response, but I hope this was helpful.
Metaladon 28 Apr, 2017 @ 9:41am 
Is there a range to what shapeIDs should be? I know for blocks and factions there is, I must assume the same applies here.
stormageddon 17 Mar, 2017 @ 10:56pm 
Unable to find shapes.lua, cannot find the cvar to regenerate it ethier. Any tips?
 [author] 31 Jan, 2017 @ 4:55pm 
Remember that Reassembly does not particularly like concave shapes, so you might run into some issues
licflagg 30 Jan, 2017 @ 8:30pm 
so far, this is helping me out, but i'd like someone to make a program to do this easier.

the reassembly web dev kit kinda works, but only gives me confirmation if i did the shape right. (BETA version)

i'm trying to do a crescent shape, and i'm doing some editing in paint to define the shape.
Deltonus 26 Nov, 2016 @ 9:18pm 
Wellp its fine
I guess i'll just have to use the one with both missile attatchments and launcher attatchments
Literally the SINGLE pre-existing block with that :/
Bad thing about it is, it doesnt create a mine-field, it creates 2 mine lines on the sides. :/
I'll have to find a way to change its AI in such a way that it spins but still moves when it needs to.
 [author] 26 Nov, 2016 @ 9:14pm 
Sorry, I have not found the source of that issue, and can't help in any meaningful way
Deltonus 26 Nov, 2016 @ 3:58pm 
(The edit button didnt appear for some reason)

The reason i cant just use the NONAGON_LAUNCHER block is because the block that should launch the Nonagon tries to generate squares, and the block itself tries to generate rectangles even though they are defenitly set to properly launch.