Code Snippets
Code Snippets is a pretty easy to use, configureable Plugin that lets you turn a big chunk of code, or even entire Modules into a single keyword that you type into your Script Editor to avoid having to type it out every time you need it.
(You dont actually have to open the Snippet itself to use it, infact you dont even have to open the Plugin to use it)
IMPORTANT NOTES:
- Due to how Roblox works, updating the Script Source will automatically reset your Cursor position!
- Incase anything happens I would recommend backing up Important Code when the Snippets are disabled as this might mess with it if it finds any Keywords you had in your Script before you enable it or use it for the first time!
- This Plugin only affects the currently active Script that you are editing, so you dont really have to worry about any Code that you don’t plan on opening when using Code Snippets.
- This Plugin will propably ask you to let it modify Scripts, if you are scared of it being malicious, the Source Code isnt obfuscated or anything so you can read it first if you want to make sure
Why use Code Snippets?
Well, why shouldn’t you? It literally just lets you Code more efficiently without having to go through your Inventory or other Places to find Code that you need. Its all there after typing just one Word. If you dont want to use it then dont.
How do I use it?
This is for people who have no idea how to use it atall:
When you open the Plugin, you should see two Boxes, one with a crossed out Symbol and one with a big green Button. The one with the crossed out Symbol is the Code Snippets Editor, where you will be writing your Snippets (or just pasting it in if you want to write them in an external Editor or something).
The green Button lets you create Snippets. After clicking it you should notice that a new Snippet was added, which includes a frame where the Name of the Snippet is displayed (this can be edited like a Textbox), a delete Button and an edit Button. The Key (what you write in the Script Editor) is going to be set to the name of the Snippet by default (you can change this to whatever you want I’ll go into that later), and the Code is, well, the Code that the Key gets replaced with.
NOTE: Take a look at the Settings (and more information on them if you need it) if your Snippets arent working before asking Questions please!
Does it save?
Yes. It saves across all your Places, so if you write a Snippet in one Place you can use it anywhere, unless I messed something up somewhere if I did please let me know!
More Information on how to use it (Keys, Settings etc)
More Information
More Information on Keywords and Importing
Keys
In the first gif you can see in my “header” Snippet code, theres actually a
key "head"
This is actually because the Plugin will detect this and instead of setting the Keyword to the Name of the Snippet, it gets set to the Keyword specified in the String (It has to be a string, doesn’t matter if you use single or double quotes)
IMPORTANT: Make sure this is on its own line, and theres nothing other than the “key” and the string! no ; or anything
Imports
Using the “letimport” keyword in your Code will allow you to compress the Code into a module, as seen in the gif below:
If no return is detected in the script, it will add one by itself. This can not only be used to shorten Code, but also to import Modules. This also works with Modules that have Modules inside of them, but you’ll have to make a new Snippet for each Module and change some of the Variables to index the imported Variable instead of whatever the Variable is (If you have any Questions on this feel free to ask!)
NOTE: When using letimport, the key of your Snippet will change from just the Key to "import "…Key . This is to avoid variable Names calling the Snippet on themselves and your Studio crashing.
More Information on Settings
Settings
IMPORTANT: WHEN CHANGING SETTINGS, YOU HAVE TO CHANGE THE ACTIVE SCRIPT EDITOR TO SOMETHING ELSE LIKE ANOTHER SCRIPT OR THE VIEWPORT FOR IT TO UPDATE THEM
Settings are pretty self Explanitory if you ask me, but if you can’t understand them:
[Enabled]: "Enables / Disables all Snippets"
[Space Identifier]: "Enables / Disables Space that you have to write after the Key in the Script Editor"
[Import Keyword]: "Keyword that you type infront of your actual Keyword when using "letimport" "
[$NAME]: "What each Dollar Variable returns"
// This is the only allowed Dollar Syntax code:
[DOLLAR SYNTAX CODE]:
[ActiveScript]: Name, Path
[LocalPlayer]: Name, DisplayName
[CurrentTime]: Day, Month, Year, Hour , Minute
Does this Cost anything?
No, this is completly free.
End Note
I would appreciate any feedback. Note that this is actually my first Plugin that I am publicly releasing on the DevForum, I’d love to know what I could improve on in future Plugins!
If I forgot to mention anything, please tell me!
If you have any Questions, feel free to ask!
And finally,
You can try out the Plugin here!