reset234567890

qqq

May 27th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.40 KB | None | 0 0
  1. -- This script has convert to FE by who i don't know?
  2.  
  3. -----------------------------------------------------
  4. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  5. local Player,game,owner = owner,game
  6. local RealPlayer = Player
  7. do
  8. print("FE Compatibility code by Mokiros | Showcase by Bacon Hair!")
  9. local rp = RealPlayer
  10. script.Parent = rp.Character
  11.  
  12. --RemoteEvent for communicating
  13. local Event = Instance.new("RemoteEvent")
  14. Event.Name = "UserInput_Event"
  15.  
  16. --Fake event to make stuff like Mouse.KeyDown work
  17. local function fakeEvent()
  18. local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
  19. t.connect = t.Connect
  20. return t
  21. end
  22.  
  23. --Creating fake input objects with fake variables
  24. local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  25. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  26. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  27. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  28. end}
  29. --Merged 2 functions into one by checking amount of arguments
  30. CAS.UnbindAction = CAS.BindAction
  31.  
  32. --This function will trigger the events that have been :Connect()'ed
  33. local function te(self,ev,...)
  34. local t = m[ev]
  35. if t and t._fakeEvent then
  36. for _,f in pairs(t.Functions) do
  37. f(...)
  38. end
  39. end
  40. end
  41. m.TrigEvent = te
  42. UIS.TrigEvent = te
  43.  
  44. Event.OnServerEvent:Connect(function(plr,io)
  45. if plr~=rp then return end
  46. m.Target = io.Target
  47. m.Hit = io.Hit
  48. if not io.isMouse then
  49. local b = io.UserInputState == Enum.UserInputState.Begin
  50. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  51. return m:TrigEvent(b and "Button1Down" or "Button1Up")
  52. end
  53. for _,t in pairs(CAS.Actions) do
  54. for _,k in pairs(t.Keys) do
  55. if k==io.KeyCode then
  56. t.Function(t.Name,io.UserInputState,io)
  57. end
  58. end
  59. end
  60. m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  61. UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  62. end
  63. end)
  64. Event.Parent = NLS([==[
  65. local Player = game:GetService("Players").LocalPlayer
  66. local Event = script:WaitForChild("UserInput_Event")
  67.  
  68. local Mouse = Player:GetMouse()
  69. local UIS = game:GetService("UserInputService")
  70. local input = function(io,a)
  71. if a then return end
  72. --Since InputObject is a client-side instance, we create and pass table instead
  73. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  74. end
  75. UIS.InputBegan:Connect(input)
  76. UIS.InputEnded:Connect(input)
  77.  
  78. local h,t
  79. --Give the server mouse data 30 times every second, but only if the values changed
  80. --If player is not moving their mouse, client won't fire events
  81. while wait(1/30) do
  82. if h~=Mouse.Hit or t~=Mouse.Target then
  83. h,t=Mouse.Hit,Mouse.Target
  84. Event:FireServer({isMouse=true,Target=t,Hit=h})
  85. end
  86. end]==],Player.Character)
  87.  
  88. ----Sandboxed game object that allows the usage of client-side methods and services
  89. --Real game object
  90. local _rg = game
  91.  
  92. --Metatable for fake service
  93. local fsmt = {
  94. __index = function(self,k)
  95. local s = rawget(self,"_RealService")
  96. if s then return s[k] end
  97. end,
  98. __newindex = function(self,k,v)
  99. local s = rawget(self,"_RealService")
  100. if s then s[k]=v end
  101. end,
  102. __call = function(self,...)
  103. local s = rawget(self,"_RealService")
  104. if s then return s(...) end
  105. end
  106. }
  107. local function FakeService(t,RealService)
  108. t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
  109. return setmetatable(t,fsmt)
  110. end
  111.  
  112. --Fake game object
  113. local g = {
  114. GetService = function(self,s)
  115. return self[s]
  116. end,
  117. Players = FakeService({
  118. LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
  119. },"Players"),
  120. UserInputService = FakeService(UIS,"UserInputService"),
  121. ContextActionService = FakeService(CAS,"ContextActionService"),
  122. }
  123. rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
  124. g.service = g.GetService
  125.  
  126. g.RunService = FakeService({
  127. RenderStepped = _rg:GetService("RunService").Heartbeat,
  128. BindToRenderStep = function(self,name,_,fun)
  129.  
  130. end,
  131. UnbindFromRenderStep = function(self,name)
  132. self._btrs[name]:Disconnect()
  133. end,
  134. },"RunService")
  135.  
  136. setmetatable(g,{
  137. __index=function(self,s)
  138. return _rg:GetService(s) or typeof(_rg[s])=="function"
  139. and function(_,...)return _rg[s](_rg,...)end or _rg[s]
  140. end,
  141. __newindex = fsmt.__newindex,
  142. __call = fsmt.__call
  143. })
  144. --Changing owner to fake player object to support owner:GetMouse()
  145. game,owner = g,g.Players.LocalPlayer
  146. end
  147.  
  148. lp=game.Players.LocalPlayer
  149. local Tool = Instance.new('HopperBin',lp.Backpack)
  150. Tool.Name='Don't press 1'
  151. lp=game.Players.LocalPlayer
  152. local Tool = Instance.new('HopperBin',lp.Backpack)
  153. Tool.Name='MoveSun'
  154.  
  155. -- convert number (in hours) to TimeOfDay string
  156. -- because TimeOfDay doesn't cast numbers as expected (3.7 -> 03:07:00 instead of 3:42:00)
  157. local function ToTimeOfDay(n)
  158. n = n % 24
  159. local i,f = math.modf(n)
  160. local m = f*60
  161. local mi,mf = math.modf(m)
  162. m = tostring(math.abs(math.floor(m)))
  163. local s = tostring(math.abs(math.floor(mf*60)))
  164. return i..":"..string.rep("0",2-#m)..m..":"..string.rep("0",2-#s)..s
  165. end
  166.  
  167. -- convert TimeOfDay string to number (in hours)
  168. local function FromTimeOfDay(t)
  169. local signed,h,m,s = t:match("^(%-?)(%d+):(%d+):(%d+)$")
  170. s = tonumber(s)/60
  171. m = tonumber(m + s)/60
  172. h = tonumber(h) + m
  173. return h * (#signed > 0 and -1 or 1)
  174. end
  175.  
  176. local function rad_sc(n)
  177. return n/(math.pi*2)
  178. end
  179.  
  180. local function sc_rad(n)
  181. return n*(math.pi*2)
  182. end
  183.  
  184. -- convert direction to latitude (as GeographicLatitude) and longitude (as TimeOfDay)
  185. local function ToLatLon(d)
  186. d = Vector3.new(-d.x,-d.y,d.z) -- derp derp derp derp derp
  187. local lat = math.atan2(d.z,math.sqrt(d.x^2 + d.y^2))
  188. local lon = math.atan2(d.y,d.x)
  189.  
  190. lat = rad_sc(lat)*360 + 23.5
  191. lon = ToTimeOfDay(rad_sc(lon)*24 - 6)
  192.  
  193. return lat,lon
  194. end
  195.  
  196. --[[
  197. -- convert lat and lon to direction (doesn't work)
  198. local function to_dir(lat,lon)
  199. lat = sc_rad((lat - 23.5)/360)
  200. lon = sc_rad((FromTimeOfDay(lon) + 6)/24)
  201.  
  202. return Vector3.new(
  203. (math.cos(lat)*math.cos(lon)),
  204. (math.cos(lat)*math.sin(lon)),
  205. math.sin(lat)
  206. )
  207. end
  208. ]]
  209.  
  210. local Event = {}
  211. local function Disconnect(...)
  212. for _,name in pairs{...} do
  213. if Event[name] then
  214. Event[name]:disconnect()
  215. Event[name] = nil
  216. end
  217. end
  218. end
  219.  
  220. local Lighting = Game:GetService("Lighting")
  221. local down = false
  222.  
  223. local P = 0.02
  224. local D = 16
  225. local position = Lighting:GetSunDirection()
  226. local velocity = Vector3.new(0,0,0)
  227. local goal = Lighting:GetSunDirection()
  228.  
  229. local active = false
  230. local function Activate(Mouse)
  231. position = Lighting:GetSunDirection()
  232. goal = Lighting:GetSunDirection()
  233. active = true
  234. Event.Down = Mouse.Button1Down:connect(function()
  235. down = true
  236. goal = Mouse.UnitRay.Direction
  237. end)
  238.  
  239. Event.Up = Mouse.Button1Up:connect(function()
  240. down = false
  241. end)
  242.  
  243. Event.Move = Mouse.Move:connect(function()
  244. if down then
  245. goal = Mouse.UnitRay.Direction
  246. end
  247. end)
  248.  
  249. asd = game:GetService'RunService'.RenderStepped:connect(function()
  250. velocity = Vector3.new(
  251. velocity.x + P * ((goal.x - position.x) + D * -velocity.x),
  252. velocity.y + P * ((goal.y - position.y) + D * -velocity.y),
  253. velocity.z + P * ((goal.z - position.z) + D * -velocity.z)
  254. )
  255. position = position + velocity
  256. local lat,lon = ToLatLon(position)
  257. Lighting.GeographicLatitude = lat
  258. Lighting.TimeOfDay = lon
  259. --print(lon)
  260. --wait()
  261. end)
  262. end
  263.  
  264. local function Deactivate()
  265. active = false
  266. down = false
  267. asd:disconnect()
  268. Disconnect("Down","Up","Move")
  269. end
  270.  
  271. Tool.Selected:connect(Activate)
  272. Tool.Deselected:connect(Deactivate)
  273. -- convert number (in hours) to TimeOfDay string
  274. -- because TimeOfDay doesn't cast numbers as expected (3.7 -> 03:07:00 instead of 3:42:00)
  275. local function ToTimeOfDay(n)
  276. n = n % 24
  277. local i,f = math.modf(n)
  278. local m = f*60
  279. local mi,mf = math.modf(m)
  280. m = tostring(math.abs(math.floor(m)))
  281. local s = tostring(math.abs(math.floor(mf*60)))
  282. return i..":"..string.rep("0",2-#m)..m..":"..string.rep("0",2-#s)..s
  283. end
  284.  
  285. -- convert TimeOfDay string to number (in hours)
  286. local function FromTimeOfDay(t)
  287. local signed,h,m,s = t:match("^(%-?)(%d+):(%d+):(%d+)$")
  288. s = tonumber(s)/60
  289. m = tonumber(m + s)/60
  290. h = tonumber(h) + m
  291. return h * (#signed > 0 and -1 or 1)
  292. end
  293.  
  294. local function rad_sc(n)
  295. return n/(math.pi*2)
  296. end
  297.  
  298. local function sc_rad(n)
  299. return n*(math.pi*2)
  300. end
  301.  
  302. -- convert direction to latitude (as GeographicLatitude) and longitude (as TimeOfDay)
  303. local function ToLatLon(d)
  304. d = Vector3.new(-d.x,-d.y,d.z) -- derp derp derp derp derp
  305. local lat = math.atan2(d.z,math.sqrt(d.x^2 + d.y^2))
  306. local lon = math.atan2(d.y,d.x)
  307.  
  308. lat = rad_sc(lat)*360 + 23.5
  309. lon = ToTimeOfDay(rad_sc(lon)*24 - 6)
  310.  
  311. return lat,lon
  312. end
  313.  
  314. --[[
  315. -- convert lat and lon to direction (doesn't work)
  316. local function to_dir(lat,lon)
  317. lat = sc_rad((lat - 23.5)/360)
  318. lon = sc_rad((FromTimeOfDay(lon) + 6)/24)
  319.  
  320. return Vector3.new(
  321. (math.cos(lat)*math.cos(lon)),
  322. (math.cos(lat)*math.sin(lon)),
  323. math.sin(lat)
  324. )
  325. end
  326. ]]
  327.  
  328. local Event = {}
  329. local function Disconnect(...)
  330. for _,name in pairs{...} do
  331. if Event[name] then
  332. Event[name]:disconnect()
  333. Event[name] = nil
  334. end
  335. end
  336. end
  337.  
  338. local Lighting = Game:GetService("Lighting")
  339. local down = false
  340.  
  341. local P = 0.02
  342. local D = 16
  343. local position = Lighting:GetSunDirection()
  344. local velocity = Vector3.new(0,0,0)
  345. local goal = Lighting:GetSunDirection()
  346.  
  347. local active = false
  348. local function Activate(Mouse)
  349. position = Lighting:GetSunDirection()
  350. goal = Lighting:GetSunDirection()
  351. active = true
  352. Event.Down = Mouse.Button1Down:connect(function()
  353. down = true
  354. goal = Mouse.UnitRay.Direction
  355. end)
  356.  
  357. Event.Up = Mouse.Button1Up:connect(function()
  358. down = false
  359. end)
  360.  
  361. Event.Move = Mouse.Move:connect(function()
  362. if down then
  363. goal = Mouse.UnitRay.Direction
  364. end
  365. end)
  366.  
  367. asd = game:GetService'RunService'.RenderStepped:connect(function()
  368. velocity = Vector3.new(
  369. velocity.x + P * ((goal.x - position.x) + D * -velocity.x),
  370. velocity.y + P * ((goal.y - position.y) + D * -velocity.y),
  371. velocity.z + P * ((goal.z - position.z) + D * -velocity.z)
  372. )
  373. position = position + velocity
  374. local lat,lon = ToLatLon(position)
  375. Lighting.GeographicLatitude = lat
  376. Lighting.TimeOfDay = lon
  377. --print(lon)
  378. --wait()
  379. end)
  380. end
  381.  
  382. local function Deactivate()
  383. active = false
  384. down = false
  385. asd:disconnect()
  386. Disconnect("Down","Up","Move")
  387. end
  388.  
  389. Tool.Selected:connect(Activate)
  390. Tool.Deselected:connect(Deactivate)
Advertisement
Add Comment
Please, Sign In to add comment