Categories

Learn here how to create and use plugins.

Moderator: Plugin Moderators

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Categories

#1

Post by Lobby »

Since version 337 you're able to define your own categories. Here you can see what that means:
Inked2017-09-08 12.06.06_LI.jpg
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
dummy.png (543 Bytes) Viewed 22560 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
icon.png (488 Bytes) Viewed 22560 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:
2017-09-08 12.06.55.png
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:
2017-09-08 12.07.51.png
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:
2017-09-08 12.20.58.png
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 :space
=^._.^= ∫

User avatar
Josh
Graphic designer
Reactions:
Posts: 2214
Joined: 11 Mar 2017, 19:20
Location: The Netherlands
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Categories

#2

Post by Josh »

WoW :D
TheoTown player since update 1.1.50

Creator of Aldorria, Covinton Empire, West Country, Sunnydale

User avatar
actemendes
Metropolitan
Reactions:
Posts: 131
Joined: 20 Jan 2017, 16:53
Location: Russia
Plugins: Showcase Store

Platform

Re: Categories

#3

Post by actemendes »

It's unbelievable
Do not bend under a volatile world,
One day he will bend under us.Theo of tomorrow in developing.

User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Categories

#4

Post by Bearbear76 »

Well done !
Just my opinion
retired

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2220
Joined: 07 Jul 2016, 22:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

Re: Categories

#5

Post by KINGTUT10101 »

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

User avatar
CommanderABab
AB
Reactions:
Posts: 11109
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Categories

#6

Post by CommanderABab »

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

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Categories

#7

Post by Lobby »

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
=^._.^= ∫

User avatar
Josh
Graphic designer
Reactions:
Posts: 2214
Joined: 11 Mar 2017, 19:20
Location: The Netherlands
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Categories

#8

Post by Josh »

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

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Categories

#9

Post by Lobby »

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

User avatar
Josh
Graphic designer
Reactions:
Posts: 2214
Joined: 11 Mar 2017, 19:20
Location: The Netherlands
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Categories

#10

Post by Josh »

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

User avatar
CommanderABab
AB
Reactions:
Posts: 11109
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Categories

#11

Post by CommanderABab »

Got one made! :)Image


Image
Attachments
Screenshot_20170908-090655.jpg
act26ik.png
act26ik.png (330 Bytes) Viewed 22485 times
my avatar:

User avatar
mdk_813
Inhabitant of a Country
Reactions:
Posts: 857
Joined: 16 Dec 2016, 02:38
Location: Germany
Plugins: Showcase Store

Platform

Re: Categories

#12

Post by mdk_813 »

I have a question about this:
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.
My Plugins: Link

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.

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Categories

#13

Post by Lobby »

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)
=^._.^= ∫

User avatar
sairam
Inhabitant of a Conurbation
Reactions:
Posts: 537
Joined: 31 Dec 2017, 13:35
Location: India Pudukkottai
Plugins: Showcase Store
Version: Beta

Platform

Re: Categories

#14

Post by sairam »

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 30 Oct 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.
:D ( ͡° ͜ʖ ͡°)

User avatar
sairam
Inhabitant of a Conurbation
Reactions:
Posts: 537
Joined: 31 Dec 2017, 13:35
Location: India Pudukkottai
Plugins: Showcase Store
Version: Beta

Platform

Re: Categories

#15

Post by sairam »

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.
:D ( ͡° ͜ʖ ͡°)

User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Categories

#16

Post by Bearbear76 »

sairam wrote:
08 Aug 2018, 05: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
retired

User avatar
sairam
Inhabitant of a Conurbation
Reactions:
Posts: 537
Joined: 31 Dec 2017, 13:35
Location: India Pudukkottai
Plugins: Showcase Store
Version: Beta

Platform

Re: Categories

#17

Post by sairam »

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

User avatar
CommanderABab
AB
Reactions:
Posts: 11109
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Categories

#18

Post by CommanderABab »

Try:

Code: Select all

  "ordinal from":"$existing_category_id_00",
    "ordinal":1,
to place your category after it.
my avatar:

User avatar
sairam
Inhabitant of a Conurbation
Reactions:
Posts: 537
Joined: 31 Dec 2017, 13:35
Location: India Pudukkottai
Plugins: Showcase Store
Version: Beta

Platform

Re: Categories

#19

Post by sairam »

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.
:D ( ͡° ͜ʖ ͡°)

User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Categories

#20

Post by Bearbear76 »

Screenshot_2018-08-12-11-42-05.jpg
So if you want to do something like this you would have to write your JSON like the way I wrote above :json

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
retired

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”