I'm trying to put together something to see if it can be done. But before I get too far into it, I want to know if having a long 'script' is worse or better than dividing it into several smaller ones (which are triggered by broadcasts).
These if-blocks are going to really start adding up really quickly...
Offline
Depends what you're shooting for.
If you want to use as few scripts as possible, do the long one.
If you don't really care, I say it depends on your computer speed and your patience.
Offline
scimonster wrote:
Depends what you're shooting for.
If you want to use as few scripts as possible, do the long one.
If you don't really care, I say it depends on your computer speed and your patience.
For the last one: Wha?
Offline
One script is (generally considered) faster, but can make it harder to program and make the code less readable. On the other hand, I think that if you can put them all in one script, go for it!
On the other hand, using multiple scripts can cause some glitches that occur because certain scripts loop over before other ones. In one giant script, the programmer knows what script just happened, and what variables he/she can count on as accurate.
Offline
I'm trying to accomplish performance rather than a minimal number of scripts.
The thing in particular that I'm doing is having multiple classes/roles all crammed into the player. It is about 18 if-blocks per class, but assuming if there are like 10-15 classes, that's a bit to have constantly running in the background- just from simply walking...
I can separate each set into several smaller bunches, which would be triggered via broadcast. So that not all that extra code is having to be ran constantly.
But I'm unsure which one uses less processing, or if there is even a difference.
Offline
Single scripts run faster but in order, this means that if for example you had a loop in the middle of one of your bits everything would have to wait for that loop in the single script.
By using broadcasting, which takes more processing power simply because you have to do the broadcast code as well, you get more easily edited code that takes up a bit more power. Plus side is that you can run things simultaneously though, or as near as you can get to simultaneously, anyway.
Offline
OK.
Last time I made a 1s1s, the designer got REALLY slow. I have never had that problem with multiple scripts.
I find multiple scripts easier to find and fix bugs, but that is just my opinion.
Offline
Personally, I think that several medium sized scripts would do well. Several long ones would be too laggy.
And too many scripts in general is laggy. Example.
Last edited by henley (2011-11-10 16:14:34)
Offline
Xzerie wrote:
I'm trying to accomplish performance rather than a minimal number of scripts.
The thing in particular that I'm doing is having multiple classes/roles all crammed into the player. It is about 18 if-blocks per class, but assuming if there are like 10-15 classes, that's a bit to have constantly running in the background- just from simply walking...
I can separate each set into several smaller bunches, which would be triggered via broadcast. So that not all that extra code is having to be ran constantly.
But I'm unsure which one uses less processing, or if there is even a difference.
Breaking it into broadcasts will run considerably faster. Each 5 if loops added to a forever loop can reduce the Frames Per Second by as much as 1 - 4. Having broadcasts will cut out a lot of the lag.
Also not, never have a small script that simply says:
When <greenflag> clicked
forever
if foo
bar
end
Instead, replace the if with a wait until block. For whatever reason, this speeds the program up immensely.
Offline
henley wrote:
Personally, I think that several medium sized scripts would do well. Several long ones would be too laggy.
And too many scripts in general is laggy. Example.
What I noticed was that they were using a lot of <when green flag clicked>, then a long list of things in <forever>.
Offline
I try to put them in one script, but it really depends on what you're trying to achieve... for example, two scripts running at the same time can check for two things at the same time but two if blocks in a forever in one script can only check for one thing at a time.
Offline
I love to do 1s1s and I think that's usually the way to go...the problems occur when you get a long script which slows down the editing speed and such in which case, it might be better to go with multiple scripts. However, I think that multiple scripts can lead to disorganization, overlapping scripts (i.e. one script runs when it shouldn't, messing up others), and other such things. Multiple scripts usually need more parameters or restrictions so as to not interfere with others.
Offline
Xzerie wrote:
henley wrote:
Personally, I think that several medium sized scripts would do well. Several long ones would be too laggy.
And too many scripts in general is laggy. Example.What I noticed was that they were using a lot of [[green flag clicked] blocks], then a long list of things in some [forever] blocks.
How do you suppose I change that? By not making the project?
Offline