LayoutOrder
Module Oriented Object ProgramingCreate a layout order using an attribute easily.
Install the module
Go on github then install the source code. After this, import it on roblox studio, preferally on ReplicatedStorage.
Use the module
Create a script, (preferably a localscript but both work), you will need to require the script with a path. The path is where the instance is. For example if your module is on replicatedStorage, you can type game:GetService("ReplicatedStorage").LayoutOrder
if the module is on a folder named "Modules" which is on ReplicatedStorage then game:GetService("ReplicatedStorage").Modules.LayoutOrder
. Now that you know how to get an instance's path, you will need to create a variable and require() the module.
local module = require(path.to.module)
local module = require(path.to.module)
It's not harder than that. You can now create another variable with value module.new()
to create an audio.
local module = require(path.to.module)
local layout = module.new()
local module = require(path.to.module)
local layout = module.new()
Properties
there are 2 main properties:
- layout
- attributeName both are required.
layout
must be a UIListLayout or UIGridLayout & attributeName must be a string.
now you can add whatever properties you want. for example
local module = require(path.to.module)
local layout = module.new()
layout.layout = path.to.layout
layout.attributeName = "rarity"
layout.COMMON = 1
layout.RARE = 2
layout.EPIC = 3
layout.LEGENDARY = 4
layout.EXCLUSIVE = 5
local module = require(path.to.module)
local layout = module.new()
layout.layout = path.to.layout
layout.attributeName = "rarity"
layout.COMMON = 1
layout.RARE = 2
layout.EPIC = 3
layout.LEGENDARY = 4
layout.EXCLUSIVE = 5
as you can see, COMMON
, RARE
, ...
are not autocompleting. This is because you can create your own order. The index (COMMON
, RARE
, ...
) is the attribute value & the value (1, 2, ...
) are the order to give.
Method
Now that you gave every info you add, you can do layout:Order()
to order every child of layout parent which are guielements.
Example
local module = require(path.to.module)
local layout = module.new()
layout.layout = path.to.layout
layout.attributeName = "rarity"
layout.COMMON = 1
layout.RARE = 2
layout.EPIC = 3
layout.LEGENDARY = 4
layout.EXCLUSIVE = 5
layout:Order()
local module = require(path.to.module)
local layout = module.new()
layout.layout = path.to.layout
layout.attributeName = "rarity"
layout.COMMON = 1
layout.RARE = 2
layout.EPIC = 3
layout.LEGENDARY = 4
layout.EXCLUSIVE = 5
layout:Order()
Credits
Here is every user contributed on audioManager's documentation