Optimizing a script that replenishes everything

All discussions & material related to Command's Lua interface

Moderators: michaelm75au, angster, RoryAndersonCDT, MOD_Command

Post Reply
Redeye43
Posts: 63
Joined: Wed Jan 05, 2022 7:37 pm

Optimizing a script that replenishes everything

Post by Redeye43 »

So I built this huge script over a lot of work to replenish, refuel, repair, all that, for EVERY unit on a side - I included a batching system, but it's a bit crunchy. So far, on No BREXIT No Problem!, the first run without a cache takes 200-300ms on my system with a denominator of 1, while running with a full cache takes 70-110ms. I'm trying to figure out how to speed this thing up, because almost all of the actual time is coming from ScenEdit_GetUnit calls and the live data access component, where I pull stuff out of the results of the ScenEdit_GetUnit call. I think this is data marshaling lag but I'm unsure what's up. Anybody have ideas about how to make this script even quicker? I'd really prefer to just *trigger* it only when units fire, but I have no idea how to make an event that triggers when a unit *shoots,* and that somehow feels extremely inefficient.
Attachments
ReplenishAll.lua.txt
(27.52 KiB) Downloaded 11 times
Post Reply

Return to “Lua Legion”