Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-13-2006, 08:58 PM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to Prozac
Object Oriented Programming tutorial

Still a little rough, but I think it gets the ideas across for a mindset that is more adaptive to learning gs2.

Please feel free to modify/correct/edit and repost revisions to this as needed.
It is for the newcomers to the gs2 community, and can be openly modified by those in the know. (scroll down for latest version)
Attached Files
File Type: txt oop-gs2.txt (7.8 KB, 311 views)
Reply With Quote
  #2  
Old 02-13-2006, 11:32 PM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
Put it on the GraalBible.
Reply With Quote
  #3  
Old 02-13-2006, 11:58 PM
Fox1545 Fox1545 is offline
Registered User
Join Date: Jul 2004
Posts: 78
Fox1545 is on a distinguished road
Quote:
Originally Posted by Rick
Put it on the GraalBible.
Put it on the Graal Wiki.
Reply With Quote
  #4  
Old 02-14-2006, 12:01 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Prozac
Still a little rough, but I think it gets the ideas across for a mindset that is more adaptive to learning gs2.

Please feel free to modify/correct/edit and repost revisions to this as needed.
It is for the newcomers to the gs2 community, and can be openly modified by those in the know. (scroll down for latest version)
I think the article could do with fluffing out a bit, to make it easier for the average person with no programming knowledge to understand. If you were to start with basic construct of the language, logic behind the construct, why things are what they are and explaining everything in plain English, it might help people more.

Other than that, looking interesting.
__________________
Skyld
Reply With Quote
  #5  
Old 02-14-2006, 12:45 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Hmmm Prozac you forgot to put the cup down before leaving the washroom
It's a good start I think, although it's more a general programming introduction not only about object oriented programming
Reply With Quote
  #6  
Old 02-14-2006, 03:35 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Hmm.. I think your section on Constructors is a bit flawed. Should try looking up what a constructor is before writing about it

Quote:
Originally Posted by Stefan
Hmmm Prozac you forgot to put the cup down before leaving the washroom
o_O What do you mean by this? xD
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #7  
Old 02-14-2006, 09:32 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by ApothiX
o_O What do you mean by this? xD
In his example of an algorithm, with the stuff about what you do in the morning - he forgot to put the cup down.
Reply With Quote
  #8  
Old 02-15-2006, 01:18 AM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to Prozac
ya, thought I might forget some stuff on the first draft.
thanks for the feedback though. Will see what I can do - or, as mentioned, feel free to 'fluff out' the doc as you see fit and post updates of it on here. I may not get back to it for a while.
Reply With Quote
  #9  
Old 02-15-2006, 02:45 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Codein
In his example of an algorithm, with the stuff about what you do in the morning - he forgot to put the cup down.
Oh, lmao xD
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #10  
Old 02-23-2006, 10:42 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
I hardly consider GS2 an OO language. It has some OO concepts yeah but it's not completley object-oriented.
While each NPC does act like a class you cant make relationships between them (either inheritance or association) you can 'inherit' the classes in the class list on the server (which are basically deferred classes). I can call functions on an NPC by using triggeraction but really I should be able to do npcname.functionname.

I can't do this: object = new Class(); (Please correct me if i'm wrong) which means I cant pass objects around. Sure there's the player object which can always be accessed but sometimes it can be useful. (Admittedly not often given the usually small nature of scripts in graal.) While GS2 has some OO concepts its OO model is quite limiting. Though of course it is just a small scripting langage and not a full programming language and doesn't really need a sophisticated object model.


Anyway, what you have there might be quite useful to non-programmers but some of the explanations might serve the opposite purpose you're using terms like code block without saying what a code block is also, i'd use GS2 only. Doesn't make sense to say "Here's some code but don't do it like this." it's like teaching java and saying "Heres an example GUI in AWT but you shouldn't use AWT you should use Swing or SWT."

oh well just my $0.03 (Damn inflation.)
Reply With Quote
  #11  
Old 02-23-2006, 11:57 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by JkWhoSaysNi
While each NPC does act like a class you cant make relationships between them (either inheritance or association) you can 'inherit' the classes in the class list on the server (which are basically deferred classes).
Can you think of a need to change the current system?
Quote:
Originally Posted by JkWhoSaysNi
I can call functions on an NPC by using triggeraction but really I should be able to do npcname.functionname.
PHP Code:
public function myFunction()
{
  return 
true;

PHP Code:
objectName.myFunction(); 
Quote:
Originally Posted by JkWhoSaysNi
I can't do this: object = new Class(); (Please correct me if i'm wrong) which means I cant pass objects around.
Yes, you can.
PHP Code:
myVar = new TStaticVar();
myWindow = new GuiWindowCtrl("myWindow"); 
Quote:
Originally Posted by JkWhoSaysNi
Sure there's the player object which can always be accessed but sometimes it can be useful.
And with player classes, you can add functions to the player object, i.e
PHP Code:
player.addMessage("Hello there"); 
__________________
Skyld
Reply With Quote
  #12  
Old 02-24-2006, 01:11 AM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Quote:
Originally Posted by Skyld
Can you think of a need to change the current system?

PHP Code:
public function myFunction()
{
  return 
true;

PHP Code:
objectName.myFunction(); 
Where does the object name come from? Say I have 2 npc's in a level. I want to call a function on one from the other. Currently you can do this with triggeractions.

Quote:
Yes, you can.
PHP Code:
myVar = new TStaticVar();
myWindow = new GuiWindowCtrl("myWindow"); 
Yes but I want to my create my own classes. (Just a simple example. I dont really need to do anything like this but it would make gscript more flexible.)

PHP Code:
class myClass {
someVar "something";
someVar2;
public function 
myClass(a,b) {
this.someVar a;
this.someVar2 b;
}
public function 
stringRepresentation() {
return 
this.someVar this.someVar2
}

PHP Code:
myVar = new myClass("One""Two");
myVar2 = new myClass("Three","Four");
player.chat myVar.stringRepresntation();
say2(myVar2.stringRepresentation()); 
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:33 AM.


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