Categories

Learn here how to create and use plugins.

Moderator: Plugin Moderators

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

Platform

Categories

#1

Post by Lobby » Fri Sep 08, 2017 12:33

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

User avatar
Josh
Graphic designer
Reactions:
Posts: 2212
Joined: Sat Mar 11, 2017 19:20
Location: The Netherlands
Plugins: Show
Version: Beta
Phone model: Iphone 7

Platform

Re: Categories

#2

Post by Josh » Fri Sep 08, 2017 12:38

WoW :D
Proud TheoTown player sinds update 1.1.50

Creator of Aldorria, Covinton Empire, West Country, Sunnydale

Save nature, before it kills you🌲

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

Platform

Re: Categories

#3

Post by actemendes » Fri Sep 08, 2017 12:57

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

User avatar
Bearbear65
Inhabitant of a Universe
Reactions:
Posts: 4594
Joined: Fri Feb 10, 2017 14:53
Plugins: Show
Version: Beta
Phone model: Xperia™ XZ1 SO-01K

Platform

Re: Categories

#4

Post by Bearbear65 » Fri Sep 08, 2017 13:01

Well done !
ImageJust my opinion
Theotown forum authoritarian! pszo48ly

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 1886
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Phone model: Moto Z Force Droid

Platform

Re: Categories

#5

Post by KINGTUT10101 » Fri Sep 08, 2017 14:37

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

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

Platform

Plugin Creator

Re: Categories

#6

Post by CommanderABab » Fri Sep 08, 2017 14:42

I believe so, after all the military road is still a road, but doesn't appear in the transport menu.
746!746Currently using beta 746. 746 What's new? :)
lit trfc lights!!
:)

Telegram - t.me/
🆎️🆎️🆎️🆎️Commander🆎️🆎️

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

Platform

Re: Categories

#7

Post by Lobby » Fri Sep 08, 2017 14:57

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

User avatar
Josh
Graphic designer
Reactions:
Posts: 2212
Joined: Sat Mar 11, 2017 19:20
Location: The Netherlands
Plugins: Show
Version: Beta
Phone model: Iphone 7

Platform

Re: Categories

#8

Post by Josh » Fri Sep 08, 2017 15:14

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

Creator of Aldorria, Covinton Empire, West Country, Sunnydale

Save nature, before it kills you🌲

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

Platform

Re: Categories

#9

Post by Lobby » Fri Sep 08, 2017 15:19

RCI buildings are handled in a special way. Might be changed in the future. After all, you can put them into a category.
...Have a nice stay

User avatar
Josh
Graphic designer
Reactions:
Posts: 2212
Joined: Sat Mar 11, 2017 19:20
Location: The Netherlands
Plugins: Show
Version: Beta
Phone model: Iphone 7

Platform

Re: Categories

#10

Post by Josh » Fri Sep 08, 2017 15:27

You can use the code:

Code: Select all

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

Creator of Aldorria, Covinton Empire, West Country, Sunnydale

Save nature, before it kills you🌲

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

Platform

Plugin Creator

Re: Categories

#11

Post by CommanderABab » Fri Sep 08, 2017 16:52

Got one made! :)Image


Image
Attachments
Screenshot_20170908-090655.jpg
act26ik.png
act26ik.png (330 Bytes) Viewed 3191 times
746!746Currently using beta 746. 746 What's new? :)
lit trfc lights!!
:)

Telegram - t.me/
🆎️🆎️🆎️🆎️Commander🆎️🆎️

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

Platform

Re: Categories

#12

Post by mdk_813 » Sun Sep 24, 2017 0:48

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

PLEASE NOTE: My plugins are not open source! So, ask me first before altering and republishing any of my plugins!

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

Platform

Re: Categories

#13

Post by Lobby » Sun Sep 24, 2017 11:44

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

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

Platform

Re: Categories

#14

Post by sairam » Thu Jul 19, 2018 18:30

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

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

Platform

Re: Categories

#15

Post by sairam » 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.
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
Bearbear65
Inhabitant of a Universe
Reactions:
Posts: 4594
Joined: Fri Feb 10, 2017 14:53
Plugins: Show
Version: Beta
Phone model: Xperia™ XZ1 SO-01K

Platform

Re: Categories

#16

Post by Bearbear65 » Wed Aug 08, 2018 13:30

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"}]
}]
ImageJust my opinion
Theotown forum authoritarian! pszo48ly

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

Platform

Re: Categories

#17

Post by sairam » Wed Aug 08, 2018 15:52

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: 7568
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Categories

#18

Post by CommanderABab » Wed Aug 08, 2018 18:25

Try:

Code: Select all

  "ordinal from":"$existing_category_id_00",
    "ordinal":1,
to place your category after it.
746!746Currently using beta 746. 746 What's new? :)
lit trfc lights!!
:)

Telegram - t.me/
🆎️🆎️🆎️🆎️Commander🆎️🆎️

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

Platform

Re: Categories

#19

Post by sairam » Thu Aug 09, 2018 4:18

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
Bearbear65
Inhabitant of a Universe
Reactions:
Posts: 4594
Joined: Fri Feb 10, 2017 14:53
Plugins: Show
Version: Beta
Phone model: Xperia™ XZ1 SO-01K

Platform

Re: Categories

#20

Post by Bearbear65 » Sun Aug 12, 2018 4:44

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"
}]
ImageJust my opinion
Theotown forum authoritarian! pszo48ly

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”

Who is online

Users browsing this forum: No registered users and 2 guests