Difference between revisions of "Simulating new functions"
Jump to navigation
Jump to search
no edit summary
imported>Maian |
imported>Maian |
||
Line 124: | Line 124: | ||
This removes the need for a game mode block and allows function passing (or setting in a persistent reference). I've used this quite successfully for some cool stuff I'm finishing the testing on. | This removes the need for a game mode block and allows function passing (or setting in a persistent reference). I've used this quite successfully for some cool stuff I'm finishing the testing on. | ||
--[[User:Tegid|Tegid]] 14:44, 18 April 2006 (EDT) | --[[User:Tegid|Tegid]] 14:44, 18 April 2006 (EDT) | ||
After some experimentation, I've verified that making the function script an object script and attaching it to a dummy object (in activator called testfunc in my case), it works. That is, it satisfies the following conditions: | After some experimentation, I've verified that making the function script an object script and attaching it to a dummy object (in activator called testfunc in my case), it works. That is, it satisfies the following conditions: | ||
Line 137: | Line 135: | ||
Thanks for all the help! --[[User:Maian|Maian]] 21:49, 18 April 2006 (EDT) | Thanks for all the help! --[[User:Maian|Maian]] 21:49, 18 April 2006 (EDT) | ||
Kkuhlmann's solution also worked. | |||
For reference, here's my dummy object + activate script solution: | |||
On a dummy object: | |||
<pre>scn testfuncobjscript | |||
float param1 | |||
float param2 | |||
float result | |||
begin OnActivate | |||
Message "start func", 1 | |||
set result to param1 + param2 | |||
Message "end func: %.0f", result, 1 | |||
end</pre> | |||
Calling script: | |||
<pre>scn testobj2script | |||
float r | |||
begin OnActivate | |||
Message "before call", 1 | |||
set testfuncref.param1 to 10 | |||
set testfuncref.param2 to 20 | |||
testfuncref.Activate Player, 1 ; <-- function call | |||
set r to testfuncref.result | |||
Message "after call: %.0f", r, 1 | |||
end</pre> | |||
--[[User:Maian|Maian]] 01:47, 19 April 2006 (EDT) | |||
[[Category:Solutions]] |