Effects
Line instructions.
Effects are the bread and butter of Skript code. Every code-line is an effect. Effects do not return or give back any kind of value, and are entirely self-contained on a single line.
Effects are like verbs or actions - instructions to do something.
- 1.Effects must begin with an absolute phase, usually some sort of verb or action (
run...
,set...
,delete...
). - 2.Effects may never begin with an input.
Most effects will be compiled to simple bytecode operations (such as invoke calls.)
Compilation should generally be done on the second
compile
pass when all expression data has been loaded onto the stack. States may be altered on the first preCompile
pass where necessary.Be careful not to leave any garbage on the stack after the effect passes - all effects should leave the stack as it was to maintain symmetry for programmatic jumps.
An example is given below.
Skript Source
Instruction Assembly
Bytecode Compilation
run my_func(1, 2, {foo})
return true
push1
push 2
loadObject foo
invokeStatic "my_func"
pop // pops the result of the invocation to empty stack
push1
returnSmall
iconst_1
bipush 2
aload 0
invokestatic 'my_func'
pop
iconst_1
ireturn
Last modified 1yr ago