A way to influence the order of menu entries?

Learn here how to create and use plugins.

Moderator: Plugin Moderators

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

Platform

A way to influence the order of menu entries?

#1

Post by mdk_813 » Tue Sep 19, 2017 15:14

Hi,
I've recently updated to the new public version 1.3.46 and I noticed that the order of my plugin entries in the menus has changed drastically.
Before, new entries would usually be located at the bottom of a menu so that when you add several new plugins that belong together at the same time they would also show up next to each other in the menu. But, now all this order is totally mixed up so that I have to scroll around much more.
How is the order of entries determined by the game? And is there a way to influence that order?
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
Brody Craft
Inhabitant of a Infinity
Reactions:
Posts: 8035
Joined: Tue Jan 24, 2017 11:15
Location: SE Asia
Plugins: Show
Version: Beta
Phone model: Samsung Galaxy Tab 3

Platform

Re: A way to influence the order of menu entries?

#2

Post by Brody Craft » Tue Sep 19, 2017 15:15

Alphabetical orders
When you get to be called a Board Index because you are too good.>:3

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

Platform

Re: A way to influence the order of menu entries?

#3

Post by mdk_813 » Tue Sep 19, 2017 16:04

Are you sure? The alphabetical Order of what? The id, the title?
Because honestly, it I have entries starting with "R" that are listed before "P"...
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
CommanderABab
AB
Reactions:
Posts: 7933
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: A way to influence the order of menu entries?

#4

Post by CommanderABab » Tue Sep 19, 2017 17:56

File and folder name alphabetical order. You can use "ordinal":number to place plugins in different menu places.

Use

Code: Select all

ordinal:-1
to place before default buildings. Use something like

Code: Select all

ordinal:5000
to place at the end.
777!777Currently using alpha 777. 777 What's new? :)
online maps!!
:)

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

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

Platform

Re: A way to influence the order of menu entries?

#5

Post by Lobby » Tue Sep 19, 2017 18:40

Yes, folders are read in alphabetical order now (before the update it was device dependent. On some devices the order was based on alphabetical order, too, but others used date or no meaningful ordering at all). Let's assume you have the following folders and files in your plugin dir:

Code: Select all

A/935.json
A/743.json
B/534.json
B/C/235.json
It's now ensured that json files are read in in this order:

Code: Select all

743.json
935.json
534.json
235.json
So the algorithm behind it works like this for a plugin folder p:
1. Read in all files in p in alphabetical order
2. Execute the algorithm on all folders in p in alphabetical order

I suggest that every plugin maker uses an own top level directory that identifies his work. E.g. for a file structure like this in my case:

Code: Select all

lobby/animals/animals.json
lobby/game of life/gof.json
lobby/ufo/ufo.json
However, the creator has the freedom to not follow this scheme :space



You can use ordinal as proposed by @CommanderABab. If you don't give an explicit ordinal value it will be set automatically based on the ordering in which plugins are read in. It's possible to combine ordinal with ordinal from to place items relative to others based on others id:

Code: Select all

"ordinal from":"$idofsomethingelse",
"ordinal":1
This code will place the item right behind the item of id $idofsomethingelse. It also works with categories.
...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

Plugin Creator

Re: A way to influence the order of menu entries?

#6

Post by Josh » Tue Sep 19, 2017 18:42

Again, learned something new :)
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: 3384
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Platform

Re: A way to influence the order of menu entries?

#7

Post by Lobby » Tue Sep 19, 2017 18:54

So I moved it into the documentation forum so it's easier to find.
...Have a nice stay

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

Platform

Re: A way to influence the order of menu entries?

#8

Post by mdk_813 » Tue Sep 19, 2017 19:29

Cool, thanks!
My Plugins: Link

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

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest