I dont believe nearestobject command or resources is the issue.
Seeing how the script works on some computers but crashes slower ones, that would seem to be the case. However, I tried commenting out all the evaluation part of the function (where it determines what do do with the object found via nearestobject), and it didn't crash my computer at all. So I think you may be right about that.
Now, I tried your suggestion, and.... it crashed still. However, it didn't seem to crash as quickly as usual, so at least that is encouraging
. Interesting thing though, is that I tried putting this in instead:
if ("All" countType [_obj] == 1 && typeof _obj == "crater") then
And I got a different result: instead of the game crashing, it froze. Not a more desirable result, but a different one nonetheless...
A sneaking suspicion I've had is that perhaps the nearestObject is returning something weird, like the blood particle that appears when a unit is hit. But the thing that confuses me, is why would the script crash some computers but not others, if it is making a bad call (like a getpos to an object that doesn't exist)?