## Categories

Learn here how to create and use plugins.

Moderator: Plugin Moderators

Lobby
Developer
Reactions:
Posts: 3631
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta

### Categories

Since version 337 you're able to define your own categories. Here you can see what that means:
Let's say we have the following plugin:

Code: Select all

[
{
"id":"$lobby_camp_dummy00", "type":"park", "title":"Plain area", "text":"Just a plain area.", "width":1, "height":1, "frames":[{"bmp":"dummy.png"}] } ] dummy.png (543 Bytes) Viewed 5650 times As it's a building of type park it will be put into the park category automatically. We want to put it into an own camping category. So let's define a new category for camping: Code: Select all  { "id":"$cat_lobby_camp00",
"type":"category",
"title":"Camping",
"frames":[{"bmp":"icon.png"}],
"ordinal":10
}
As icon I use this 26x26 pixel sized image:
icon.png (488 Bytes) Viewed 5650 times
I recommend to always use a size of 26x26 pixels for icons for consistency. In order to put our plugin into this category we have to specify the category manually:

Code: Select all

  {
"id":"$lobby_camp_dummy00", "type":"park", "category":"$cat_lobby_camp00",    // This way we define the category to put this park into
"title":"Plain area",
"text":"Just a plain area.",
"width":1,
"height":1,
"frames":[{"bmp":"dummy.png"}]
}
Pay attention on that the category you're referring to has to be defined before your plugin. Otherwise it cannot be assigned. The result looks now like this:The result:
Now you may want to put your category to a more meaningful position: behind the existing park category. To do so, we can use the attribute ordinal which can be also used to order items within a category:

Code: Select all

  {
"id":"$cat_lobby_camp00", "type":"category", "title":"Camping", "frames":[{"bmp":"icon.png"}], "ordinal":10 // Specify own position (after park, in this case) } The number you provide for ordinal determines which position should be used, with 0 being the first place. The result: Last but not least we may want to use another preview for our cool plank area. To do so, we can provide a preview frame like this in our plugin: Code: Select all  { "id":"$lobby_camp_dummy00",
"type":"park",
"category":"$cat_lobby_camp00", "title":"Plain area", "text":"Just a plain area.", "width":1, "height":1, "frames":[{"bmp":"dummy.png"}], "preview frames":[{"bmp":"icon.png"}] // A single frames to use for preview } Result: The whole code in a single file looks like this: Code: Select all [ { "id":"$cat_lobby_camp00",
"type":"category",
"title":"Camping",
"frames":[{"bmp":"icon.png"}],
"ordinal":10
},
{
"id":"$lobby_camp_dummy00", "type":"park", "category":"$cat_lobby_camp00",
"title":"Plain area",
"text":"Just a plain area.",
"width":1,
"height":1,
"frames":[{"bmp":"dummy.png"}],
"preview frames":[{"bmp":"icon.png"}]
}
]
You can use the code:

Code: Select all

"separator": true
to put a line that separates parts of a category

Have fun
=^._.^= ∫

Josh
Graphic designer
Reactions:
Posts: 2223
Joined: Sat Mar 11, 2017 19:20
Location: The Netherlands
Plugins: Show
Version: Beta

### Re: Categories

WoW
TheoTown player since update 1.1.50

Creator of Aldorria, Covinton Empire, West Country, Sunnydale

actemendes
Metropolitan
Reactions:
Posts: 131
Joined: Fri Jan 20, 2017 16:53
Location: Russia
Plugins: Show

### Re: Categories

It's unbelievable
Do not bend under a volatile world,
One day he will bend under us.

Bearbear76
Former Bearbear65
Reactions:
Posts: 5296
Joined: Fri Feb 10, 2017 14:53
Plugins: Show
Version: Beta

### Re: Categories

Well done !
Just my opinion

KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2103
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Contact:

### Re: Categories

Can you put two different plug-ins in a custom catagory or will it cause problems?

CommanderABab
AB
Reactions:
Posts: 9113
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

### Re: Categories

I believe so, after all the military road is still a road, but doesn't appear in the transport menu.

Lobby
Developer
Reactions:
Posts: 3631
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta

### Re: Categories

Yes, you can mix them in any way you like to. That's also how other items are organized internally. In case you want to put a plugin into another native category here are the ids:

$cat_terrain00$cat_road00
$cat_zone00$cat_residential00
$cat_commercial00$cat_industrial00
$cat_energy00$cat_water00
$cat_park00$cat_sport00
$cat_public00$cat_education00
$cat_religion00$cat_award00
$cat_firebrigade00$cat_police00
$cat_medic00$cat_military00
$cat_decoration00$cat_disaster00
=^._.^= ∫

Josh
Graphic designer
Reactions:
Posts: 2223
Joined: Sat Mar 11, 2017 19:20
Location: The Netherlands
Plugins: Show
Version: Beta

### Re: Categories

After making the camping category, it puts the caravans & tents in the camping category and the residential category
TheoTown player since update 1.1.50

Creator of Aldorria, Covinton Empire, West Country, Sunnydale

Lobby
Developer
Reactions:
Posts: 3631
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta

### Re: Categories

RCI buildings are handled in a special way. Might be changed in the future. After all, you can put them into a category.
=^._.^= ∫

Josh
Graphic designer
Reactions:
Posts: 2223
Joined: Sat Mar 11, 2017 19:20
Location: The Netherlands
Plugins: Show
Version: Beta

### Re: Categories

You can use the code:

Code: Select all

"separator": true
to put a line that separates parts of a category
TheoTown player since update 1.1.50

Creator of Aldorria, Covinton Empire, West Country, Sunnydale

CommanderABab
AB
Reactions:
Posts: 9113
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

### Re: Categories

Attachments
act26ik.png (330 Bytes) Viewed 5575 times

mdk_813
Inhabitant of a Country
Reactions:
Posts: 860
Joined: Fri Dec 16, 2016 2:38
Location: Germany
Plugins: Show

### Re: Categories

In the example above, the category is defined at the beginning of the plugin-json, before the definition of the plugin itself. That is fine, if you have one plugin, for which you want to make a special category.
But, I would like to make a category that incorporates a number of different plugins.
Is it possible to define once and for all a category in one separate json-file, so that I just have to set the category in the jsons of all future plugins? Or would I have to define the category everytime at the start of each single plugin all over again?

edit: I deleted some stuff that I discovered was incorrect. nevermind.

Update Sep 12, 2020:
As I am not really active here anymore, I am not able to answer any PMs in time.
So, as long as you mention me in the plugin and the description, feel free to use or modify my plugins for your own creations.

Lobby
Developer
Reactions:
Posts: 3631
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta

### Re: Categories

It's not important where a category is defined as long as it's read in before plugins start using it. Maybe create a new directory for the category and name it so that it's read in at first in any case.

These plugins define only categories, for example:
Plugin storage
More categories (no longer available)
=^._.^= ∫

sairam
Inhabitant of a Conurbation
Reactions:
Posts: 537
Joined: Sun Dec 31, 2017 13:35
Location: India Pudukkottai
Plugins: Show
Version: Beta

### Re: Categories

There are some categories left.

Code: Select all

 $cat_terrain00$cat_asphalt00

$cat_transport00$cat_road00
$cat_roaddeco00$cat_bus00
$cat_train00$cat_airport00

$cat_zone00$cat_residential00
$cat_commercial00$cat_industrial00

$cat_supply00$cat_energy00
$cat_water00$cat_wastedisposal00
$cat_bodydisposal00$cat_public00
$cat_park00$cat_sport00
$cat_public00$cat_management00
$cat_award00$cat_religion00
$cat_decoration00$category_christmas00
$category_firework00$cat_service00
$cat_firebrigade00$cat_education00
$cat_medic00$cat_police00
$cat_military00$cat_landmark00

$cat_disaster00  Last edited by sairam on Tue Oct 30, 2018 17:39, edited 1 time in total. Proud to be the player of theotown since 1.0.45 alpha. Proud to be the first Tamil theotowner. Done 2 plugins. ( ͡° ͜ʖ ͡°) sairam Inhabitant of a Conurbation Reactions: Posts: 537 Joined: Sun Dec 31, 2017 13:35 Location: India Pudukkottai Plugins: Show Version: Beta #### Platform ### Re: Categories I have a doubt that the can i place my category next to the RCI categories. I am doing a plugin which is next to RCI categories. So I just asked i used ordinal but doesn't works. Please can any of you one help me. Proud to be the player of theotown since 1.0.45 alpha. Proud to be the first Tamil theotowner. Done 2 plugins. ( ͡° ͜ʖ ͡°) Bearbear76 Former Bearbear65 Reactions: Posts: 5296 Joined: Fri Feb 10, 2017 14:53 Plugins: Show Version: Beta #### Platform #### Plugin Creator ### Re: Categories sairam wrote: Wed Aug 08, 2018 5:41 I have a doubt that the can i place my category next to the RCI categories. I am doing a plugin which is next to RCI categories. So I just asked i used ordinal but doesn't works. Please can any of you one help me. Try something like this Code: Select all [{ "id":"ID", "title":"Text", "category":"$cat_zone00",
"type":"category",
"ordinal":x,
"frames":[{"bmp":"icon.png"}]
}]
Just my opinion

sairam
Inhabitant of a Conurbation
Reactions:
Posts: 537
Joined: Sun Dec 31, 2017 13:35
Location: India Pudukkottai
Plugins: Show
Version: Beta

### Re: Categories

Not working.
Proud to be the player of theotown since 1.0.45 alpha.
Proud to be the first Tamil theotowner. Done 2 plugins.
( ͡° ͜ʖ ͡°)

CommanderABab
AB
Reactions:
Posts: 9113
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

### Re: Categories

Try:

Code: Select all

  "ordinal from":"$existing_category_id_00", "ordinal":1, to place your category after it. sairam Inhabitant of a Conurbation Reactions: Posts: 537 Joined: Sun Dec 31, 2017 13:35 Location: India Pudukkottai Plugins: Show Version: Beta #### Platform ### Re: Categories Not working Code: Select all  [{"category":"$cat_zone00","frames":[{"bmp":"icon.png"}],"id":"$cat_cat_zone","ordinal from":"$cat_industrial00",
"ordinal":1,"title":"buildings","type":"category"}]
Proud to be the player of theotown since 1.0.45 alpha.
Proud to be the first Tamil theotowner. Done 2 plugins.
( ͡° ͜ʖ ͡°)

Bearbear76
Former Bearbear65
Reactions:
Posts: 5296
Joined: Fri Feb 10, 2017 14:53
Plugins: Show
Version: Beta

### Re: Categories

So if you want to do something like this you would have to write your JSON like the way I wrote above

The JSON I used :

Code: Select all

[{
"id":"Cat_typ0",
"ordinal":0,
"type":"category",
"category":"\$cat_zone00",
"frames":[{"bmp":"Cat_Icon.png"}],
"title":"Rnd Category"
}]
Just my opinion