Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   noobie scripting guide! (https://forums.graalonline.com/forums/showthread.php?t=65078)

excaliber7388 03-31-2006 12:47 AM

noobie scripting guide!
 
http://wiki.graal.net/index.php/Worl...cripting_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 09:19 AM

A few things need to be touched up, but overall, a good try.
Quote:

triggeraction (x,y,"params[0]","params[1]");
Variable names should not be inside "quotes".
Quote:

addweapon Fire Ball;
setshape 1,32,32;
if (playerrupees>=100)
PHP Code:

addweapon("Fire Ball");
setshape(13232);
if (
player.rupees >= 100

Quote:

function onPlayertouchesme()
PHP Code:

function onPlayerTouchsMe() 

... spelling error.
Quote:

triggeraction (x,y,"Touched","Touched");
... will produce
PHP Code:

function onActionTouched() 

... not
PHP Code:

function onTouched() 

Quote:

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:
PHP Code:

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 10:50 AM

Quote:

Originally Posted by Skyld
PHP Code:

function onPlayerTouchsMe() 

... spelling error.

Of a spelling error!

ApothiX 03-31-2006 03:54 PM

Quote:

Originally Posted by napo_p2p
Of a spelling error!

Stefan didn't want the language to sound so dirty!

Skyld 03-31-2006 06:20 PM

Quote:

Originally Posted by napo_p2p
Of a spelling error!

Which is, of course, ironic.

excaliber7388 03-31-2006 10: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. ^^


All times are GMT +2. The time now is 01:23 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.