From a871c9cf0ca8b4f033f645173f84591143e2beba Mon Sep 17 00:00:00 2001 From: Camden-png Date: Mon, 3 Nov 2025 21:40:58 -0800 Subject: [PATCH] Add Skript Language (#6857) * Add Skript grammar * Add Skript samples (GNU General Public License, source: https://github.com/SkriptLang/Skript) --- .gitmodules | 3 + grammars.yml | 2 + lib/linguist/languages.yml | 8 +++ samples/Skript/chest menus.sk | 62 +++++++++++++++++++ samples/Skript/text formatting.sk | 38 ++++++++++++ samples/Skript/variables.sk | 53 ++++++++++++++++ vendor/README.md | 1 + vendor/grammars/skript-grammar | 1 + .../git_submodule/skript-grammar.dep.yml | 31 ++++++++++ 9 files changed, 199 insertions(+) create mode 100644 samples/Skript/chest menus.sk create mode 100644 samples/Skript/text formatting.sk create mode 100644 samples/Skript/variables.sk create mode 160000 vendor/grammars/skript-grammar create mode 100644 vendor/licenses/git_submodule/skript-grammar.dep.yml diff --git a/.gitmodules b/.gitmodules index f2c90a1cad..235ec2c034 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1121,6 +1121,9 @@ [submodule "vendor/grammars/shaders-tmLanguage"] path = vendor/grammars/shaders-tmLanguage url = https://github.com/tgjones/shaders-tmLanguage +[submodule "vendor/grammars/skript-grammar"] + path = vendor/grammars/skript-grammar + url = https://github.com/SkriptLang/skript-grammar.git [submodule "vendor/grammars/slang-vscode-extension"] path = vendor/grammars/slang-vscode-extension url = https://github.com/shader-slang/slang-vscode-extension.git diff --git a/grammars.yml b/grammars.yml index 9da8a9b6a2..4bd496c5f3 100644 --- a/grammars.yml +++ b/grammars.yml @@ -1019,6 +1019,8 @@ vendor/grammars/selinux-policy-languages: vendor/grammars/shaders-tmLanguage: - source.hlsl - source.shaderlab +vendor/grammars/skript-grammar: +- source.skript vendor/grammars/slang-vscode-extension: - source.slang vendor/grammars/slint-tmLanguage: diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 971b8138eb..30cad65a84 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -7182,6 +7182,14 @@ Singularity: - Singularity ace_mode: text language_id: 987024632 +Skript: + type: programming + color: "#FF9800" + extensions: + - ".sk" + tm_scope: source.skript + ace_mode: text + language_id: 754733364 Slang: type: programming color: "#1fbec9" diff --git a/samples/Skript/chest menus.sk b/samples/Skript/chest menus.sk new file mode 100644 index 0000000000..525f7e805a --- /dev/null +++ b/samples/Skript/chest menus.sk @@ -0,0 +1,62 @@ + +# +# An example of opening a chest inventory with an item. +# Players will be able to take the item out. +# + +command /simplechest: + permission: skript.example.chest + trigger: + set {_chest} to a new chest inventory named "Simple Chest" + set slot 0 of {_chest} to apple # Slots are numbered 0, 1, 2... + open {_chest} to player + +# +# An example of listening for click events in a chest inventory. +# This can be used to create fancy button-style interfaces for users. +# + +command /chestmenu: + permission: skript.example.menu + trigger: + set {_menu} to a new chest inventory with 1 row named "Simple Menu" + set slot 4 of {_menu} to stone named "Button" # Slots are numbered 0, 1, 2... + open {_menu} to player + +on inventory click: # Listen for players clicking in an inventory. + name of event-inventory is "Simple Menu" # Make sure it's our menu. + cancel event + if index of event-slot is 4: # The button slot. + send "You clicked the button." + else: + send "You didn't click the button." + +# +# An example of making and filling a fancy inventory with a function. +# This demonstrates another way you can use chest inventories, and a safe way of listening to specific ones. +# + +aliases: + menu items = TNT, lava bucket, string, coal, oak planks + +function make_menu(name: text, rows: number) :: inventory: + set {_gui} to a new chest inventory with {_rows} rows with name {_name} + loop {_rows} * 9 times: # Fill the inventory with random items. + set slot loop-number - 1 of {_gui} to random item out of menu items + return {_gui} + +command /fancymenu: + permission: skript.example.menu + trigger: + set {_menu} to make_menu("hello", 4) + add {_menu} to {my inventories::*} # Prepare to listen to this inventory. + open {_menu} to player + +on inventory click: # Listen for players clicking in any inventory. + if {my inventories::*} contains event-inventory: # Make sure it's our menu. + cancel event + send "You clicked slot %index of event-slot%!" + +on inventory close: # No longer need to listen to this inventory. + {my inventories::*} contains event-inventory + remove event-inventory from {my inventories::*} diff --git a/samples/Skript/text formatting.sk b/samples/Skript/text formatting.sk new file mode 100644 index 0000000000..d3771ccc5f --- /dev/null +++ b/samples/Skript/text formatting.sk @@ -0,0 +1,38 @@ +# +# This example is for colours and formatting in Skript. +# Skript allows the old-style Minecraft codes using `&`, like &0 for black and &l for bold. +# You can also use <> for colours and formats, like `` for red and `` for bold +# +# In Minecraft 1.16, support was added for 6-digit hexadecimal colors to specify custom colors other than the 16 default color codes. +# The tag for these colors looks like this: <#hex code> e.g. `<#123456>` +# + +command /color: + permission: skript.example.color + trigger: + send "&6This message is golden." + send "This message is light red and bold." + send "<#FF0000>This message is red." + +# +# Other formatting options are also available. +# You can create clickable text, which opens a website or execute a command, or even show a tool tip when hovering over the text. +# + +command /forum: + permission: skript.example.link + trigger: + send "To visit the website, [click here]" + +command /copy : + permission: skript.example.copy + trigger: + # Insertion: when the player shift clicks on the message, it will add the text to their text box. + # To use variables and other expressions with these tags, you have to send the text as `formatted`. + send formatted "%arg-1%" + +command /suggest: + permission: skript.example.suggest + trigger: + send "Click here to run the command /say hi" + send "Click here to suggest the command /say hi" diff --git a/samples/Skript/variables.sk b/samples/Skript/variables.sk new file mode 100644 index 0000000000..1cd6aa4ccc --- /dev/null +++ b/samples/Skript/variables.sk @@ -0,0 +1,53 @@ + +# +# This example stores a time-stamp in the global `{timer}` variable. +# This variable is accessible everywhere, and will be saved when the server stops. +# +# The `{_difference}` variable is local and is different for each use of the command. +# + +command /timer: + permission: skript.example.timer + trigger: + if {timer} is set: + send "This command was last run %time since {timer}% ago." + else: + send "This command has never been run." + set {timer} to now + +# +# This example stores two items in a global list variable `{items::%uuid of player%::*}`. +# These items can then be recalled with the example `/outfit` command, which then clears the list. +# + +on join: + set {items::%uuid of player%::helmet} to player's helmet + set {items::%uuid of player%::boots} to player's boots + send "Stored your helmet and boots." + +command /outfit: + executable by: players + permission: skript.example.outfit + trigger: + give player {items::%uuid of player%::*} # gives the contents of the list + clear {items::%uuid of player%::*} # clears this list + send "Gave you the helmet and boots you joined with." + +# +# An example of adding, looping and removing the contents of a list variable. +# This list variable is local, and so will not be kept between uses of the command. +# + +command /shoppinglist: + permission: skript.example.list + trigger: + add "bacon" to {_shopping list::*} + add "eggs" to {_shopping list::*} + add "oats" and "sugar" to {_shopping list::*} + send "You have %size of {_shopping list::*}% things in your shopping list:" + loop {_shopping list::*}: + send "%loop-index%. %loop-value%" + send "You bought some %{_shopping list::1}%!" + remove "bacon" from {_shopping list::*} + send "Removing bacon from your list." + send "You now have %size of {_shopping list::*}% things in your shopping list." diff --git a/vendor/README.md b/vendor/README.md index a0ceb6b4e5..c86ee6d62e 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -570,6 +570,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **Sieve:** [Alhadis/language-etc](https://github.com/Alhadis/language-etc) - **Simple File Verification:** [Alhadis/language-etc](https://github.com/Alhadis/language-etc) - **Singularity:** [onnovalkering/vscode-singularity](https://github.com/onnovalkering/vscode-singularity) +- **Skript:** [SkriptLang/skript-grammar](https://github.com/SkriptLang/skript-grammar) - **Slang:** [shader-slang/slang-vscode-extension](https://github.com/shader-slang/slang-vscode-extension) - **Slash:** [slash-lang/Slash.tmbundle](https://github.com/slash-lang/Slash.tmbundle) - **Slice:** [zeroc-ice/vscode-slice](https://github.com/zeroc-ice/vscode-slice) diff --git a/vendor/grammars/skript-grammar b/vendor/grammars/skript-grammar new file mode 160000 index 0000000000..2cef6b9a4f --- /dev/null +++ b/vendor/grammars/skript-grammar @@ -0,0 +1 @@ +Subproject commit 2cef6b9a4f8200e34134aed0da0ab56854b4582c diff --git a/vendor/licenses/git_submodule/skript-grammar.dep.yml b/vendor/licenses/git_submodule/skript-grammar.dep.yml new file mode 100644 index 0000000000..ab7704edd1 --- /dev/null +++ b/vendor/licenses/git_submodule/skript-grammar.dep.yml @@ -0,0 +1,31 @@ +--- +name: skript-grammar +version: 2cef6b9a4f8200e34134aed0da0ab56854b4582c +type: git_submodule +homepage: https://github.com/SkriptLang/skript-grammar.git +license: mit +licenses: +- sources: LICENSE + text: | + MIT License + + Copyright (c) 2022 SkriptLang + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +notices: []