HalRiyami
Member
For those who have published function heavy assets, pre and post 2.3. Pre 2.3, whenever you built a system it most likely looked like a bunch of scripts the user can see for every function your asset provides (whether you wanted to expose the function to the user or not) but now with 2.3, you get to choose how your functions are presented and have the option of using methods instead.
Suppose I have a collision system I am building, pre 2.3 it would look like this:
Now, I have multiple options:
Obviously there are more styles but you get the idea.
I am wondering how you guys decide which style to go for, how to present the functions, and what considerations go into your decision making. Do you simply go for what makes the most sense to you? Do you lean towards consistency? How about ease of use on the users' end? I am mainly wondering "how do I make sure the user can quickly and reliably find the functions I want them to use while at the same time hiding any code they don't need to interact with?"
I currently have two fully featured systems I built for myself and I believe they might be worth sharing/selling but they are written in GMS 2.2.5 and so I am trying to figure out if there is a standard you follow or if you lean towards one style over another.
Cheers
Suppose I have a collision system I am building, pre 2.3 it would look like this:
GML:
// Scripts
// Folder: My Collision System
// Folder: Exposed Functions
collider_create()
collider_set_scale()
collider_get_scale()
...
// Folder: Internal Functions
__collider_update()
__collider_get_centroid()
...
1. Keep it the same way with minor adjustments to where internal functions are placed. This is a good way to maintain similarity with pre 2.3 scripts and any user should be able to pick up which functions are available to them at a glance. What's bad about this is that now you have a bunch of script assets and many of them do one thing, so you're not really utilizing the new system as much as you could.
GML:
// Folder: My Collision System
// Folder: Exposed Functions
// Script Asset: collider_create
function collider_create()
// Script Asset: collider_set_scale
function collider_set_scale()
// Script Asset: collider_get_scale
function collider_get_scale()
...
// Script Asset: collider_internal_functions
function __collider_update()
function __collider_get_centroid()
...
2. Move all functions into appropriate script assets that indicate to the user where they should go to look for relevant functions. The nice thing about this is that functions are tucked nicely inside script assets. I can easily tell that all my collider functions are going to be under "collider_exposed_functions" but now I have to open the script asset to know what functions are actually available to me.
GML:
// Folder: My Collision System
// Script Asset: collider_exposed_functions
function collider_create()
function collider_set_scale()
function collider_get_scale()
...
// Script Asset: collider_internal_functions
function __collider_update()
function __collider_get_centroid()
...
3. Where appropriate use constructors and methods. "collider_create" now creates a struct that holds all the collider's information and gives it the appropriate method variables pertinent to the struct so it makes perfect sense to have it this way. One issue is that you're very likely to mix both named functions and method variables and this could create some confusion for the user. Another issue here is that for this particular style, the user can easily see all method variables so you have to explicitly tell them which to use and which to avoid.
GML:
// Folder: My Collision System
// Script Asset: collider_functions
function collider_create() constructor
// Exposed Functions
static setScale = function()
static getScale = function()
...
// Internal Functions
static update = function()
static getCentroid = function()
...
I am wondering how you guys decide which style to go for, how to present the functions, and what considerations go into your decision making. Do you simply go for what makes the most sense to you? Do you lean towards consistency? How about ease of use on the users' end? I am mainly wondering "how do I make sure the user can quickly and reliably find the functions I want them to use while at the same time hiding any code they don't need to interact with?"
I currently have two fully featured systems I built for myself and I believe they might be worth sharing/selling but they are written in GMS 2.2.5 and so I am trying to figure out if there is a standard you follow or if you lean towards one style over another.
Cheers