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 03-16-2005, 06:23 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
Functions.

I have some questions about the use of functions in gscript:

1. Can you create a function in an npc and call it from another npc? if so, how?

2. Is it possible to pass arguements to functions?

Also, is there any form of inheritance in gscript (ie, basing an npc from another npc).

is it obvious i'm used to OO languages?
Reply With Quote
  #2  
Old 03-16-2005, 08:14 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
I wasn't entirely sure whether you were talking about Old Gscript or the New Engine, so I'll answer for both.

Quote:
Originally Posted by JkWhoSaysNi
I have some questions about the use of functions in gscript:
1. Can you create a function in an npc and call it from another npc? if so, how?
Gscript: Not that I know of.
Gscript2: Yes, by using public function functionname(params) {
Say you use that in a weapon called "Haha", then you would then call it using Haha.functionname(params);. If your weapon name has spaces, then you would use makevar("Weapon Name").functionname(params);.

Quote:
Originally Posted by JkWhoSaysNi
2. Is it possible to pass arguements to functions?
Gscript: Not that I know of.
Gscript2: Yes, by putting variable names like function functionname(var1, var2) { which will take parameters like functionname(first, second);. In this case, inside the function, var1 and var2 will be set to the given parameters.

Quote:
Originally Posted by JkWhoSaysNi
Also, is there any form of inheritance in gscript (ie, basing an npc from another npc).
I'm not sure what you mean by inheritence, but you can use classes which can be used with putnpc2. This will allow you to write a script and each of these putnpc2'd NPCs will follow it, but they are individual NPCs. Also, you can use join; in a script to include script from a class.
__________________
Skyld
Reply With Quote
  #3  
Old 03-17-2005, 05:04 AM
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
There is no real inheritence in GScript or GScript2.
Reply With Quote
  #4  
Old 03-17-2005, 05:17 AM
falco10291029 falco10291029 is offline
BEst User EVER!
Join Date: Apr 2004
Posts: 1,186
falco10291029 is on a distinguished road
FOr normal gscript, callnpc can be used (maybe not directly, but I'mn sure it can) to call another npc's function, perhaps through something like:

NPC Code:

callnpc index,call,;


and then in the other npc (recieving the command to call the function):
NPC Code:

if (call) funcname();




I used something similar to that in a summoning system.

And Skyld, take that quote of me out of your sig please....
__________________
BEst Insult ever: If I had a dollar for every brain you DIDNT have, i'd have one dollar!
Reply With Quote
  #5  
Old 03-17-2005, 10:09 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 falco10291029
FOr normal gscript, callnpc can be used (maybe not directly, but I'mn sure it can) to call another npc's function, perhaps through something like:

NPC Code:

callnpc index,call,;


and then in the other npc (recieving the command to call the function):
NPC Code:

if (call) funcname();




I used something similar to that in a summoning system.
You could use triggeraction I suppose. Although, that requires knowing the NPC's location on the board if not a weapon.

Quote:
Originally Posted by falco10291029
And Skyld, take that quote of me out of your sig please....
A'okay. There you go.
Reply With Quote
  #6  
Old 03-17-2005, 04:41 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
Thanks. I asked about passing variables because when i press test in the level editor it shows it as invalid. I guess it's outdated.
Reply With Quote
  #7  
Old 03-17-2005, 09:28 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
How do you get the index of the NPC?
Reply With Quote
  #8  
Old 03-17-2005, 10:17 PM
Ajira Ajira is offline
Poont.
Join Date: Oct 2004
Location: NY, USA
Posts: 477
Ajira is on a distinguished road
Quote:
Originally Posted by JkWhoSaysNi
How do you get the index of the NPC?
I believe its the var 'id'.
__________________
Liek omigosh.

Reply With Quote
  #9  
Old 03-17-2005, 10:28 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
Thanks. I'll try that. I still cant get parameters for functions to work. Even if i do something as simple as this:
NPC Code:

function finished(what) {
say2 #v(what);
}



It simply wont run. I've tried putting a say2 in with plain text, no variables. It's as if the function never gets called.
Reply With Quote
  #10  
Old 03-17-2005, 10:31 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Ajira
I believe its the var 'id'.
Well, ids and indices aren't the same thing, though there're similarities. Still, I can't think of any situation where the id wouldn't suffice.

Quote:
Originally Posted by JkWhoSaysNi
Thanks. I'll try that. I still cant get parameters for functions to work
Dude, you've already been told that it's not a feature of old GScript.
__________________
Reply With Quote
  #11  
Old 03-17-2005, 10:43 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
Erm... how do i know if the server is using gscript or gscript2?
Reply With Quote
  #12  
Old 03-17-2005, 11:09 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by JkWhoSaysNi
Erm... how do i know if the server is using gscript or gscript2?
Old GScript is a subset of new GScript. Ask the manager if the latter is enabled.
__________________
Reply With Quote
  #13  
Old 03-25-2005, 06:47 PM
p2p_Sir_Link p2p_Sir_Link is offline
Banned
p2p_Sir_Link's Avatar
Join Date: Nov 2004
Posts: 425
p2p_Sir_Link is an unknown quantity at this point
In the case of Syvlion, it isn't.
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 03:46 AM.


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