Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language Skript #5726

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -1146,3 +1146,6 @@
[submodule "vendor/grammars/zephir-sublime"]
path = vendor/grammars/zephir-sublime
url = https://github.com/phalcon/zephir-sublime
[submodule "vendor/grammars/Language-Skript"]
path = vendor/grammars/Language-Skript
url = https://github.com/Skript-Atom/Language-Skript.git
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source 'https://rubygems.org'
gemspec :name => "github-linguist"


blockarchitech marked this conversation as resolved.
Show resolved Hide resolved
group :debug do
gem 'byebug' if RUBY_VERSION >= '2.2'
end
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ vendor/grammars/Isabelle.tmbundle:
- source.isabelle.theory
vendor/grammars/JSyntax:
- source.j
vendor/grammars/Language-Skript:
- source.skript
vendor/grammars/LiveScript.tmbundle:
- source.livescript
vendor/grammars/MATLAB-Language-grammar:
Expand Down
8 changes: 8 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7218,3 +7218,11 @@ xBase:
tm_scope: source.harbour
ace_mode: text
language_id: 421
Skript:
type: programming
color:
aliases:
- sk
extensions:
- ".sk"
language_id: 754733364
40 changes: 40 additions & 0 deletions samples/Skript/sample1.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Github Lingust Sample File - 1
# This will go over storing data, using existing player data, and working with variables.
options:
myColor: &a&l
myPrefix: {@myColor}GitHub:


# This example ueses events to find out when a user broke a block, and send a chat message with the prefix myPrefix from the options above.
on break:
send '{@myPrefix} You broke a block!' to player
# We can also add this to a variable.
add block to {blocks::*}

# Same example, but when a player places a block.
on place:
send '{@myPrefix} You broke a block!' to player

# You can also use placeholders from PAPI, for stats commands, like this.

on command /myStats:
trigger:
send "You are in biome %player_biome%"
send "Your ping is %player_ping%"
# Many, MANY more placeholders are in the PAPI documentation. I used the 'Player' extension (https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#player)
# To create this example.

# You can also store PAPI placeholders in variables, so it's easy to change one line

every 5 seconds:
add "%player_ping%" to {storedping::*}

on command /storedplayerping:
trigger:
send "%{storedping::*}%"
# Note, this will send ALL player pings, so you might want to wipe the variable every 4 seconds to get rid of the old ping. So,

# This is what you should do.

every 4 seconds:
clear {storedping::*}
72 changes: 72 additions & 0 deletions samples/Skript/sample2.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# GitHub Lingust Sample File - 2
# This will go over contacting the outside world, like databases, and using functions.
# We'll also work with Skript Addons, which expand the usage of skript.

# Like almost every skript, it probably needs an options area.
# This sample requires the addon 'Skellet'.

options:
# We'll only declare thre prefix, because usernames and passwords can't be stored here.
prefix: &3&lGitHub

# On the Skript load, connect to the database.
on load:
# Declare the user and password.
set {_user} to "test"
set {_password} to "test123!"
# Declare the Database name,
set {_database} to "mydatabase"
set {_ip} to "mydatabasehost.com"
set {_port} to 3306
# Wait one tick before we connect.
wait 1 tick
# Connecr to the database.
set {-database::connection} to the database "mysql://%{_ip}%:%{_port}%/%{_database}%?user=%{_user}%&password=%{_password}%&useSSL=false"
# Wait a tick before any action is taken
wait 1 tick
# Create the 'players' table if it doesn't exist. Part of this is NOT Skript, but instead SQL, so I won't go in depth here.
execute "CREATE TABLE IF NOT EXISTS players ( uuid VARCHAR(150) NOT NULL, username VARCHAR(150) NOT NULL" in {-database::connection}
# Throw our error function if something goes wrong.
db_error()

# Our error function, which tells us if there's an error.
function db_error():
# If there was an error
if last sql error is set:
# Send a chat message saying there was an error, but only if the player has operator permissions
send "{@prefix} &4Error occured with database connection!" to all players where [input is op]
# Send the error to all playerd with operator permissions.
send "&c%last sql error%" to all players where [input is op]

# Now, we need some way to update the database. Let's do that here.

# We'll declare a new function named db_updateData
function db_updateData(p: offline player):
#Store player's UUID in the database
execute "SELECT username FROM players WHERE uuid = ""%{_p}'s UUID%""" in {-database::connection} and store in {_exists}
# Set username and UUID to a new variable.
set {_username} to "%{_p}%"
set {_uuid} to {_p}'s UUID
# If that player is online,
if {_p} is online:
# Set the online variable to TRUE
set {_online} to true
else:
# If not, make it false.
set {_online} to false
# If the player is new, and doesn't already exist in the database, add them to it.
if {_exists} is not set:
execute "INSERT INTO players (username, uuid, online) VALUES (%{_username}%, %{_uuid}%, %{_online}%;" in {-database::connection}
else:
# Or, just update their information.
execute "UPDATE players SET username = %{_username}%, online = %{_online}%, WHERE uuid = %{_uuid}%;" in {-database::connection}
# This is the function from earlier. If there's an error, throw it.
db_error()

# More events! This time we'll use our function that we just made when the player joins and quits.
on join:
$ thread
db_updateData(player)
on quit:
$ thread
db_updateData(player)
1 change: 1 addition & 0 deletions vendor/grammars/Language-Skript
Submodule Language-Skript added at 2db7ee