Advertisement
Guest User

Extra Equip Slots patch

a guest
Apr 20th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. local _G = GLOBAL
  2. if _G.rawget(_G,"EQUIPSLOT_IDS") ~= nil then
  3.     local new = {"back", "neck"}
  4.     local slots = #_G.EQUIPSLOT_IDS
  5.     for i, v in ipairs(new) do
  6.         if _G.EQUIPSLOT_IDS[v] == nil then
  7.             slots = slots + 1
  8.             _G.EQUIPSLOT_IDS[v] = slots
  9.         end
  10.     end
  11.    
  12.     local FindUpvalue = function(fn, upvalue_name, member_check, no_print)
  13.         local info = _G.debug.getinfo(fn, "u")
  14.         local nups = info and info.nups
  15.         if not nups then return end
  16.         local getupvalue = _G.debug.getupvalue
  17.         local s = ''
  18.         for i = 1, nups do
  19.             local name, val = getupvalue(fn, i)
  20.             s = s .. "\t" .. name .. ": " .. type(val) .. "\n"
  21.             if (name == upvalue_name)
  22.                 and ((not member_check) or (type(val)=="table" and val[member_check] ~= nil))
  23.             then
  24.                 return val, true
  25.             end
  26.         end
  27.         if no_print == nil then
  28.             print("CRITICAL ERROR: Can't find variable "..tostring(upvalue_name).."!")
  29.             print(s)
  30.         end
  31.     end
  32.    
  33.     local replica = GLOBAL.require "components/equippable_replica"
  34.     local EQUIPSLOT_NAMES = FindUpvalue(replica.EquipSlot, "EQUIPSLOT_NAMES", 1)
  35.     local EQUIPSLOT_IDS = FindUpvalue(replica.SetEquipSlot, "EQUIPSLOT_IDS", "head")
  36.     if EQUIPSLOT_NAMES == nil or EQUIPSLOT_IDS == nil then
  37.         print("EXTRA EQUIP SLOTS ERROR")
  38.         return
  39.     else
  40.         for j,v in ipairs(_G.EQUIPSLOT_IDS) do
  41.             EQUIPSLOT_NAMES[j] = v
  42.             EQUIPSLOT_IDS[v] = j
  43.         end
  44.     end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement