 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
| Author |
Message |
Austin POL Developer
Joined: 30 Jan 2006 Posts: 355 Location: San Diego, California
|
Posted: Fri Feb 16, 2007 12:25 pm Post subject: |
|
|
| Code: |
function GetAllObjectsOnShard()
var objects := array;
// First process all top level objects.
foreach realm_name in ( Realms() )
foreach multi in ( ListMultisInBox(0, 0, -128, realm.width, realm.height, 128, realm_name) )
if ( !(multi in objects) )
objects.Append(multi);
endif
endforeach
foreach object in ( ListObjectsInBox(0, 0, -128, realm.width, realm.height, 128, realm_name) )
if ( !(object in objects) )
objects.Append(object);
endif
endforeach
endforeach
// Process all player characters
foreach accout_name in ( ListAccounts() )
var account := FindAccount(account_name);
var i;
for ( i:=1; i<=6; i:=i+1 )
var object := account.GetCharacter(i);
if ( object )
if ( !(object in objects) )
objects.Append(object);
endif
endif
endfor
endforeach
// Process all storage areas
var storage_areas := StorageAreas();
foreach area_name in ( storage_areas )
var storage_area := storage_areas[area_name];
foreach root_container in ( storage_area )
if ( !(root_container in objects) )
objects.Append(root_container);
endif
foreach item in ( EnumerateItemsInContainer(root_container) )
if ( !(item in objects) )
objects.Append(itemt);
endif
endforeach
endforeace
endforeach
return objects;
endfunction
|
|
|
 |
|
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
| Author |
Message |
Barbeirosa
Joined: 01 Feb 2007 Posts: 43
|
Posted: Sat Feb 17, 2007 6:14 pm Post subject: |
|
|
I wouldn't run any such script while players were online at all due to the memory use and CPU use it would generate. Slapping 'sleeps' in scripts seems to be a way people avoid apparent problems in scripts (for example, to avoid the 'runaway script' warnings), but usually I think people have no clue what they are doing, and they are just masking real problems. It's kind of like fixing that "Check Engine" light in your car by cutting the wires that power it, instead of fixing the problem that caused the light to come on in the first place.
With no players on, I would -NOT- put sleeps in it - in fact, I would run it critical or at maximum priority so that it finishes as quickly as possible, and doesn't sit there taking forever due to all those sleepms(100) calls. I would assume anything important enough to want to fix ALL the items on the shard would also be important enough that you would not want any concurrency issues arising from actions players might take.
I mean... do the math here; 100ms is 1/10 a second. A sleep will give you at least that much time between each item, allowing other scripts to run for at least that long. Meanwhile, you still have this huge array being built up in memory and stored, while you are letting other things happen concurrently. 1/10 of a second between each item delay, and you could easily be causing such a script to run for a day or longer depending on the size of your shard.
Perfect example of fixing the Check Engine light by cutting the wires that power it... and this, from a 'Distro Developer'. |
|
 |
|
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
| Author |
Message |
Barbeirosa
Joined: 01 Feb 2007 Posts: 43
|
Posted: Sun Feb 18, 2007 3:20 pm Post subject: |
|
|
| MontuZ wrote: | | And Babbles, I do highly suggest to anyone to put sleepms's in there foreach loops to prevent RUNAWAYS. Unless of course you enjoy them(I think barb might be one!). |
Yup. Just like I said. Cutting the wires to turn off the Check Engine light, instead of trying to actually understand what's going on.
"Runaway scripts" are simply something that POL reports to you on the assumption that it's a bad thing. It's an "Idiot Light" sort of thing... just like that "Check Engine" light. Simply putting sleeps in there does -nothing at all- except avoid that 'Idiot Light' from coming on. That's all you are doing. To suggest otherwise is to prove you are completely ignorant about how threading works in general, and how POL's script scheduling works in particular.
When you sprinkle sleeps everywhere willy-nilly, without any concern for what is actually being done, you are being sure to avoid that idiot light. But, guess what? Your script can still bring your shard to its knees, even with sleeps.
Scripting POL is not like just driving your car to work every day. It's more like being a high-performance car mod freak, playing with the innards of your engine to get the most performance out of it. When you do that, you are going to find that occasionally, your "Check Engine" light is going to turn on. You can bury your head in the sand and just cut the wire, OR you can make an effort to understand what's going on, and why that "Check Engine" light is coming on. Perhaps it's actually not a problem at all.
In the case of the above script, a runaway is no big deal. You want the script to run FAST and be COMPLETED, and you should not be interested in having anything running at the same time. Yes... your "Check Engine" light is going to flash up a storm while that's running - but a scripter who has any clue what they are doing would know why, and would know that it's not a bad thing at all. That actually, in this case, it's a GOOD thing.
But maybe this is why the distro is in such a sorry state... having people like this working on it. |
|
 |
|
|
 |
 |
|