View Full Version : How resource intensive is having lots of scripts all running 'while line = get' ?
phoenixfire53
05-30-2016, 05:16 PM
So the other day I wrote up a quick script which automatically goes to a table once I've been invited. It's just a simple while line = get; if line =~ /{invite string}/; fput go table. It got me wondering, what would happen if I had a lot of these simple line checking scripts running concurrently? How much load are they creating? Should I have a pause after each loop? Would it make more sense to have a single file with a long list of if/elsif checks?
Haldrik
06-02-2016, 10:53 PM
So the other day I wrote up a quick script which automatically goes to a table once I've been invited. It's just a simple while line = get; if line =~ /{invite string}/; fput go table. It got me wondering, what would happen if I had a lot of these simple line checking scripts running concurrently? How much load are they creating? Should I have a pause after each loop? Would it make more sense to have a single file with a long list of if/elsif checks?
I would say... not very. But you shouldn't need "a lot of little ones". If you have a bunch of little ones, just create a script that contains them
while line = get
do x if line = y
do x if line = y
do x if line = y
if line = y
do x
do y
do z
end
end
That being said, I have multiple while line = get if scripts need them to and are more self-contained.
You don't need a pause after a while line = get because the nature of the while loop is that it has a waitfor. while line = get has a WAITFOR LINE. Therefore it can never go into infinite loop. This is most apparent when you are expecting your loop to do something but it does not because you haven't gotten a line from the game in awhile.
while line = get
fput 'stand' if !stand?
fput 'get weapon' if line = /You have been disarmed/
end
As you can see in the above, you would expect the script to stand if not standing. However, it will not stand until ANY line comes through. Hopefully that makes sense.
Loops generally do need pauses, this one does not.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.