Will a lot of global user functions bog down a quest script?

Post » Wed Jun 20, 2012 8:15 pm

I am starting to get a lot of Global functions in my quest script to be used in other scripts (magic effect scripts).

In Oblivion we put user functions in unused (not in the game world) Object REFs not in the quests. I am worried this will bog down my Skyrim quest script.

Is this true? If so can I build my functions in an object script that is not placed in the world in Skyrim?
User avatar
Nick Pryce
 
Posts: 3386
Joined: Sat Jul 14, 2007 8:36 pm

Post » Wed Jun 20, 2012 5:58 am

Is this true?
I don't know for sure, but I don't think the number of functions has any impact on the script's performance. What the functions do does matter a lot more, e.g. do they have to do long loops, that would delay execution? Edit: On the other hand: If I understood correctly how the script threading works it should not be a problem, so long the functions don't access shared variables you cann call a function while another is still executing, the game will simply start another thread of the script to execute the function (not sure if this is true though).
If so can I build my functions in an object script that is not placed in the world in Skyrim?

It depends. If the script only provides functionality and does neither have to store values nor has to have access to any properties you could also use a script that is not attached to anything and invoke it's global functions either by importing it into the calling script or by calling scriptname.function().

If the script needs to store values or have acces to properties you'd need to attach it to an object. In order to call the functions you need a reference to an instance of that object (otherwise the script is not loaded, and more importantly values wouldn't be saved), so you need need to place it in the gameworld.
User avatar
Joe Alvarado
 
Posts: 3467
Joined: Sat Nov 24, 2007 11:13 pm

Post » Wed Jun 20, 2012 4:32 pm

We (programmers) call that http://c2.com/cgi/wiki?PrematureOptimization.

Simply put, stop worrying and start doing. You can worry when you know there is something to worry about, until then don't.
User avatar
Cartoon
 
Posts: 3350
Joined: Mon Jun 25, 2007 4:31 pm

Post » Wed Jun 20, 2012 5:39 am

If you have a heap of global functions, then set them up the same as the vanilla globals. ie, put them in their own file MyGlobals.psc
There's no need to create any objects to hold the script. It's a lot cleaner than previous games in that respect.

Then in your quest, magic effect, or any other script, use them by

MyGlobals.MyGlobalFunc1()

or

Import MyGlobals
MyGlobalFunc1()
User avatar
Marie
 
Posts: 3405
Joined: Thu Jun 29, 2006 12:05 am

Post » Wed Jun 20, 2012 7:33 pm

Thanks you guys.
User avatar
Sophie Payne
 
Posts: 3377
Joined: Thu Dec 07, 2006 6:49 am


Return to V - Skyrim