UntitledGoose Posted December 17, 2020 Share Posted December 17, 2020 Introduction Variables are a form of data storage in Skript that allows you to store strings, integers, players, multiple players, etc. You will be learning how to use every type of variable in Skript, aswell as what each one is and does. What you’ll learn about Variable commonplace How to set variables Single value variables (‘Normal’ variables) List variables Local variables Metadata tags Variable commonplace There are 2 key components to any variable: index and value. The index is like the name of your variable, if I had a variable named {epic}, the index would be ‘epic’. The value is what your variable stores, if I had a variable that held the string “minehut.com”, the value would be “minehut.com”. How to set variables You can set variables with the effect Change: Set/Add/Remove/Delete/Reset. The syntax for this effect looks like: (add|give) %objects% to %objects% _________ increase %objects% by %objects%____________ give %objects% %objects%___________________ set %objects% to %objects%_________________ remove (all|every) %objects% from %objects% (remove|subtract) %objects% from %objects%_ reduce %objects% by %objects% _____________ (delete|clear) %objects%___________________ reset %objects%____________________________ So if I were to set a variable with this, it’d look like: set {woohoo} to “Join minehut.com for quality servers today!” Single value variables Because I’m lazy, I’ll be referring to single value variables as normal variables so it’s easier for me to type and explain. Normal variables can be thought of as envelopes, they can hold anything, but only 1 one of that something. Normal variables usually look like this: {index}, {my.awesome.variable}, etc. These variables can be set or retrieved anywhere within your script. set {my.variable} to “a” # Success! {my.variable} is now set to “a”______________ set {my.variable} to “a” and “b” # {my.variable} can only be set to one object, not more List variables List variables are like cardboard boxes, they can hold multiple items, compared to normal variables, which can only hold one thing. In order for a list variable to hold multiple values, the index MUST end in ::*, and have nothing else after it (except for the closing }) List variables look like this: {my::variable::*} {my.variable::*} {hello_there::*} set {my.variable::*} to “a” and “b” # Success! {my.variable::*} is now set to “a” and “b” set {my::variable} to “a” and “b” # {my::variable} can only be set to one object, not more_ Local variables Local variables are temporary variables. They can be either list variables or normal variables, but they will be deleted at the end of a trigger (the end of a command or event), and cannot be accessed by external triggers. You can initiate a local variable by slapping a _ right before the index. This will look like: {_variable} {_my.list::*} {_hey::*} {_} Metadata tags Metadata tags are [also temporary] variables, but they’re attached to an entity or block, and are flushed when the server restarts. Note that metadata tags can only hold one value. This is the syntax for metadata tags: metadata [(value|tag)[s]] %strings% of %metadataholders% %metadataholders%'[s] metadata [(value|tag)[s]] %string% Note: %metadataholders% = entity or block Examples of metadata tags: set metadata tag “super cool” of player to true delete metadata tag “epic” of target block____. Conclusion There you go! Now you’re a pro on everything Skript variables. Hope this tutorial helped clear up some fog, and be sure to comment on this post if I missed everything. 5 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...
AgentGamerPro Posted December 18, 2020 Share Posted December 18, 2020 nice tutorial +1 like 1 Lifestealed | Minecraft Servers OG [VIP] 12/26/20 - 10/27/2021 OG [PRO] 12/27/21 - 11/18/2022 OG [LEGEND] 11/18/2022 - 3/14/2023 [DEFAULT] 3/14/2023 - Present Link to comment Share on other sites More sharing options...
Cosmoss Posted December 22, 2020 Share Posted December 22, 2020 Very good tutorial for beginners. Explains everything fully detailed, but not confusingly. ⁃ 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...
SkripterMan Posted January 2, 2021 Share Posted January 2, 2021 Lol, I never knew you could "reduce" SkripterManJoined Minehut on 4/21/16 Owner of CareSMP.minehut.ggVIP - 6/21/17LEGEND - 18/12/20MARKET MAKER - 5/6/21Discord: SkripterMan#0001 Link to comment Share on other sites More sharing options...
Madlirex Posted September 25, 2021 Share Posted September 25, 2021 How to make private variable like your money or balance? Link to comment Share on other sites More sharing options...
ram3n_nabi Posted September 25, 2021 Share Posted September 25, 2021 12 minutes ago, Madlirex said: How to make private variable like your money or balance? Hi Madlirex! I will now lock this post. Please do not reply to posts that have not been responded to in over a month. You can always create your own post and be sure to post in under the right category. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts