Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. AddPrefabPostInit("your_character",function(inst)
  2.  
  3.     inst.temperature_bonus = 0.2  -- Means +20%
  4.  
  5.     local save_ignore_temp
  6.     inst:ListenForEvent("temperaturedelta",function(inst,data)
  7.         if save_ignore_temp then
  8.             save_ignore_temp = false --Skip this event.
  9.         else
  10.             local delta = data.new - data.last
  11.             local bonus_delta = delta * inst.temperature_bonus
  12.             if bonus_delta ~= 0 then
  13.                 save_ignore_temp = true
  14.                 --Will cause the event again, we should skip it.
  15.                 inst.components.temperature:DoDelta(bonus_delta)
  16.             end
  17.         end
  18.     end)
  19.    
  20. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement