Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Some warning before script too complex

Discussion in 'Programming (In-game)' started by cheb, May 30, 2020.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. cheb Trainee Engineer

    Messages:
    12
    May I know in script about how i close to "Script is too complex" error? My script may vary count of iterations it does. So, maybe there is a way to know about reaching limit without stopping PB?
     
  2. Malware Master Engineer

    Messages:
    9,861
    If you get the script is too complex error, you're already doing way, way too much. You shouldn't be getting even close to the limit.


    That said, you don't want to do that. It will result in scripts that makes as much performance hit as they can, as opposed to doing as little as possible every tick, being performance friendly.

    You can find the count here though:
    https://github.com/malware-dev/MDK-...ridProgramRuntimeInfo.CurrentInstructionCount

    But please don't use it the way you suggest.
     
  3. cheb Trainee Engineer

    Messages:
    12
    Thank you. Again very useful info!

    Here is my script: https://steamcommunity.com/sharedfiles/filedetails/?id=2112549802.
    To sort items i must check every inventory, then found target inventory for each item, that needs to be moved. I have large base (~100 refineries, millions of ore and ingots, hundreds of thousands components). Main load(as i think) is to check contents of any non-configured inventory(output of assemblers and refineries, etc). How can i optimize it? With property, that you give, i can separate inventories between executions.

    Vanilla sorter blocks are almost unusless :(
     
  4. Malware Master Engineer

    Messages:
    9,861
    I recommend splitting the work into multiple ticks. Don't try to do everything in one go. The following might be a little hard to learn if you're not familiar with the subject, but if you can manage to, it is seriously powerful in this regard - well worth the effort.

    https://github.com/malware-dev/MDK-SE/wiki/Coroutines---Run-operations-over-multiple-ticks

    Inventory scripts are particularly tricky, since Keen's inventory system is... mwell, less than optimized, let's say.
     
  5. cheb Trainee Engineer

    Messages:
    12
    This is probably the most correct way.

    The conveyor system also has limits and may stuck for seconds. And no info how to calculate this limit.
     
Thread Status:
This last post in this thread was made more than 31 days old.