Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-03-2017, 01:01 PM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,746
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
GScript for Dummies Guide to GS2 question.

I'm reading the guide on GS2 and near the end he or she mentions objects. This part has me lost. What exactly is happening here?
PHP Code:
temp.controlnpc findnpc("Control-NPC");  //Creates an object references the Control-NPC
this.player_data temp.controlnpc.player_data;  //Copies data from the Control-NPC to the current NPC.
temp.controlnpc.onCreated(); //Executes the onCreated function through the Control-NPC 
I can only guess what Control-NPC is. I see it listed on the server I am practicing on, but I have very limited rights so I can't open it up. I assume there is code inside, but at this point I am only guessing what this script is referencing.
__________________
Save Classic!
Reply With Quote
  #2  
Old 08-03-2017, 06:17 PM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,746
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Okay after reading some of FP4's tutorial I am guessing temp.controlnpc = findnpc("Control-NPC") finds the object and this.player.data = temp.controlnpc.player_data pulls the value of player_data from the object? But what does temp.controlnpc.onCreated() do? Execute code listed in the onCreated() part of the Control-NPC? If so, how is this different than creating a class, using join, and calling a function that way?
__________________
Save Classic!
Reply With Quote
  #3  
Old 08-03-2017, 07:45 PM
Kamaeru Kamaeru is offline
G2k1
Kamaeru's Avatar
Join Date: Dec 2001
Posts: 1,040
Kamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud of
Quote:
Originally Posted by maximus_asinus View Post
Okay after reading some of FP4's tutorial I am guessing temp.controlnpc = findnpc("Control-NPC") finds the object and this.player.data = temp.controlnpc.player_data pulls the value of player_data from the object? But what does temp.controlnpc.onCreated() do? Execute code listed in the onCreated() part of the Control-NPC? If so, how is this different than creating a class, using join, and calling a function that way?
Control-NPC is an NPC, not a class.

BTW I learned a little from reading this.
__________________
3DS friendcode: 1118-0226-7975
Reply With Quote
  #4  
Old 08-03-2017, 10:55 PM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,746
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Quote:
Originally Posted by Kamaeru View Post
Control-NPC is an NPC, not a class.

BTW I learned a little from reading this.
FP4's tutorial is actually really helpful. I had no idea you could call functions from a variable. Also I now understand what the different variable prefixes do.
__________________
Save Classic!
Reply With Quote
  #5  
Old 08-03-2017, 11:40 PM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,746
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Quote:
Originally Posted by Kamaeru View Post
Control-NPC is an NPC, not a class.
Yeah I realize that. I am just wondering what the difference of doing what was posted vs something like:

PHP Code:
// Part of Class NPC called ControlNPC
function onControl() {
   
temp.control player_data// player_data defined earlier in the script
   
return temp.control;

PHP Code:
function onCreated() {
   
join("ControlNPC");
}
//#CLIENTSIDE
function onPlayerChats() {
   
temp.foobar onControl();
   echo(
temp.foobar);

But maybe I am not clear on the difference between an NPC and a Class. Or maybe I don't know what I'm talking about.

I am not by a computer so I don't know if this is 100% correct**
__________________
Save Classic!
Reply With Quote
  #6  
Old 08-04-2017, 03:05 AM
Kamaeru Kamaeru is offline
G2k1
Kamaeru's Avatar
Join Date: Dec 2001
Posts: 1,040
Kamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud of
This is the best gs2 documentation I have found:

http://gswiki.wikidot.com/gs2-commands

This is the best for explaining how to script gs2:

http://gscript.graal.net/Index

But the best way to learn I have found that helped me the most was javascript lessons here:

http://www.freecodecamp.com
__________________
3DS friendcode: 1118-0226-7975
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 11:09 AM.


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