diet.lua 583 B

1234567891011121314151617181920212223242526272829
  1. hunger.diet = hunger.diet or {}
  2. hunger.diet.players = hunger.diet.players or {}
  3. local players = hunger.diet.players
  4. function hunger.adjust_from_diet(pname, item, def)
  5. local ndef = table.copy(def)
  6. local ctime = os.time()
  7. -- Create and localize player table if not exists.
  8. players[pname] = players[pname] or {}
  9. local info = players[pname]
  10. local ltime = info[item] or 0
  11. info[item] = ctime
  12. -- Barf. You ate too quickly.
  13. if (ctime - ltime) < 1 then
  14. ndef.healing = -1
  15. end
  16. return ndef
  17. end
  18. if not hunger.diet.run_once then
  19. hunger.diet.run_once = true
  20. end