Page 1 of 2

MGRemix lags fix

Posted: Thu Aug 27, 2020 8:18 pm
by Raito
MGRemix.lua search for function mg.function mg.GetSlotByItemId(uniqueID,aExclude) (uniqueID,aExclude) --around line 120

rename function to function mg.GetSlotByItemIdOld(uniqueID,aExclude)
copy paste this in the file:

mg.InvTable = {}
mg.InvTable_nTime=-1000
function mg.GetSlotByItemId(uniqueID,aExclude)
local vBagItems=DataUtils.GetCraftingItems()
local iSmall=10000
local iSlot=0
local nLoc=mg.TYPE_CRAFTING
local vItem
if (mg.nTime > mg.InvTable_nTime+5)then
mg.InvTable_nTime = mg.nTime;
mg.InvTable = {};
for k,v in pairs(vBagItems) do
mg.InvTable[v.uniqueID]=k;
end
end
if (mg.InvTable[uniqueID])then
iSlot = mg.InvTable[uniqueID];
vItem=vBagItems[iSlot];
end
return iSlot,nLoc,vItem
end



checks no longer normal inventory,saves inventory data for 5sec(use at own risk and have larger seed reserve)

Re: MGRemix lags fix

Posted: Thu Aug 27, 2020 11:35 pm
by Akalukz
woot

Re: MGRemix lags fix

Posted: Sun Sep 06, 2020 8:48 am
by Taz83
so what does this change really do no more auto reserve/convert or is it something else ?

Re: MGRemix lags fix

Posted: Sun Sep 06, 2020 10:10 am
by kaloel
First some indentation:

Code: Select all

mg.InvTable = {}
mg.InvTable_nTime=-1000
function mg.GetSlotByItemId(uniqueID,aExclude)
  local vBagItems=DataUtils.GetCraftingItems()
  local iSmall=10000
  local iSlot=0
  local nLoc=mg.TYPE_CRAFTING
  local vItem
  if (mg.nTime > mg.InvTable_nTime+5)then
    mg.InvTable_nTime = mg.nTime;
    mg.InvTable = {};
      for k,v in pairs(vBagItems) do
      mg.InvTable[v.uniqueID]=k;
    end
  end
  if (mg.InvTable[uniqueID])then
    iSlot = mg.InvTable[uniqueID];
    vItem=vBagItems[iSlot];
  end
  return iSlot,nLoc,vItem
end
It seems like this caches the inventory, to remove the lag when replanting (and auto converting). The cache lasts for 5 seconds, and affects every item that MGRemix is searching for, be it seeds or weeds. BUT it only searches the crafting bags, not the "normal" inventory. (Basically what the OP said, but with more style)

EDIT: Tried it and it seems to work.

Re: MGRemix lags fix

Posted: Sat Sep 12, 2020 10:34 am
by Trsh
is it intended that after this change my mgr shows as yellow in the addons list ?

Re: MGRemix lags fix

Posted: Sat Sep 12, 2020 11:12 am
by Natherul
might be good for someone to post this edit into
https://tools.idrinth.de/addons/mgremix/

Re: MGRemix lags fix

Posted: Sat Sep 12, 2020 8:16 pm
by Darks63
Does this mean if you have seeds in your normal inv it will no longer pull from there if you do this change?

Re: MGRemix lags fix

Posted: Fri Oct 02, 2020 10:17 am
by Mcz
Any chance to get a more detailed explanation please?

Re: MGRemix lags fix

Posted: Sun Nov 15, 2020 3:49 am
by lolwut
If this fix makes MGR window shown with different textures, buttons unclickable and window unmovable in layout editor, put the code from
kaloel wrote: Sun Sep 06, 2020 10:10 amFirst some indentation:

Code: Select all

...
after the last line of MGRemix.lua

Re: MGRemix lags fix

Posted: Thu Apr 15, 2021 12:26 pm
by Eisboleas
lolwut wrote: Sun Nov 15, 2020 3:49 am If this fix makes MGR window shown with different textures, buttons unclickable and window unmovable in layout editor, put the code from
kaloel wrote: Sun Sep 06, 2020 10:10 amFirst some indentation:

Code: Select all

...
after the last line of MGRemix.lua
Doesnt seem to work for me, any idea ?