Page 1 of 2

Compositions

Posted: 28 Apr 2019, 19:04
by Lobby
Overview
Compositions are a way to combine buildings, roads, road decorations and trees as a building. An important property of compositions is the support of a non square ground size. Therefore it could be used to make up non squared buildings for example :teach

Compositions are used for example for the pre-built train stations :img
sample_composition.png


Definition
Technically compositions are defined as buildings that contain a list of the "things" they are built up with. The user can build it like a regular building, the preview displays the actual contents of the building. However, once the player issues to build the building the actual contents of the building will be built instead.

Basic structure (here for the train station as an example) :json

Code: Select all

[
  {
    "id": "$somerandomid00",
    "type": "decoration",
    "width": 4,
    "height": 2,
    "composition": [
      {"id": "$trainplatform03","x": 0,"y": 0,"frame": 1}, // A platform
      ...
      {"id": "$rails00","x0": 0,"y0": 1,"x1": 3,"y1": 1},  // Rails/road
      ...
      {"id": "$railroof01","x": 1,"y": 1},                 // Road decoration (for the rail)
      ...
    ]
  }
]
To understand how it's built up let's try to make a composition of the following:
draft.png
So basically a road with a crossing on it and a park. The size of the building is 4x2. The basic structure of the building might look like:

Code: Select all

[{
  "id": "$compositionexample00",
  "type": "decoration",
  "width": 4,
  "height": 2,
  "composition": []   -- We will put something in here
}]
Note that we will put the components of the composition into the composition array. Let's begin with the park. Since it's a building (we'll use the park with id $park01 for it) all we have to provide is the id, the position x, y within the composition. Optionally we can specify which frame of the park should be used. If we don't provide a frame the game will pick one randomly (if multiple are available). The code for the park:

Code: Select all

{"id": "$park00", "x": 0, "y": 1, "frame": 0}
The next thing will be the road. We will use $road01 (the country road) and have to provide the starting position x0, y0 and the target position x1, y1. To form a line that is axis aligned these parameters have to obey x0 == x1 or y0 == y1 (or both). With that, the code for the road would be:

Code: Select all

{"id": "$road01", "x0": 0, "y0": 0, "x1": 3, "y1": 0}
Note that y0 == y1, so the condition mentioned above is fulfilled. Roads will connect to neighboring roads automatically if they intersect with them or if the start/end point is near to a connectable road.
Last but not least we want to put a crossing on the road. For that we will use the road decoration of id $roaddeco_crosswalk00. Similar to buildings it's sufficient to provide the id as well as a position x, y:

Code: Select all

{"id": "$roaddeco_crosswalk00", "x": 1, "y": 0}
Done!

Let's insert these objects into the composition array above and we get :json

Code: Select all

[{
  "id": "$compositionexample00",
  "type": "decoration",
  "width": 4,
  "height": 2,
  "composition": [
    {"id": "$park01", "x": 0, "y": 1, "frame": 0},
    {"id": "$road01", "x0": 0, "y0": 0, "x1": 3, "y1": 0},
    {"id": "$roaddeco_crosswalk00", "x": 1, "y": 0}
  ]
}]
Alternatively you may download it as a ready to play plugin (no external files needed):
composition_example.json
(418 Bytes) Downloaded 320 times
which results in :img
result.png
result.png (186.35 KiB) Viewed 14505 times
As you can see it's possible to rotate the composition. If rotation aware buildings are part of the composition they will rotate accordingly.



:66:
image.png
image.png (548.69 KiB) Viewed 13885 times

Code: Select all

[{
  "id": "$compositionexample01",
  "type": "decoration",
  "width": 3,
  "height": 3,
  "composition": [
    {"id": "$road01", "x0": 0, "y0": 0, "x1": 2, "y1": 0,"l0":0,"l1":1},
    {"id": "$road01", "x0": 2, "y0": 0, "x1": 2, "y1": 2,"l0":1,"l1":2},
    {"id": "$road01", "x0": 2, "y0": 2, "x1": 0, "y1": 2,"l0":2,"l1":3},
    {"id": "$road01", "x0": 0, "y0": 1, "x1": 2, "y1": 1,"join":false}
  ]
}]
For road decorations and bus stops you can provide a level attribute (0 by default).

New attributes were added for roads in compositions, namely:
Show
l0, l1
Use these to specify the start and the end level of the road with "l0" being the start, and "l1" the end level.

The default values are 0 which means on ground (also in context of terrain; road levels are always relative to the ground). The behavior is the same as if you would use the road tool to build a road by hand (e.g. start and end point of the road are always flat)
Show
join
By default, the roads in road compositions join to other roads. However, in some cases you may not want that to happen. Now you can prevent that by using:

Code: Select all

"join":false
The road will still align to other roads that it intersects.
You may for example create intersections with these. The composition extractor mentioned below doesn't work for roads that are not on ground.

Since version 1.10.62 you can also include bus stops in your compositions. Lines for bus stops will look like that:

Code: Select all

{"id": "$busstop00", "x":1, "y":0, "level":0}

Tool
To make building up a composition easier there's a tool to convert a selected rectangle from a city to corresponding json code. It's part of the Plugin Creator Tools that you may find in the Plugin Store (you may find it via search function or listed in Categories->Tools).

Once you have installed the tool(s) you can select it from the toolbar. After that mark the area you want to create a json composition code for. The code will be copied into your clipboard then. This may look like:

Code: Select all

{
  "width":4,"height":2,
  "composition":[
    {"y0":0,"x0":0,"y1":0,"x1":3,"id":"$road01"},
    {"level":0,"x":1,"y":0,"id":"$roaddeco_crosswalk00"},
    {"x":0,"y":1,"id":"$park01","frame":0}
  ]
}
Note that it's up to you to add at least an id as well as a building type (e.g. decoration) to it.

Known issues:
-The tool does not always handle road curves correctly.
-Road levels aren't supported, yet.

Re: Compositions

Posted: 29 Apr 2019, 18:21
by Hadestia
Can you give sample zip for this Lobby?

Re: Compositions

Posted: 29 Apr 2019, 18:41
by Lobby
Of course! Added the json file to it :json

Re: Compositions

Posted: 30 Apr 2019, 04:05
by BetterBear
Thank you!

This will definately make some things come to life, such as one-tap custom intersections. :)

Re: Compositions

Posted: 02 May 2019, 15:04
by Ssss
When i use "Composition" to make 1×3 building, there is an error(game was shutdowned when i place my building). It work before i add two or more frames.

This is my plugin that has some problems.

Code: Select all

[
{
"id":"$Composition_Test1_MSG$",
"type":"decoration",
"width":1,
"height":1,
"buildtime":0,
"needsroad":false,
"author":"MSG",
"drawground":true,
"influencepark":30,
"influencepolice":100,
"influenceculture":2,
"price":0,
"monthlyprice":0,
"frames":[
{
"bmp":"1.png"
},
{
"bmp":"4.png"
}
],
"rotationaware":false
},
{
"id":"$Composition_Test2_MSG$",
"type":"decoration",
"width":1,
"height":1,
"buildtime":0,
"needsroad":false,
"author":"MSG",
"drawground":true,
"influencepark":30,
"influencepolice":100,
"influenceculture":2,
"price":0,
"monthlyprice":0,
"frames":[
{
"bmp":"2.png"
},
{
"bmp":"5.png"
}
],
"rotationaware":false
},
{
"id":"$Composition_Test3_MSG$",
"type":"decoration",
"width":1,
"height":1,
"buildtime":0,
"needsroad":false,
"author":"MSG",
"drawground":true,
"influencepark":30,
"influencepolice":100,
"influenceculture":2,
"price":0,
"monthlyprice":0,
"frames":[
{
"bmp":"3.png"
},
{
"bmp":"6.png"
}
],
"rotationaware":false
},
{
"id":"$Composition_Test_MSG$",
"text":"Test",
"title":"Test",
"type":"park",
"width":3,
"height":1,
"composition":[
{
"id":"$Composition_Test1_MSG$",
"x":0,
"y":0
},
{
"id":"$Composition_Test2_MSG$",
"x":1,
"y":0
},
{
"id":"$Composition_Test3_MSG$",
"x":2,
"y":0
}
],
"rotationaware":false
}
]
P.S. I cannot login & register.I also haven't received any mail. It's not just my problem some of user cannot receive any mail and also accounts are inactive...
-MsgmSgmsG-

MsgmSgmsG said

Re: Compositions

Posted: 02 May 2019, 16:01
by Lobby
This code works for me, did he ensure that he has the latest version (that is 606)?

Re: Compositions

Posted: 04 May 2019, 15:12
by Ssss
Ssss wrote:
02 May 2019, 15:04
When i use "Composition" to make 1×3 building, there is an error(game was shutdowned when i place my building). It work before i add two or more frames.

This is my plugin that has some problems.

Code: Select all

[
{
"id":"$Composition_Test1_MSG$",
"type":"decoration",
"width":1,
"height":1,
"buildtime":0,
"needsroad":false,
"author":"MSG",
"drawground":true,
"influencepark":30,
"influencepolice":100,
"influenceculture":2,
"price":0,
"monthlyprice":0,
"frames":[
{
"bmp":"1.png"
},
{
"bmp":"4.png"
}
],
"rotationaware":false
},
{
"id":"$Composition_Test2_MSG$",
"type":"decoration",
"width":1,
"height":1,
"buildtime":0,
"needsroad":false,
"author":"MSG",
"drawground":true,
"influencepark":30,
"influencepolice":100,
"influenceculture":2,
"price":0,
"monthlyprice":0,
"frames":[
{
"bmp":"2.png"
},
{
"bmp":"5.png"
}
],
"rotationaware":false
},
{
"id":"$Composition_Test3_MSG$",
"type":"decoration",
"width":1,
"height":1,
"buildtime":0,
"needsroad":false,
"author":"MSG",
"drawground":true,
"influencepark":30,
"influencepolice":100,
"influenceculture":2,
"price":0,
"monthlyprice":0,
"frames":[
{
"bmp":"3.png"
},
{
"bmp":"6.png"
}
],
"rotationaware":false
},
{
"id":"$Composition_Test_MSG$",
"text":"Test",
"title":"Test",
"type":"park",
"width":3,
"height":1,
"composition":[
{
"id":"$Composition_Test1_MSG$",
"x":0,
"y":0
},
{
"id":"$Composition_Test2_MSG$",
"x":1,
"y":0
},
{
"id":"$Composition_Test3_MSG$",
"x":2,
"y":0
}
],
"rotationaware":false
}
]
P.S. I cannot login & register.I also haven't received any mail. It's not just my problem some of user cannot receive any mail and also accounts are inactive...
-MsgmSgmsG-

MsgmSgmsG said

Re: Compositions

Posted: 04 May 2019, 15:13
by Ssss
Lobby wrote:
02 May 2019, 16:01
This code works for me, did he ensure that he has the latest version (that is 606)?

Re: Compositions

Posted: 04 May 2019, 20:00
by Lobby
The composition building has to be rotation aware since the map can be rotated. Therefor, remove the line

Code: Select all

"rotation aware":false
from your composition building $Composition_Test_MSG and it should work.

Re: Compositions

Posted: 18 May 2019, 03:01
by Mrqwerty
Can RCI be built in a composition?

Re: Compositions

Posted: 18 May 2019, 16:13
by Mrqwerty
Ok i guess it can have rci. I tried it. Also the tool is very helpful!

Re: Compositions

Posted: 07 Jun 2019, 11:12
by Lobby
:66: Time for some pre-built intersections I guess.

Re: Compositions

Posted: 04 Jul 2019, 16:24
by XNOTE
Is this only working on 1x1 buildings? (I was trying to make my own composition with 8x8 buildings and it doesn't build any building.

Re: Compositions

Posted: 04 Jul 2019, 17:02
by CommanderABab
It works for other sizes also, but placement is tricky.

Re: Compositions

Posted: 04 Jul 2019, 17:41
by CommanderABab
Screenshot_20190704-110549.png
Screenshot_20190704-110749.png
Screenshot_20190704-111119.png
Screenshot_20190704-110613.png
Screenshot_20190704-111135.png
It's mostly industrial, but there are a decoration and a small fire station included. To place requires a large area zoned industrial. Roads will have to be built surrounding the buildings to keep them viable.

Re: Compositions

Posted: 27 Jul 2019, 11:14
by AngelPandaEarth
Wow, so I can add presets to a future plugin I'm making.

Re: Compositions

Posted: 29 Aug 2019, 17:13
by Sparkle8538
Screenshot_20190829-170600.png

Re: Compositions

Posted: 17 Jul 2020, 02:49
by choggoba
When inserting a one-way road (64 frames) into a composition tag,
The completed road uses 64 frames.

However, before road construction (preview), only 16 frames are used.

So users can't predict exactly what the road will look like before it's built.
What should I do?
Screenshot_20200717-092951_TheoTown.jpg
Screenshot_20200717-093026_Pixly.jpg

Re: Compositions

Posted: 17 Jul 2020, 18:48
by Lobby
I have to admit, I don't see a difference between them in the image.

However, it is correct, the game does not use direction information for the preview of roads in compositions as of right now.



Please send me your plugin including the composition, I will then try to fix that :)

Re: Compositions

Posted: 03 Jan 2021, 09:33
by AngelPandaEarth
Why can't I place this
Screenshot_20210103-023135_TheoTown.jpg