Migrating from Skript¶
FastScript is not a drop-in replacement: the syntax is similar, but the language is its own. A table for rewriting typical pieces.
Equivalents¶
| Skript | FastScript |
|---|---|
on join: |
on player join: (variants in the event reference) |
command /heal <player>: + trigger: |
command heal(target : text) permission ...: (the body is the handler) |
permission: ... inside a command |
permission <node> in the command header |
send "hi" to player |
message "hi" (to the event player) |
broadcast "..." |
broadcast "..." |
give diamond sword to player |
give "DIAMOND_SWORD" 1 |
heal player / damage player by 4 |
heal 4 / damage 4 (event player) or set-health(p, 20) |
teleport player to ... |
teleport(x, y, z) (event player) |
kill player |
kill |
set {x} to 5 |
$x = 5 (global) / #x = 5 (player) / let x = 5 (local) |
{x} / {x::%player%} |
$x / #x |
if ...: else: |
the same |
loop 10 times: |
loop 10 times: (loop-index instead of loop-number - 1) |
loop ...: over a list |
for x in list: |
while ...: |
the same |
stop / return |
the same (stop takes no value) |
cancel event |
cancel-event |
%player% in text |
concatenation: "Hi " + sender-name() |
player's health |
victim.health / sender() + .health |
function f(p) :: number: |
function f(p) : number: |
if player has permission "..." |
if has-permission(me, "..."): |
Migration traps¶
- Stricter indentation: spaces only (tab = 4), mixed is an error.
- No event text: chat contents, block coordinates are unavailable.
- No delays: there is no replacement for
wait 5 seconds(the scheduler isn't exposed). - Stricter types:
null + 1crashes instead of yielding 1 — initialize counters. is===:is "admin"is equality, not a type/role check.- Pure functions: effects and
$/#in them are compile errors. - Commands go in
plugin.yml: Skript registers them itself; here, by hand. - The
playervariable: don't name locals that — you'll shadow the builtin. join()is for lists: joining two strings uses+.forover a non-list is silent: an empty loop instead of an error.