Skip to content

Separate elements into separate files#1

Open
KitCat962 wants to merge 1 commit intov3.xfrom
seperate-files
Open

Separate elements into separate files#1
KitCat962 wants to merge 1 commit intov3.xfrom
seperate-files

Conversation

@KitCat962
Copy link

Because of the FileAPI, we can have seperate files for organization. Lets abuse that.
libraries/GNUI.lua is now a loader script. It ensures that the user is the host and that GNUI is installed.
the GNUI folder goes in the data folder in the Figura directory. Drag drop.
data:GNUI/GNUI.lua is the actual main script. At the bottom of the script, it loads every single file in the data:GNUI/elements folder and adds the return to a elements table, expecting the class to be returned. If its not returned, assume forgor and error. When the loadElement function is executed with an invalid element (for whatever reason), it will not error and return false.
All element scripts are expected to declare local elements, utils, eventLib, config, debug = ... to access main script variables, and return their class table.
All element class tables will be added to the elements table, and retrieved if not found. This ensures that load order does not matter.
The return value of data:GNUI/GNUI.lua has been changed. All the newX function explicit declarations have been removed in favor of the elements table and newX being an __index alias for elements[x].new.
So now, so long as you have the textbox.lua in the elements folder, you can do GNUI.newTextBox() case insensitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant