PDA

View Full Version : noobie scripting guide!


excaliber7388
03-31-2006, 01:47 AM
http://wiki.graal.net/index.php/Worlds/Dark_Rival#Excaliber.27s_Scripting_Guide
When I ws trying to learn how to script, guides helped more if they had many examples, and a lot of explanations. Since none really had this, I learned from looking at scripts, and beraking them down. This guide makes it easier to start learning scripting. It's no where near done, but as of now it's quite long, and has many examples. Graal needs more scripters, so I hope this is taken seriously. I made this originally so that my staff could know some scripting, but anyone could learn from it. So enjoy!

Skyld
03-31-2006, 10:19 AM
A few things need to be touched up, but overall, a good try.
triggeraction (x,y,"params[0]","params[1]");
Variable names should not be inside "quotes".
addweapon Fire Ball;
setshape 1,32,32;
if (playerrupees>=100)
addweapon("Fire Ball");
setshape(1, 32, 32);
if (player.rupees >= 100)
function onPlayertouchesme()
function onPlayerTouchsMe()
... spelling error.
triggeraction (x,y,"Touched","Touched");
... will produce
function onActionTouched()
... not
function onTouched()
function onCreated()
{
setshape 1,32,32;
//setshape is needed for all level NPCs triggeractions
//this setsit to a square of tiles 32 pix by 32 pix
}
function onActiontime()
{
server.time+=1;
//no need for incredible accuracy
}
//#CLIENTSIDE
function onCreated()
{
settimer(1);
}
function onTimeout()
{
triggeraction(x,y,"time","time");
settimer(1);
}
A better version:
function onCreated()
{
onTimeout();
}

function onTimeout()
{
server.time ++;
setTimer(1);
}
Although, note that a server. string can only be read serverside.

napo_p2p
03-31-2006, 11:50 AM
function onPlayerTouchsMe()
... spelling error.

Of a spelling error!

ApothiX
03-31-2006, 04:54 PM
Of a spelling error!
Stefan didn't want the language to sound so dirty!

Skyld
03-31-2006, 07:20 PM
Of a spelling error!
Which is, of course, ironic.

excaliber7388
03-31-2006, 11:44 PM
:) thanks if you havn't already, i'll fix the errors. Thats one of the reasons I chose to do this on the wiki, any user can access it or fix errors, or even add to it. ^^