SphereCommunity
How to call Function - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: How to call Function (/Thread-How-to-call-Function)



How to call Function - desadius - 02-01-2014 09:03 PM

Hi Bye i need little help whit calling functions in script.

i have function called: f_regionSpawn

it take some arguments and returns string whit random position on the map.

it works as should be.
i tested it by .show command ingame and returns what i need. But i dont know how to properly call it in script and store it in variable. Can any one please advise me proper syntax?

i tried some of these :

Code:
Local.Pos = f_regionSpawn a_yew_ter,1000,828,2000,0,<i.defname>_<i.uid>


Local.Pos = <f_regionSpawn a_yew_ter,1000,828,2000,0,<i.defname>_<i.uid>>  This one is right!


Local.Pos = f_regionSpawn(a_yew_ter,1000,828,2000,0,<i.defname>_<i.uid>)

Local.Pos = <f_regionSpawn(a_yew_ter,1000,828,2000,0,<i.defname>_<i.uid>)>


Local.Pos = <f_regionSpawn a_yew_ter,1000,828,2000,0,<i.defname>_<i.uid>> This one is right!



but varibale always don't store the string
what i missing ? :Confused

and it call the function in script just fine but I can't store the returned string


RE: How to call Function - XuN - 02-02-2014 03:44 AM

The second one is the correct, if you cannot call it in script it may be a problem with the previous call, is it already inside a function? how is it called and from who? Try this:

Code:
[function f_test]
var.mytest=<f_regionSpawn a_yew_ter,1000,828,2000,0,<i.defname>_<i.uid>>
say var.mytest=<var.mytest>


If this function returns you the correct value ingame, then it must be working this way.


RE: How to call Function - Alaric - 02-02-2014 04:54 AM

The function itself might cause the issue. Will you show it to us? Just deducing, since you tried the second one which is also the correct one.


RE: How to call Function - Extreme - 02-02-2014 11:19 AM

Where is the f_regionSpawn function?


RE: How to call Function - desadius - 02-02-2014 08:39 PM

(02-02-2014 11:19 AM)Extreme Wrote:  Where is the f_regionSpawn function?

Thanks for IDEA! i rechecked the spheretable.scp and found it.

i put my function file after the call script. So i re-ordered and everthing is ok! thanks for help.