Wow, complicated but getting it.
Printable View
Wow, complicated but getting it.
Can we start easy?
Oh yes poorface, I think we stopped at loops...
They're pretty easy to learn, I guess I can include them in my next tutorial, but here's an overview.
A loop can be either infinite, or specific, and the only way to stop a loop is to put 'break;' or 'return;' if it is infinite.
Lot's of ways to have loops on Graal.
I'm going to teach you the for(); loop today. Let me show you how it works correctly.
what this will echo is:PHP Code:
function onCreated() {
for (i = 0; i < 6; i++) {
echo(i);
}
}
So how does this work? You have three arguments to have in a for() loop.Quote:
0
1
2
3
4
5
You can replace all of the above this way:PHP Code:
for (i = 0; // This will be read once at the beginning
i < 5; // this will be checked everytime
i += 1 // or whatever you want to change every time the loop starts (WARNING, this does not take a semi colomn
) {
echo(i);
}
PHP Code:
function onCreated() {
i = 0;
if (i < 5) break;
echo(i);
i += 1; // or i++; whatever
if (i < 5) break;
echo(i);
i +=1;
if (i < 5) break;
echo(i);
i += 1;
if (i < 5) break;
echo(i);
i += 1;
if (i < 5) break;
echo(i);
i += 1;
// etc
}
Wow. So it is like counting, or continous things it says?
well, I understand now what "break;" does, I don't understand what not make them like a line like so:
PHP Code:
function onActionServerSide(pl, this.lucky) {
for (pl : players) {
if (pl.level == "era_lucky-grab.nw") {
pl.setlevel2("era_luck-grab.nw", 30, 30);
triggerclient("gui", name, pl)
}
if (this.lucky == true)
pl.setlevel2("era_lucky-grab.nw", 30, 40);
}
pl.setlevel2("era_start.nw", 30, 30);
}
}
function onCreated() {
for (this.num = 0; this.num < 5; this.num--) {
}
}
//#CLIENTSIDE
function onPlayerChats() {
this.staff = "Events Team";
if (player.guild in this.staff && player.chat == "down") {
triggerserver("gui", name, NULL);
}
}
function onActionClientSide(pl) {
this.lucky = "Yay I'm luck!";
if (player.guild in this.staff && player.chat == ":timer") {
player.chat = "kicking in: " @ this.num;
if (player.this.staff.chat == "0")
sleep(3);
if (pl.level == "era_lucky-grab.nw" && player.chat == "Yay I'm lucky!")
triggerserver("gui", name, pl, this.lucky)
}
if (player.chat != this.lucky) {
triggerserver("gui", name, NULL)
}
}
}
}
Serverside and clientside aren't even operated on the same things.
Clientside is compiled then sent off to be executed on the client whilst serverside is compiled then sent off to be executed by the server.
Therefore, this. variables will go through the whole script, but only on the size it's instanced on. So, a this.timer = 5; declaration on serverside will not set this.timer = 5; on clientside and vice versa.