Advertisement
RCAProduction

woodRewrite2.lua

Sep 29th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. --INIT
  2. maxT=400
  3. R=254
  4. G=215
  5. B=161
  6.  
  7. --Scale Factor, 1 = no scale
  8. adjustVal=1
  9.  
  10. --Range loop, finds range of TMPs on the screen from 400
  11. for i in sim.parts(i) do
  12.     if sim.partProperty(i,"type")==17 and sim.partProperty(i,"tmp")>maxT then
  13.         maxT=sim.partProperty(i,"tmp")
  14.     end
  15. end
  16.  
  17. --Range calculations
  18. range=(maxT-400)*adjustVal
  19. dsizeR=range/R
  20. dsizeG=range/G
  21. dsizeB=range/B
  22.  
  23. --Set dcolour
  24. for i in sim.parts(i) do
  25.     if sim.partProperty(i,"type")==17 then
  26.         if sim.partProperty(i,"tmp")<=0 then
  27.             color=0xFF000000+(0x0010000*R)+(0x00000100*G)+(0x00000001*B)
  28.         else
  29.             color=0xFF000000+((0x00000001)*(B-(math.floor((sim.partProperty(i,"tmp")-400)/dsizeB))))+((0x00000100)*(G-(math.floor((sim.partProperty(i,"tmp")-400)/dsizeG))))+((0x00010000)*(R-(math.floor((sim.partProperty(i,"tmp")-400)/dsizeR))))
  30.  
  31.         end
  32.  
  33.         sim.partProperty(i, "dcolour", color)
  34.     end
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement