Graal Reborn GS1 Scripting Guide BETA VERSION 0.2
first comments:
this guide is explained on basic knowledge of mine, i will explain the main commands
but only the features i know will be explained, if you have knowledge of the ones i dont, please (if your staff) edit this post. or
if your no staff member private Message me
also i explain some easy commands, wich is a must for LATs and beginning NATs
also try experimenting! its okay if you make mistakes, keep trying, and if you cant figure it out,
there are always people on the forum wich will help you out
post any questions in the forum of Development > NPCs
also…
this guide is made for anyone who has problems or who wants to learn scripting
im trying to do my best on this guide so please no flaming!
also a few notes:
X = horizontal line
Y = vertical line
a timeout max limit is 0.05, after that it freezes. so dont use 0.01 to 0.04 because those wont work.
you can see the X/Y coordinates in editor when you put your mouse anywhere
its in the leftright corner of the screen.
Explanation how to get into editor, and where you can put/write scripts.
The Guide PT. 0 ~ few explanation of how to start scripting and basic information
the number one priority is that you can do a little of math, and you got a good commands.rtf file
i uploaded mine in this post, but the one ill upload is the one downloaded of this forums.
first i want to explain how to start a script
first a few note’s:
- a command mostly starts with a if, but can also start with: else,elseif, for,with, or while
~ else { //is a command that triggers, if none of the script is correct.
for example:
if (playertouchsme) {
if (carriesbush) {
setplayerprop #c, Yay you win; }
else {
setplayerprop #c, wtf you have no bush!;
}
}
~ elseif //a command that is used to give functions more then 1 option, and can give restrictions to the else command.
for example: [b]
if (playertouchsme) {
if (isleader) {
setplayerprop #c, you are the first one to enter this level!;
}
elseif (!playertouchsme&&isleader) {
message touch me!;
}
}
~ for //i got no decent explenation for this
~ with //i got no decent explenation for this
~ while //this is a special one, it will response when a flag stays on true
for example:
if (playertouchsme) {
while (carriesbush) {
hide;
sleep 1;
show;
}
}
//while the player carries a bush and is touching the NPC, the NPC will hide sleep for 1 second and then show
- always when making a trigger, put a open “(” icon and close it with the “)” icon
- after you made the trigger for example: if (playertouchsme) open it with brackets
brackets are these “{” “}” icons, always open AND close them or the script will fail.
so if im right you now have if (playertouchsme) { }
and between the brackets comes the script - also know that the // in a line of script wont be readed.
// is used for comments in scripts.
you can also if you have allot of lines
put something like this
/*
made by: example
for: example
playerworld: example
copyrighted by: example
/
this is just a example but to show you that you can post a big line of words without letting the script read it
you can insert personal info and stuff anything you like, but do it with “//” or with " / " " */ " if its not the a part of the script.
this is a sample of a script i will explain every line:
NOTE: if you want to see how it works, you can just copy it in your offline editor
(see the picture tutorial for details, its in the post.)
5. you can put a trigger inside of a trigger.
but there are 2 ways to do that:
way 1: if (playertouchsme&&carriesbush) { this will put them together in one line, but only works when the NPC is touched
and is carrying a bush.
way2:
if (playertouchsme) {
if (carriesbush) {
}
elseif (!carriesbush) {
}
}
this way, you can do a multiple command, you leave playertouchsme open, so the playertouchsme rule counts always.
but then you can put carriesbush inside, so the script will respond when the player carries a bush.
and then i putted a extra trigger with elseif(!carriesbush) this means if the player DOES NOT carry a bush.
and then i close with 2 brackets, because first i close of the (!carriesbush) but if (playertouchsme) { was still open!
so i needed to close that one off! i hope you understand that.
[php]
if (playertouchsme) { //if is the start, so if the NPC is touched
toweapons Explosion Test; //this will add the weapon Explosion Test to the weapons;
} // bracket end
if (weaponfired) { //if is the start, so if the weapon is fired
if (!extriggerd) { //this is a set/unset option to see if the weapon is already fired. in this case its not.
setplayerprop #c, Explosions On!; //will set the players chat to explosions on!
set extriggerd; //now it will set that the weapon is fired
timeout = 0.05; //here starts a loop
} //bracket end
elseif (extriggerd) { //here is what to do if the weapon is currently fired, when it was already triggerd
setplayerprop #c, Explosions Off!; //the playerchat will go back to explosions off;
unset extriggerd; //now the weapon is put off;
} //bracket end
} //another bracket end because i have a trigger inside a trigger, wich needs to be closed by 2 brackets
if (timeout&&extriggerd) { //this is a double command, the timeout has to be triggerd, but the weapon has to be triggerd too!
this.iyrand = (random(-5,5)); //this puts a variable, in a random ammount between -5 and 5 so this can be anything.
this.ixrand = (random(-5,5)); //same as above
this.iplx = playerx; //puts the variable this.iplx to the playerx (the player’s X coordinates)
this.iply = playery; //puts the variable this.iply to the playery (the player’s Y coordinates)
putexplosion 1,this.iplx+this.ixrand, this.iply+this.iyrand; //puts an explosion with the power of one, at the playery + the random number
//so actuelly it can put it anywhere between the playerx -5 and 5. and the playery -5 and 5. see it in offline editor to get what im saying.
timeout = 0.05;
}
[/php]
if you have any questions please PM me, ill be happy to explain
and i hope you understand for so far.
now i want to talk about the symbols.
symbols are icons that can put different triggers together.
i put them in a list below, but theyre also in the commands.rtf
ill add a sample after it ~
[php]
! not ~ if (!playertouchsme) { //responses when the player doesnt touch the NPC
&& and ~ if (playertouchsme && carriesbush) { //response when the player touches the NPC WITH a bush
|| or ~ if (playertouchsme || playerenters) { //response if the player touches the NPC or if the player enters the level
== equals ~ if (this.variable == server.variable) { //response when this.variable is equal to server.variable
!= does not equal ~ if (this.variable != server.variable) { //response when this.variable and server.variable are not the same
- addition ~ if (playertouchsme) { this.variable + this.variable2 //counts these 2 variables up
- substraction ~ if (playertouchsme) { this.variable - this.variable2 //this.variable minus this.variable2
- multiplication ~ if (playertouchsme) {this.variable * this.variable2 //multiplies this.variable times this.variable2
/ division ~ if (playertouchsme) { this.variable / this.variable2 //devides this.variable trough this.variable2;
% mod; a%b = a - int(a/b)*b; ~ { this.variable //mod takes (a) and devides it by B then does it times B.
^ power; a^0.5 = squareroot(a) ~ //power is taking the squareroot of (a).
in tests if an array/range contains a variable (e.g. 2 in {1,2,3}; x,y in |0,64|) ~ if (playery in |0,30|) { //response when the playery is between 0 and 30
= assigment ~ if (playertouchsme) { this.variable = 3; } //sets this.variable to 3;
a += b a = a+b ~ if (playertouchsme) { this.variable += 3; //adds 3 to this.variable
a -= b a = a-b ~ if (playertouchsme) { this.variable -= 3; //takes 3 from this.variable
a = b a = ab ~ if (playertouchsme) { this.variable *= 2; //multiplys this.variable times 2
a ++ a = a+1 ~ if (playertouchsme) { this.variable++ //+1 to this.variable
a – a = a-1 ~ if (playertouchsme) { this.variable-- //-1 to this.variable
this. variables starting with this. is only for this NPC
[/php]
The Guide PT. I
the first i want to explain are the basic physic triggers wich happen to trigger up a script when you do something
for example if you enter a level wich is named by
if (playerenters) { //dostuff }
try to learn the scripting language, most words in english are pushed together as one
so for example if you take playerenters, it actually says if the player enters the level then do stuff
these are all basic commands for the people who know the basic,
but newbies will make allot of mistakes if they dont understand what they are doing.
these are all the physic triggers in graal (also known as build in flags):
[php]
playerenters triggers when the player enters the current level
playertouchsme triggers when the player touch this NPC
playertouchsother triggers when the player touches any other NPC in the current room
playerlaysitem triggers when the player drops any item on the ground.
playerchats triggers when the player chats something
NOTE: uploaded a new commands.rtf