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.