1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to read syntax

Jun 1, 2020
How to read syntax
  • How to read syntax

    in this tutorial, I will show how to read syntaxes

    how to use the + sign
    %number% + %number%
    a number that is the sum of 2 numbers

    will return a number 3

    How expressions work
    you have +
    its %number%+%number% and it returns a number

    you have "name of"
    it returns a string
    broadcast name of player

    you have "uuid of %player/entity%"
    it returns a string

    you have "y coordinate of %object%"
    it returns a number
    > y coordinate of player + y coordinate of player
    = 124

    its that simple

    Full explanation

    in the documentations, you will see things like these
    • grow [of (%tree type%|%item type%)]
    • (food|hunger) (level|met(er|re)|bar) chang(e|ing)
    these are hard to understand so I will break it down to 3 main components
    square brackets []
    parenthesis ()

    they each mean

    text - required text
    () - required of 1 of the text inside(split by “|”)
    [] - optional text

    if the syntax is
    on chat
    then only “on chat” will be recognized by the parser

    if the syntax is
    on book (edit|change|write)
    - on book edit
    - on book change
    - on book write
    will be recognized by the parser

    if the syntax is
    on bucket fill[ing]
    then both
    - on bucket fill
    - on bucket filling
    will be recognized by the parser

    text are made up of 2 categories
    - plain text (plain text)
    - % % (types)

    plain text will never change
    however, you need to type out the types your own

    • [player] ((eat|drink)[ing]|consum(e|ing)) [[of] %item type%]
    %item types% is an item type
    one of the types that Skript has
    and for the names of an object(in this case, an item), check out the github page.(or just type the thing you think it is. works 90% of the time. you can expand the item types you can use by using an aliases file)
    so if i were to use a steak i need to type either of

    - on eat of steak
    - on player consuming steak
    - on player eating steak
    (you might ask, how about “on drink of steak”? it might be possible, or it might be not. my question is, why would you do that? Skript is an english based language. on drink of steak defeats that purpose. so don’t do unexpectable things. but still curious? try it yourself)

    %type% is a required field(is not optional)

    so lets try and analyze the syntaxes I listed on the top of the page

    grow [of (%tree type%|%item type%)]

    “grow” is a required text
    “[” the next is optional
    “of ” is a required text
    “(“ means it should pass one of the text
    “%tree type%” a required tree type
    “|” next option
    “%item type%” a required item typr
    “)” parenthesis close
    “]” option close

    so valid syntaxes would look like these
    on grow
    on grow of oak tree
    on grow of carrot

    invalid syntaxes will look like these
    on grow oak tree
    on oak tree
    on grow carrot
    on of carrot

    lets try this
    (food|hunger) (level|met(er|re)|bar) chang(e|ing)

    need either “food” or “hunger”
    need either “level”, “met(need either er or re)” or bar
    need “chang”
    need “e” or “ing”

    valid syntaxes
    on food bar change
    on hunger metre changing
    on food level change

    invalid syntaxes
    on foodbar change
    on hunger change
    on food changing

    %players% means to put a player in there.
    in most cases it will work with player or event-player

    give 1 dirt to player

    however, if you want a specific player, use a variable that is the player or
    “<playername>” parsed as offline player

    there you go, now you can read syntaxes!

    Important notes:
    - a(|b) and a are the same
    a, ab || a, ab
    but a(|b|c) and a[c] are different
    a, ab,ac || a, ab, ac, abc
    this might cause parsing problems in the future
    - because it is both syntaxes are valid doesn’t mean they are the same
    ex) on [block] (break[ing]|min(e|ing)) [[of] %itemtype%]
    can have 2 different meanings
    1. on [block] break[ing] [[of] %itemtype%]
    2. on [block] min(e|ing) [[of] %itemtype%]
    reas Skript docs if you want to find out
    - using an optional text means you need to use everything in the text
    ex) [oh ]hi[ mark(rober|jukerberg)]
    oh hi mark - invalid syntax
    - the document syntaxes are not 100% accurate. they might miss a space or add 1 more space.
    - sometimes the syntaxes contain plural expressions. be careful about the meaning of those since it might be different.
    - sometimes, addons will include their addon names as an optional text.
    ex) [bungeecord ]
    if you use 2 similar addons it is recommended to add the optional text inorder to avoid conflicts/confusion

    edit 19/11/07
    changed documents to documentations, fixed some formats
    edit 20/2/25
    added titles and Formatting.