Difference between revisions of "Simulating new functions"

1,361 bytes added ,  21:49, 18 April 2006
no edit summary
imported>Tegid
(More function call options)
imported>Maian
Line 126: Line 126:


[[Category:Questions]]
[[Category:Questions]]
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:
#It can be called (via |testfunc.Activate player, 1|).
#The function is executed immediately rather than after the script that called it.
#It can be called even in places where the dummy object isn't at, e.g. I placed the dummy object inside an interior cell and called it in an exterior cell. This was what I was most worried about with this approach - that the function would only work if the dummy object is in the same area. I haven't tested this extensively, so it may be the case that it works only because the dummy object is still in memory, but I suspect that's not the case.
Tegid, in your example, the called function apparently needs a reference to the script calling it, which defeats the purpose of making the function generic (after all, the main reason for creating a new function is to share code between 2+ functions). Maybe if your script just checked if incoming.Me was set and just used incoming rather than CallingScriptRef, it could work generically.
Kkuhlmann, I haven't tried your method yet, but I'm post an update once I do so.
Thanks for all the help! --[[User:Maian|Maian]] 21:49, 18 April 2006 (EDT)
Anonymous user