Advertisement
Guest User

Refactored B&A

a guest
Jul 22nd, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. require = GLOBAL.require
  2. local PlayerHUD = require "screens/playerhud"
  3.  
  4. Assets =
  5. {
  6.     Asset("ATLAS", "images/newslots.xml"),
  7. }
  8.  
  9. function backpackpostinit(inst)
  10.     inst.components.equippable.equipslot = GLOBAL.EQUIPSLOTS.BACK
  11. end
  12.  
  13. function amuletpostinit(inst)
  14.     inst.components.equippable.equipslot = GLOBAL.EQUIPSLOTS.NECK
  15. end
  16.  
  17. function inventorypostinit(component,inst)
  18.     inst.components.inventory.numequipslots = 5
  19. end
  20.  
  21. AddPrefabPostInit("amulet", amuletpostinit)
  22. AddPrefabPostInit("blueamulet", amuletpostinit)
  23. AddPrefabPostInit("purpleamulet", amuletpostinit)
  24. AddPrefabPostInit("orangeamulet", amuletpostinit)
  25. AddPrefabPostInit("greenamulet", amuletpostinit)
  26. AddPrefabPostInit("yellowamulet", amuletpostinit)
  27. AddComponentPostInit("inventory", inventorypostinit)
  28. AddPrefabPostInit("backpack", backpackpostinit)
  29. AddPrefabPostInit("krampus_sack", backpackpostinit)
  30. AddPrefabPostInit("piggyback", backpackpostinit)
  31. AddPrefabPostInit("icepack", backpackpostinit)
  32.  
  33. table.insert(GLOBAL.EQUIPSLOTS, "BACK")
  34. GLOBAL.EQUIPSLOTS.BACK = "back"
  35. table.insert(GLOBAL.EQUIPSLOTS, "NECK")
  36. GLOBAL.EQUIPSLOTS.NECK = "neck"
  37.  
  38. local oldSetMainCharacter = PlayerHUD.SetMainCharacter
  39. function PlayerHUD:SetMainCharacter(maincharacter)
  40.     local result = oldSetMainCharacter(self, maincharacter)
  41.  
  42.     self.controls.inv:AddEquipSlot(GLOBAL.EQUIPSLOTS.BACK, "images/newslots.xml", "back.tex")
  43.     self.controls.inv:AddEquipSlot(GLOBAL.EQUIPSLOTS.NECK, "images/newslots.xml", "neck.tex")
  44.     self.controls.inv.bg:SetScale(1.25,1,1.25)
  45.  
  46.     local bp = maincharacter.components.inventory:GetEquippedItem(GLOBAL.EQUIPSLOTS.BACK)
  47.     if bp and bp.components.container then
  48.         bp.components.container:Close()
  49.         bp.components.container:Open(maincharacter)
  50.     end
  51.  
  52.     return result
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement