Guest User

Brighter Dusks Refactoring

a guest
Aug 4th, 2022
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. GLOBAL.setmetatable(env, {__index=function(t,k) return GLOBAL.rawget(GLOBAL,k) end})
  2. --> That's is just a merge of mod env and global env
  3. ------------------------------------------------------------------------------------
  4.  
  5. local UpvalueHacker = require("tools/upvaluehacker")
  6.  
  7. local function RGB(n)
  8.     return Point(n/255, n/255, n/255)
  9. end
  10.  
  11. local INTERIOR_COLOUR = RGB(0)
  12. local DUSK_COLOUR = RGB(150)
  13.  
  14. --> Your if statement was checking if the game was on the hamlet map,
  15. -- so interiors outside the hamlet map got weird light at dusk
  16. local function GetDuskColour()
  17.     return TheCamera.interior and INTERIOR_COLOUR or DUSK_COLOUR
  18. end
  19.  
  20. --> I also removed the spring color change, as in the game it is not applied (at least in the hamlet and other files I looked at)
  21.  
  22. local function SetGetDuskColour(initial_fn)
  23.     if initial_fn then
  24.         UpvalueHacker.SetUpvalue(initial_fn, GetDuskColour, "GetDuskColour")
  25.     end
  26. end
  27.  
  28. AddComponentPostInit("clock", function(self)
  29.     self.duskColour = DUSK_COLOUR
  30.  
  31.     SetGetDuskColour(self.OnUpdate) --Here I set the new function to all places where it was used, instead of just in StartDusk.
  32.     SetGetDuskColour(self.StartDusk)
  33.     SetGetDuskColour(self.LongUpdate)
  34.     SetGetDuskColour(self.updateAmibentColor)
  35. end)
  36.  
  37. local RBG = nil
  38. local UpvalueHacker = nil
  39. local SetGetDuskColour = nil
Advertisement
Add Comment
Please, Sign In to add comment