Thread: Functions.
View Single Post
  #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