Please Explain This Script

Lynux
Joined 24/08/2018
Posts 591
09:54 PM 11/11/2018
s = define("onPlayerTouch");
s.script = '
var brick,client;
brick = arg[0];
client = arg[1];
if(brick.Name == "Lava") {
playerKill(client);
}
';

Thanks!

List of things to explain right away:

1. What does brick = arg[0];
client = arg[1]; mean?

2. What does s.script mean and do?

3. Why do you place "define" before ("onPlayerTouch")


[TylFT] Tylorfoot
Joined 03/06/2017
Posts 6,581
07:43 AM 12/11/2018
im not good at explaining this but i will try:

1. arg[] refers to the arguments in a function. in a user function, for example:
s = define("epic gamer")
s.script = '
messageAll(arg[0])
';

execute("epic gamer","no u")
"epic gamer" is the function to execute, and "no u" is the 0th argument. so running this script would show the message: "no u" in chat.
in predefined functions, it can have a variety of effects. for this one, arg[0] is the brick which is being touched, and arg[1] is the player who is touching the brick.

2. s.script defines the script to execute when the function is ran. pretty simple.

3. this defines the function itself. certain functions are predefined and will run when a certain action happens (example: onPlayerTouch runs when a player touches a brick, onGameConnection runs when a player joins, etc.)

i probably did a horrible job explaining all this


Lynux
Joined 24/08/2018
Posts 591
11:01 PM 12/11/2018
Thanks!

1