3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: what's better- 2 scripts or one?  (Read 1380 times)

xat

« on: December 13, 2010, 05:44:27 PM »
Is it better to have one script that's linked to all objects, or..

To have 2 scripts, one active that processes info, the other is inactive, and the inactive one is the only one connected to most of the other objects, and it's activated by the other script when it's time to do something to an object.

Which would more likely increase framerate? Does it even matter?

-If I'm using a lot of script-created imposters, would this affect which is better?
« Reply #1 on: December 13, 2010, 05:56:33 PM »
The problem your going to run into is that you can't use one script for everything unless you keep your project very small...

There are some work arounds, but right off the bat you are limited to the number of VAL_xx's you can have(9)  And I am pretty sure there is a limit to the OBJ_XX's you can have as well. 

I have had a lot of luck keeping the scripts modular, meaning each script serve a particular function.  It's easier to reuse code that way, IMO easier to troubleshoot if you run into problems, and it is consistent to the "spirit" of 3drad.
« Reply #2 on: December 14, 2010, 04:56:26 PM »
well, size limitations aside (a script can manage up to 81 objetcs; and VAL_xx's are there only to communicate with others scripts, so if you use just one script...  :D), this is an interesting question, because more scripts = more messages between objects = more overhead.

now, there's the conditional xat propose: the script is not started all the time.

so this question goes for Fernando, when the script is not started, the messages overhead is still there?
I gonna guess yes, because you need to start the script somehow so at least THAT message is readed, but are ALL the messages working and consuming resources?  ???

---------------
so, so far... I'd bet on one script for everything.

which raises another question,  the size of the full script weights much? even if most of it is not called all the time?
Crashing Boxes - winner of the 3d games category at the 5th Uruguayan video game contest
get a copy for your iPad/iPhone!
« Reply #3 on: December 14, 2010, 05:14:01 PM »
only 81...what a limitation for me...
I was dreaming about only one big script but it's a nightmare
« Reply #4 on: December 14, 2010, 05:47:34 PM »
For many reasons, some mentioned by electron_theory above, trying to use individual Script object for individual aspects of your game logic is usually the best approach.

Disabled scripts use less processing power and less messages are exchanged, so, yes, stopping scripts that aren't in use is a good idea, performance wise.

However, in certain cases, depending on what exactly your script does, one single script for the whole game has advantages. Especially if the algorithms are strictly correlated and splitting the code into multiple Script objects would result in a lot of script-script linking (for example to share variables etc).

As always in life, I guess it's a matter of finding the balance, to fit the circumstances  :)

xat

« Reply #5 on: December 14, 2010, 06:13:16 PM »
I like to 'test' the framerate for various things to get some solid actual-outcome framerate logic.

It'd be a worthwhile 3d rad community project to make several tests on how various things affect the framerate and document the outcome of them. This would be extremely useful for reference, and anyone could contribute to it.

Every bit of info from anyone would help.
Pages: [1]