UntitledGoose Posted December 26, 2020 Share Posted December 26, 2020 (edited) M I N E H U T C O M M U N I T Y F A Q HOW TO USE FUNCTIONS WITH SKRIPT REQUIREMENTS: Skript DIFFICULTY: MEDIUM Introduction Functions are little doodads in Skript that hold snippets of code, and that function can be executed to run that code. Functions also take parameters, and can return values. You’ll learn all about functions here. What you’ll learn General look on functions Parameters Returning Examples General look on functions Functions have 4 components to them: name, parameters, return type, and code. Name is the name of the function, you will see more about this later. Parameters are inputs that the function can take in when executed, the functions can interact with these inputs to make diverse outcomes. Return types are required if you want to return something. It basically says what something should expect a function to return. What the function returns must follow this type. A few examples of types are string, numbers, player, etc. Code is the snippet that the function executes when it is called. This is what a function looks like: function name(parameter_name: parameter_type) :: return_type: ____# code___________________________________________________ Note that after putting the parameter’s name and type in the function’s declaration, you can also tack on a default value. The parameter’s content becomes the default value if that parameter was not filled in when the function was called. It looks like this: _______________________________________________ parameter_name: parameter_type = default value_ _______________________________________________ To call a function in code, you put the name, and then round brackets, and put your parameters inside of the brackets, separated by commas. It looks like this: ___ _______________________ name({_par1}, {_par2}, ...) _ ____ ______________________ Parameters Parameters can be passed when calling a function. These parameters can be anything, as long as it follows the type specified in the function’s declaration. A function can access the value of a parameter in a local variable, with the parameter’s name as the label. This is what it looks like: ________________ {_parametername} ________________ Returning The return keyword can be used to return a value from a function, this can be thought of a conversation between the function and the code, with parameters and returns. Code calls function -> Passes in parameters -> Function does magic with parameters and whatnot -> Returns value -> Code does stuff with new value Note here that even when a return type is defined in the function, the function does not have to return something. It can choose to return nothing. Here is the syntax for returning: ______________ _+ return %objects% _ _______________ + Examples ______________________________________________________________________function hello(name: text) :: text:___________________________________ ____return “Hello, %{_name}%!”________________________________________ ______________________________________________________________________ hello(“Goose”) # Returned value: “Hello, Goose!”______________________ ______________________________________________________________________ function set(name: text, value: object):______________________________ ____set {vars::%{_name}%} to {_value}_________________________________ ______________________________________________________________________ set(“foo”, “bar”)_____________________________________________________ {vars::foo} # Value: “bar”____________________________________________ Require further assistance?: If you need more help on this topic, head over to this section of forums, or join our Discord! Compiled by the Minehut Staff Team Edited December 26, 2020 by TheGoose 1 VIP since January 7th, 2020 Support since September 19th, 2020 Helper since November 3rd, 2020 Moderator since March 8th, 2021 Link to comment Share on other sites More sharing options...
muelr Posted December 26, 2020 Share Posted December 26, 2020 cool tutorial there honkling 1 hey gamer! unless you're Jackson then you're toxic. Senior Moderator since July 21st 2020 - Currently leading the Recruitment and Media Team. Link to comment Share on other sites More sharing options...
notminehut Posted December 26, 2020 Share Posted December 26, 2020 Awesome tutorial, however it doesn't really work with dark theme. Founder - Minehut.xyz The leading Minehut support website. We aim to provide top quality tutorials, provide answers to top questions, and help in any way we can. Our site is community driven, and we will continue to make it better and better. Support | 28/08/20 -13/09/20 Senior Support | 13/09/20 - 19/10/20 Link to comment Share on other sites More sharing options...
UntitledGoose Posted December 27, 2020 Author Share Posted December 27, 2020 6 hours ago, Minehut said: Awesome tutorial, however it doesn't really work with dark theme. I'm using Dark Theme and it looks fine for me? Can you clarify VIP since January 7th, 2020 Support since September 19th, 2020 Helper since November 3rd, 2020 Moderator since March 8th, 2021 Link to comment Share on other sites More sharing options...
notminehut Posted December 27, 2020 Share Posted December 27, 2020 5 hours ago, TheGoose said: I'm using Dark Theme and it looks fine for me? Can you clarify Sorry, meant light theme. In light mode you can't see the code blocks. Founder - Minehut.xyz The leading Minehut support website. We aim to provide top quality tutorials, provide answers to top questions, and help in any way we can. Our site is community driven, and we will continue to make it better and better. Support | 28/08/20 -13/09/20 Senior Support | 13/09/20 - 19/10/20 Link to comment Share on other sites More sharing options...
Cosmoss Posted December 27, 2020 Share Posted December 27, 2020 pretty cool tutorial ⁃ Owner of Shulked ⁃ ⁃ Skript Developer ⁃DEFAULT / 2018[VIP] / 2019 ⁃ DISCORD: Cosmos#2576 ⁃ ⁃ IGN: Stuudium (soon to change) ⁃- *former* ADMIN on Versa Realms - - MODERATOR on EddyEvents - Link to comment Share on other sites More sharing options...
UntitledGoose Posted December 27, 2020 Author Share Posted December 27, 2020 10 hours ago, Minehut said: Sorry, meant light theme. In light mode you can't see the code blocks. Looks fine for me? VIP since January 7th, 2020 Support since September 19th, 2020 Helper since November 3rd, 2020 Moderator since March 8th, 2021 Link to comment Share on other sites More sharing options...
notminehut Posted December 27, 2020 Share Posted December 27, 2020 5 minutes ago, TheGoose said: Looks fine for me? You would call that 'fine'? Half of the code blocks are just black lines, could be made to look nicer. Founder - Minehut.xyz The leading Minehut support website. We aim to provide top quality tutorials, provide answers to top questions, and help in any way we can. Our site is community driven, and we will continue to make it better and better. Support | 28/08/20 -13/09/20 Senior Support | 13/09/20 - 19/10/20 Link to comment Share on other sites More sharing options...
UntitledGoose Posted December 27, 2020 Author Share Posted December 27, 2020 1 minute ago, Minehut said: You would call that 'fine'? Half of the code blocks are just black lines, could be made to look nicer. that was on purpose lol. It looks a lot better on Google Docs but Forums messed it up. there isn't anything I can do about it VIP since January 7th, 2020 Support since September 19th, 2020 Helper since November 3rd, 2020 Moderator since March 8th, 2021 Link to comment Share on other sites More sharing options...
notminehut Posted December 27, 2020 Share Posted December 27, 2020 Just now, TheGoose said: that was on purpose lol. It looks a lot better on Google Docs but Forums messed it up. there isn't anything I can do about it Yeah I know that the formatting is a pain, I was just saying. Founder - Minehut.xyz The leading Minehut support website. We aim to provide top quality tutorials, provide answers to top questions, and help in any way we can. Our site is community driven, and we will continue to make it better and better. Support | 28/08/20 -13/09/20 Senior Support | 13/09/20 - 19/10/20 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now