Hiranus icon

LimitsFromFile

Hiranus | PRO | 06/17/19 11:27:46 AM UTC | 0 ⭐ | 354 👁️ | Never ⏰ | []
Lua |

840 B

|

None

|

0 👍

/

0 👎

local LimitsFile= "Limits.json";
local Limits = nil;
local LimitsIndexed = nil;
 
function RefreshLimits()
  if Limits == nil then
    Limits= JsonSaveLoad.Load(LimitsFile);
    for i=1,#Limits do
      local item = Limits[i];
      local id = item.Fingerprint.id;
      if LimitsIndexed[id] == nil then
        LimitsIndexed[id] = {};
      end
      LimitsIndexed[id][#LimitsIndexed[id] + 1] = item;
    end
  end
end
 
function GetLimitForItem(fingerprint)
  local limits = LimitsIndexed[fingerprint.id];
  if limits then
    for i=1,#limits do
      local limit = limits[i];
      local limitFingerprint = limit.Fingerprint;
      if limitFingerprint.id == fingerprint.id and limitFingerprint.dmg == fingerprint.dmg and limitFingerprint.nbt_hash == fingerprint.nbt_hash then
        return limit.Limit;
      end
    end
  end
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎