Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a shortcut to automatically generate a setter and getter for a property #6063

Closed
Eerywax opened this issue Jan 7, 2023 · 1 comment
Closed

Comments

@Eerywax
Copy link

Eerywax commented Jan 7, 2023

Describe the project you are working on

I'm making a survivor-like type of game with a bunch of stats (per-weapon, and global to each weapon owned by an Actor) which is intended as my practicing composition pattern, with so-far heavy use of Resources, which contain the many stats for the weapons and actors.

Describe the problem or limitation you are having in your project

When there is a large (or even moderate, to be honest) number of stats, it becomes tedious to create a setget function for each. Sometimes, one might want to use a setget simply to be more threadsafe, but the function might not have anything beyond the basic return or set functionality. In these cases,, copy-pasting but changing a single word in the variable gets tedious.

(15:33 in this video is where I got the notion that it's more thread-safe, I am not knowledgeable enough to know if this is true or not, but I did decide to err on the side of caution and make setgets!)

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It might be convenient if there was a hotkey to auto-generate blank (or bare-bones) setters and getters by hovering over the base variable declaration. From there the functionality would perhaps use the var name and append "set_" and "get_" to the front for the functions declared as the setters and getters, and then generate a basic setter/getter at the bottom of the script, by those names.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Addressed in the last section mostly, however I'm not sure what hotkey would be best. Maybe Ctrl + J, since J can be a visual mnemonic for a sweeping line that loops at the bottom, adding something to your the bottom of your script.

If this enhancement will not be used often, can it be worked around with a few lines of script?

The problem can be worked around with a few lines... per variable (arguably though it's not even a workaround, it's just implementing a setget). The issue arises when there are many variables, and the cost is human lifetime and energy.

Is there a reason why this should be core and not an add-on in the asset library?

"This is about improving the usability of the code editor out of the box."

@Calinou Calinou changed the title Add a Hotkey to Auto-generate basic Setters and Getters Add a shortcut to automatically generate a setter and getter for a property Jan 7, 2023
@Calinou
Copy link
Member

Calinou commented Jan 7, 2023

Duplicate of #1238.

@Calinou Calinou closed this as not planned Won't fix, can't repro, duplicate, stale Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants