scripting

For the developer API, click here
Scripting is used to create custom placeholders (i.e. the stuff in the "script" folder).
There are two types of scripts:
- Placeholders
- Replacers
Placeholders can take arguments and require {curly brackets}
Replacers on the other hand do not take arguments and thus do not require curly brackets.
To make something a replacer add "simple: true" to the script ".yml" file.

simple: true
script:
  - Some script goes here


Scripts can be found as a ".yml" file inside the "scripts" folder for IndividualMessages

script:
  - "if {itemid} = 10"
  - "return AAH LAVA!"
  - "else"
  - "return Hi"

Additional Placeholders

In custom placeholders, you can now have modifiers e.g. putting {example:A:B:C} on a sign
These modifiers will replace the following placeholders:
- {arg1}
- {arg2}
- etc.
For example:
- {arg1} will return A for the custom placeholder {example:A:B:C}

Math

to perform math, the {js:JAVASCRIPT} placeholder will come in handy. e.g.

{js:({money}+{age}-2)*3}

Logical keywords

These control the flow of logic in your script

if

 - Accepts + - / *
 - Brackets can be used: if (1+2)*3 = 9
 - Placeholders are evaluated
Relations:
 != (does not equal)
>= (greater than or equal to)
<= (less than or equal to)
=~ (equals string, case insensitive)
= (equals, case sensitive)
> (greater than, or longer than)
< (less than, or shorter than)
&& (and statement)
|| (or statement)

else

- Will trigger when an if statement returns false
e.g.

if {player} = bob
hi notch
else
you aren't bob :(

endif

- Indicates what is inside a if/else statement

if true
\it's true you know
endif
\I am no longer in the if statement

for

Can loop through a list, or just for a set amount of time
e.g. "for 10;do me test"
LISTS
- for i:1,2,3,4,5,6;do me {i}
- Some placeholders are lists e.g. {online}
- You can leave the "i" part blank if you don't want to set a temporary variable

endloop

- Indicates what is inside the for loop (and what is outside - after the endloop)
e.g.

for 10
\spam
you are spamming
endloop
\I am no longer in the for loop and thus not spamming

Functional keywords

These things do stuff :p</p>

var

var myfirstvar 5+6
{myfirstvar}
Will print 11 to your chat ^

gvar

Basically the same as var, but it doesn't disappear when you are done.

do

Has the user execute a command

do spawn

^ will have you teleport to spawn

\

Will have you send a chat message

\This is a chat message

setuser

Will change the user to another online player.

setuser Notch
{player}

Will print out Notch's name rather than yours

return

Will return a value - e.g. "return true"


Comments

Posts Quoted:
Reply
Clear All Quotes