Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. -- start with this:
  2. local InventoryAmmo = (player.inventory[player.equipment.ammo].count or 0)
  3.  
  4. -- break it up into this:
  5. local inventory = player.inventory
  6. local equipment = player.equipement
  7. local ammo = equipment.ammo
  8. local temp = inventory[ammo]
  9. local count = temp.count
  10. local InventoryAmmo = count or 0
  11.  
  12. -- the error happens at count = temp.count, so temp must be nil. fix it by adding "or {}"
  13. local inventory = player.inventory
  14. local equipment = player.equipement
  15. local ammo = equipment.ammo
  16. local temp = inventory[ammo] or {}
  17. local count = temp.count
  18. local InventoryAmmo = count or 0
  19.  
  20. -- replace count:
  21. local InventoryAmmo = temp.count or 0
  22.  
  23. -- replace temp, in order to make it work you have to add parens:
  24. local InventoryAmmo = (inventory[ammo] or {}).count or 0
  25.  
  26. -- and then the rest is easy:
  27. local InventoryAmmo = (player.inventory[player.equipement.ammo] or {}).count or 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement