Compositions

Learn here how to create and use plugins.

Moderator: Plugin Moderators

User avatar
Lobby
Developer
Reactions:
Posts: 3285
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Platform

Compositions

#1

Post by Lobby » Sun Apr 28, 2019 19:04

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 below 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 6 times
which results in :img
result.png
result.png (186.35 KiB) Viewed 429 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.



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.
...Have a nice stay

User avatar
rjroldan1
Inhabitant of a Conurbation
Reactions:
Posts: 461
Joined: Mon Jul 17, 2017 16:16
Location: philippines
Plugins: Show
Version: Beta
Contact:

Platform

Plugin Creator

Re: Compositions

#2

Post by rjroldan1 » Mon Apr 29, 2019 18:21

Can you give sample zip for this Lobby?
Silent

President of Metropole region

____________________________________________________________________________________
I LOVE PHILIPPINES

User avatar
Lobby
Developer
Reactions:
Posts: 3285
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Platform

Re: Compositions

#3

Post by Lobby » Mon Apr 29, 2019 18:41

Of course! Added the json file to it :json
...Have a nice stay

User avatar
BetterBear
Inhabitant of a Galaxy Cluster
Reactions:
Posts: 2886
Joined: Tue Apr 18, 2017 9:03
Location: In a place you don't expect.
Plugins: Show
Version: Beta
Phone model: Have 3, all too long

Platform

Re: Compositions

#4

Post by BetterBear » Tue Apr 30, 2019 4:05

Thank you!

This will definately make some things come to life, such as one-tap custom intersections. :)
BEaRz ArE AmAZiNG. I Am FeElIng SlEepY..

User avatar
Ssss
Metropolitan
Reactions:
Posts: 127
Joined: Sat Feb 24, 2018 14:51
Location: South korea
Plugins: Show
Version: Beta
Phone model: LG Q9
Contact:

Platform

Plugin Creator

Re: Compositions

#5

Post by Ssss » Thu May 02, 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
My name is dumbul(lego) i live in South Korea dongtan
Youtube channel:덤불dumbul s1s2s3s4[youtube][/youtube] :lol:
I admire everyone.
:bp :bd

User avatar
Lobby
Developer
Reactions:
Posts: 3285
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Platform

Re: Compositions

#6

Post by Lobby » Thu May 02, 2019 16:01

This code works for me, did he ensure that he has the latest version (that is 606)?
...Have a nice stay

User avatar
Ssss
Metropolitan
Reactions:
Posts: 127
Joined: Sat Feb 24, 2018 14:51
Location: South korea
Plugins: Show
Version: Beta
Phone model: LG Q9
Contact:

Platform

Plugin Creator

Re: Compositions

#7

Post by Ssss » Sat May 04, 2019 15:12

Ssss wrote:
Thu May 02, 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
Attachments
Composition_test.zip
(169.96 KiB) Downloaded 1 time
My name is dumbul(lego) i live in South Korea dongtan
Youtube channel:덤불dumbul s1s2s3s4[youtube][/youtube] :lol:
I admire everyone.
:bp :bd

User avatar
Ssss
Metropolitan
Reactions:
Posts: 127
Joined: Sat Feb 24, 2018 14:51
Location: South korea
Plugins: Show
Version: Beta
Phone model: LG Q9
Contact:

Platform

Plugin Creator

Re: Compositions

#8

Post by Ssss » Sat May 04, 2019 15:13

Lobby wrote:
Thu May 02, 2019 16:01
This code works for me, did he ensure that he has the latest version (that is 606)?
Attachments
Composition_test.zip
(169.96 KiB) Downloaded 2 times
My name is dumbul(lego) i live in South Korea dongtan
Youtube channel:덤불dumbul s1s2s3s4[youtube][/youtube] :lol:
I admire everyone.
:bp :bd

User avatar
Lobby
Developer
Reactions:
Posts: 3285
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Platform

Re: Compositions

#9

Post by Lobby » Sat May 04, 2019 20:00

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.
...Have a nice stay

User avatar
Mrqwerty
Inhabitant of a Megacity
Reactions:
Posts: 194
Joined: Sat Oct 06, 2018 21:48
Location: VER-MONT!
Plugins: Show
Version: Beta
Phone model: 2003 LG flip phone

Platform

Plugin Creator

Re: Compositions

#10

Post by Mrqwerty » Sat May 18, 2019 3:01

Can RCI be built in a composition?
WHAT IS THE DEAL WITH AIRPLANE FOOD :calc :bb :bq
http://www.theotown.com/forum/search.ph ... =firstpost <--PLUGINS

User avatar
Mrqwerty
Inhabitant of a Megacity
Reactions:
Posts: 194
Joined: Sat Oct 06, 2018 21:48
Location: VER-MONT!
Plugins: Show
Version: Beta
Phone model: 2003 LG flip phone

Platform

Plugin Creator

Re: Compositions

#11

Post by Mrqwerty » Sat May 18, 2019 16:13

Ok i guess it can have rci. I tried it. Also the tool is very helpful!
WHAT IS THE DEAL WITH AIRPLANE FOOD :calc :bb :bq
http://www.theotown.com/forum/search.ph ... =firstpost <--PLUGINS

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest