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

Fix Example Scripts #7430

Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 8 additions & 3 deletions src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,14 @@ private void runTests() {
TestingLogHandler errorCounter = new TestingLogHandler(Level.SEVERE);
try {
errorCounter.start();
File testDir = TestMode.TEST_DIR.toFile();
assert testDir != null;
ScriptLoader.loadScripts(testDir, errorCounter);

// load example scripts (cleanup after)
ScriptLoader.loadScripts(new File(getScriptsFolder(), "-examples" + File.separator), errorCounter);
// unload these as to not interfere with the tests
ScriptLoader.unloadScripts(ScriptLoader.getLoadedScripts());

// load test directory scripts
ScriptLoader.loadScripts(TestMode.TEST_DIR.toFile(), errorCounter);
} finally {
errorCounter.stop();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/scripts/-examples/commands.sk
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ command /home <text> [<text>]:

aliases:
# Creates an alias `blacklisted` for this list of items.
blacklisted = TNT, bedrock, obsidian, mob spawner, lava, lava bucket
blacklisted = TNT, bedrock, obsidian, spawner, lava, lava bucket

command /item <items>:
description: Give yourself some items.
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/scripts/-examples/functions.sk
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ command /appleexample:
# Please note that self-calling functions can loop infinitely, so use with caution.
#

function destroyOre(source: block) :: blocks:
function destroyGold(source: block) :: blocks:
add {_source} to {_found::*}
break {_source} naturally using an iron pickaxe
loop blocks in radius 1 of {_source}:
loop-block is any ore
loop-block is a gold ore block
break loop-block naturally using an iron pickaxe
if {_found::*} does not contain loop-block:
add destroyOre(loop-block) to {_found::*}
add destroyGold(loop-block) to {_found::*}
return {_found::*}

command /oreexample:
permission: skript.example.ore
trigger:
if player's target block is any ore:
if the player's target block is a gold ore block:
send "Destroying all connected ore."
set {_found::*} to destroyOre(player's target block)
set {_found::*} to destroyGold(player's target block)
send "Destroyed %size of {_found::*}% connected ores!"
else:
send "<red>You must be looking at an ore block!"
7 changes: 3 additions & 4 deletions src/main/resources/scripts/-examples/loops.sk
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ command /anotherloopexample:

loop blocks in radius 2 of player:
loop-block is a chest
loop items of types ore and log: # Loop-block comes from the first loop, loop-item from the second.
inventory of loop-block contains loop-item
remove loop-item from the inventory of loop-block
send "Destroyed a %loop-item%!"
loop items in loop-block: # Loop-block comes from the first loop, loop-item from the second.
loop-item is a dirt block # Matches any dirt block item
send "%loop-block% contains %loop-item%!"
exit loop # Exits the item loop.
4 changes: 2 additions & 2 deletions src/main/resources/scripts/-examples/options and meta.sk
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ on join:
#

variables:
score::%player% = 100
some variable = "Hello"
{score::%player%} = 100
{some variable} = "Hello"

command /variabletest:
permission: skript.example.variables
Expand Down
Loading