Mata Pancing


SUBMITTED BY: mashelmi

DATE: Dec. 7, 2017, 10:40 a.m.

FORMAT: Text only

SIZE: 3.1 kB

HITS: 663

  1. lp=game.Players.LocalPlayer
  2. local Tool = Instance.new('HopperBin',lp.Backpack)
  3. Tool.Name='MoveSun'
  4. -- convert number (in hours) to TimeOfDay string
  5. -- because TimeOfDay doesn't cast numbers as expected (3.7 -> 03:07:00 instead of 3:42:00)
  6. local function ToTimeOfDay(n)
  7. n = n % 24
  8. local i,f = math.modf(n)
  9. local m = f*60
  10. local mi,mf = math.modf(m)
  11. m = tostring(math.abs(math.floor(m)))
  12. local s = tostring(math.abs(math.floor(mf*60)))
  13. return i..":"..string.rep("0",2-#m)..m..":"..string.rep("0",2-#s)..s
  14. end
  15. -- convert TimeOfDay string to number (in hours)
  16. local function FromTimeOfDay(t)
  17. local signed,h,m,s = t:match("^(%-?)(%d+):(%d+):(%d+)$")
  18. s = tonumber(s)/60
  19. m = tonumber(m + s)/60
  20. h = tonumber(h) + m
  21. return h * (#signed > 0 and -1 or 1)
  22. end
  23. local function rad_sc(n)
  24. return n/(math.pi*2)
  25. end
  26. local function sc_rad(n)
  27. return n*(math.pi*2)
  28. end
  29. -- convert direction to latitude (as GeographicLatitude) and longitude (as TimeOfDay)
  30. local function ToLatLon(d)
  31. d = Vector3.new(-d.x,-d.y,d.z) -- derp derp derp derp derp
  32. local lat = math.atan2(d.z,math.sqrt(d.x^2 + d.y^2))
  33. local lon = math.atan2(d.y,d.x)
  34. lat = rad_sc(lat)*360 + 23.5
  35. lon = ToTimeOfDay(rad_sc(lon)*24 - 6)
  36. return lat,lon
  37. end
  38. --[[
  39. -- convert lat and lon to direction (doesn't work)
  40. local function to_dir(lat,lon)
  41. lat = sc_rad((lat - 23.5)/360)
  42. lon = sc_rad((FromTimeOfDay(lon) + 6)/24)
  43. return Vector3.new(
  44. (math.cos(lat)*math.cos(lon)),
  45. (math.cos(lat)*math.sin(lon)),
  46. math.sin(lat)
  47. )
  48. end
  49. ]]
  50. local Event = {}
  51. local function Disconnect(...)
  52. for _,name in pairs{...} do
  53. if Event[name] then
  54. Event[name]:disconnect()
  55. Event[name] = nil
  56. end
  57. end
  58. end
  59. local Lighting = Game:GetService("Lighting")
  60. local down = false
  61. local P = 0.02
  62. local D = 16
  63. local position = Lighting:GetSunDirection()
  64. local velocity = Vector3.new(0,0,0)
  65. local goal = Lighting:GetSunDirection()
  66. local active = false
  67. local function Activate(Mouse)
  68. position = Lighting:GetSunDirection()
  69. goal = Lighting:GetSunDirection()
  70. active = true
  71. Event.Down = Mouse.Button1Down:connect(function()
  72. down = true
  73. goal = Mouse.UnitRay.Direction
  74. end)
  75. Event.Up = Mouse.Button1Up:connect(function()
  76. down = false
  77. end)
  78. Event.Move = Mouse.Move:connect(function()
  79. if down then
  80. goal = Mouse.UnitRay.Direction
  81. end
  82. end)
  83. asd = game:GetService'RunService'.RenderStepped:connect(function()
  84. velocity = Vector3.new(
  85. velocity.x + P * ((goal.x - position.x) + D * -velocity.x),
  86. velocity.y + P * ((goal.y - position.y) + D * -velocity.y),
  87. velocity.z + P * ((goal.z - position.z) + D * -velocity.z)
  88. )
  89. position = position + velocity
  90. local lat,lon = ToLatLon(position)
  91. Lighting.GeographicLatitude = lat
  92. Lighting.TimeOfDay = lon
  93. --print(lon)
  94. --wait()
  95. end)
  96. end
  97. local function Deactivate()
  98. active = false
  99. down = false
  100. asd:disconnect()
  101. Disconnect("Down","Up","Move")
  102. end
  103. Tool.Selected:connect(Activate)
  104. Tool.Deselected:connect(Deactivate)

comments powered by Disqus