Advertisement
DarkScriptZEditors

Untitled

Feb 12th, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.14 KB | None | 0 0
  1.  
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,game,owner = owner,game
  4. local RealPlayer = Player
  5. do
  6. print("FE Compatibility code V2 by Mokiros")
  7. local RealPlayer = RealPlayer
  8. script.Parent = RealPlayer.Character
  9.  
  10. --Fake event to make stuff like Mouse.KeyDown work
  11. local Disconnect_Function = function(this)
  12. this[1].Functions[this[2]] = nil
  13. end
  14. local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
  15. local FakeEvent_Metatable = {__index={
  16. Connect = function(this,f)
  17. local i = tostring(math.random(0,10000))
  18. while this.Functions[i] do
  19. i = tostring(math.random(0,10000))
  20. end
  21. this.Functions[i] = f
  22. return setmetatable({this,i},Disconnect_Metatable)
  23. end
  24. }}
  25. FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
  26. local function fakeEvent()
  27. return setmetatable({Functions={}},FakeEvent_Metatable)
  28. end
  29.  
  30. --Creating fake input objects with fake variables
  31. local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  32. FakeMouse.keyUp = FakeMouse.KeyUp
  33. FakeMouse.keyDown = FakeMouse.KeyDown
  34. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  35. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  36. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  37. end}
  38. --Merged 2 functions into one by checking amount of arguments
  39. CAS.UnbindAction = CAS.BindAction
  40.  
  41. --This function will trigger the events that have been :Connect()'ed
  42. local function TriggerEvent(self,ev,...)
  43. for _,f in pairs(self[ev].Functions) do
  44. f(...)
  45. end
  46. end
  47. FakeMouse.TriggerEvent = TriggerEvent
  48. UIS.TriggerEvent = TriggerEvent
  49.  
  50. --Client communication
  51. local Event = Instance.new("RemoteEvent")
  52. Event.Name = "UserInput_Event"
  53. Event.OnServerEvent:Connect(function(plr,io)
  54. if plr~=RealPlayer then return end
  55. FakeMouse.Target = io.Target
  56. FakeMouse.Hit = io.Hit
  57. if not io.isMouse then
  58. local b = io.UserInputState == Enum.UserInputState.Begin
  59. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  60. return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
  61. end
  62. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  63. return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
  64. end
  65. for _,t in pairs(CAS.Actions) do
  66. for _,k in pairs(t.Keys) do
  67. if k==io.KeyCode then
  68. t.Function(t.Name,io.UserInputState,io)
  69. end
  70. end
  71. end
  72. FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  73. UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
  74. end
  75. end)
  76. Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
  77. local Mouse = owner:GetMouse()
  78. local UIS = game:GetService("UserInputService")
  79. local input = function(io,RobloxHandled)
  80. if RobloxHandled then return end
  81. --Since InputObject is a client-side instance, we create and pass table instead
  82. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  83. end
  84. UIS.InputBegan:Connect(input)
  85. UIS.InputEnded:Connect(input)
  86. local h,t
  87. --Give the server mouse data every second frame, but only if the values changed
  88. --If player is not moving their mouse, client won't fire events
  89. local HB = game:GetService("RunService").Heartbeat
  90. while true do
  91. if h~=Mouse.Hit or t~=Mouse.Target then
  92. h,t=Mouse.Hit,Mouse.Target
  93. Event:FireServer({isMouse=true,Target=t,Hit=h})
  94. end
  95. --Wait 2 frames
  96. for i=1,2 do
  97. HB:Wait()
  98. end
  99. end]==],script)
  100.  
  101. ----Sandboxed game object that allows the usage of client-side methods and services
  102. --Real game object
  103. local RealGame = game
  104.  
  105. --Metatable for fake service
  106. local FakeService_Metatable = {
  107. __index = function(self,k)
  108. local s = rawget(self,"_RealService")
  109. if s then
  110. return typeof(s[k])=="function"
  111. and function(_,...)return s[k](s,...)end or s[k]
  112. end
  113. end,
  114. __newindex = function(self,k,v)
  115. local s = rawget(self,"_RealService")
  116. if s then s[k]=v end
  117. end
  118. }
  119. local function FakeService(t,RealService)
  120. t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
  121. return setmetatable(t,FakeService_Metatable)
  122. end
  123.  
  124. --Fake game object
  125. local FakeGame = {
  126. GetService = function(self,s)
  127. return rawget(self,s) or RealGame:GetService(s)
  128. end,
  129. Players = FakeService({
  130. LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
  131. },"Players"),
  132. UserInputService = FakeService(UIS,"UserInputService"),
  133. ContextActionService = FakeService(CAS,"ContextActionService"),
  134. RunService = FakeService({
  135. _btrs = {},
  136. RenderStepped = RealGame:GetService("RunService").Heartbeat,
  137. BindToRenderStep = function(self,name,_,fun)
  138. self._btrs[name] = self.Heartbeat:Connect(fun)
  139. end,
  140. UnbindFromRenderStep = function(self,name)
  141. self._btrs[name]:Disconnect()
  142. end,
  143. },"RunService")
  144. }
  145. rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
  146. FakeGame.service = FakeGame.GetService
  147. FakeService(FakeGame,game)
  148. --Changing owner to fake player object to support owner:GetMouse()
  149. game,owner = FakeGame,FakeGame.Players.LocalPlayer
  150. end
  151. local LastPosition = CFrame.new(-70, 0, -40)
  152. local x, y, z = -3, -9, -3
  153. local x1, y1, z1 = 3, -7, 3
  154. local x2, y2, z2 = x, y, z
  155. local t1 = true
  156. while t1 do
  157. for i = 1, 10 do
  158. if y2 > y1 then t1 = false break end
  159. if z2 > z1 then z2 = z y2 = y2 + 1 end
  160. local part = Instance.new("Part", workspace)
  161. part.CanCollide = false
  162. part.Size = Vector3.new(2000, 5, 2000)
  163. part.CFrame = CFrame.new(x2*part.Size.X, y2*-part.Size.Y+1.5, z2*part.Size.Z)
  164. part.Anchored = true
  165. part.Transparency = 0.2
  166. part.Reflectance = 0.6
  167. part.BrickColor = BrickColor.new("Deep blue")
  168. part.BackSurface = "SmoothNoOutlines"
  169. part.FrontSurface = "SmoothNoOutlines"
  170. part.BottomSurface = "SmoothNoOutlines"
  171. part.TopSurface = "SmoothNoOutlines"
  172. part.RightSurface = "SmoothNoOutlines"
  173. part.LeftSurface = "SmoothNoOutlines"
  174. part.Material = "SmoothPlastic"
  175. if x2 > x1 then x2 = x z2 = z2 + 1 end
  176. x2 = x2 + 1
  177. end
  178. wait()
  179. end
  180. local Hills = {
  181. --Hill1 = {
  182. -- Position = CFrame.new(-200, 0, -100);
  183. -- Range = 100;
  184. -- Height = 10;
  185. -- Color = BrickColor.new("Medium stone gray");
  186. -- TreeSpawn = false
  187. --};
  188. --[[
  189. Hill2 = {
  190. Position = Vector3.new(-200, 0, 200);
  191. Range = 250;
  192. Height = 10;
  193. Color = BrickColor.new("Forest green");
  194. };
  195. Hill3 = {
  196. Position = Vector3.new(-200, 0, -200);
  197. Range = 200;
  198. Height = 10;
  199. Color = BrickColor.new("Forest green");
  200. };
  201. Hill4 = {
  202. Position = Vector3.new(200, 0, -200);
  203. Range = 150;
  204. Height = 10;
  205. Color = BrickColor.new("Forest green");
  206. }]]
  207. }
  208. local treemodel = Instance.new("Model", game.Lighting)
  209. local p = Instance.new("Part", treemodel)
  210. local treethickness = math.random(2, 6)
  211. p.BrickColor = BrickColor.new("Dark orange")
  212. p.Size = Vector3.new(treethickness, math.random(4, 20), treethickness)
  213. p.CFrame = CFrame.new(0, 0, 0)
  214. p.Anchored = true
  215. p.Name = "stump"
  216. local p1 = Instance.new("Part", treemodel)
  217. local leavesize = math.random(4, 30)
  218. p1.BrickColor = BrickColor.new("Bright green")
  219. p1.Size = Vector3.new(treethickness + leavesize, leavesize/8, treethickness + leavesize)
  220. p1.CFrame = CFrame.new(0, p.Size.Y/2 + p1.Size.Y/2, 0)
  221. p1.Anchored = true
  222. p1.Name = "bottom_leave"
  223. local p2 = Instance.new("Part", treemodel)
  224. p2.BrickColor = BrickColor.new("Bright green")
  225. p2.Size = Vector3.new(treethickness + leavesize/2, leavesize/8, treethickness + leavesize/2)
  226. p2.CFrame = CFrame.new(0, p.Size.Y/2 + p1.Size.Y + p2.Size.Y/2, 0)
  227. p2.Anchored = true
  228. p2.Name = "top_leave"
  229. local totaltreeheight = p.Size.Y + p1.Size.Y + p2.Size.Y
  230. function minimedrandom(n1min, n1, n2min, n2)
  231. local t = true
  232. local r = 0
  233. while t do
  234. r = math.random(n1, n2)
  235. if r < n1min and r < 0 then
  236. t = false
  237. end
  238. if r > n2min and r > 0 then
  239. t = false
  240. end
  241. end
  242. return r
  243. end
  244. function block1insideblock2(s1, v1, s2, v2) --idk how to call this pff
  245. local block1 = {
  246. Size = s1;
  247. Position = v1
  248. }
  249. local block2 = {
  250. Size = s2;
  251. Position = v2
  252. }
  253. --check if block1 is inside block2
  254. if block1.Position == nil then error("Position at argument #1 is nil") end
  255. if block2.Position == nil then error("Position at argument #3 is nil") end
  256. if block1.Size == nil then error("Size at argument #2 is nil") end
  257. if block2.Size == nil then error("Size at argument #4 is nil") end
  258. if block1.Position.X >= block2.Position.X - block2.Size.X and
  259. block1.Position.X <= block2.Position.X + block2.Size.X and
  260. block1.Position.Z >= block2.Position.Z - block2.Size.Z and
  261. block1.Position.Z <= block2.Position.Z + block2.Size.Z
  262. then
  263. return true
  264. end
  265. return false
  266. end
  267. local tp = true
  268. local parts = {}
  269. for i = 1, math.random(50, 100) do
  270. local newhill = {
  271. Position = CFrame.new(math.random(-3000, 3000), 0, math.random(-3000, 3000));
  272. Range = math.random(100, 300);
  273. Height = math.random(1, 6);
  274. Color = BrickColor.new("Dark green");
  275. DirtColor = BrickColor.new("Rust");
  276. StoneColor = BrickColor.new("Dark stone grey");
  277. TreeSpawn = true;
  278. StoneLand = false
  279. }
  280. if math.random(1, newhill.Height + 1) == 1 then
  281. newhill.StoneLand = true
  282. newhill.TreeSpawn = false
  283. newhill.Color = newhill.StoneColor
  284. newhill.DirtColor = newhill.StoneColor
  285. end
  286. table.insert(Hills, 0, newhill)
  287. end
  288. local max = 1000
  289. local chunks = 0
  290. function MagXZ(x, z)
  291. return x + z
  292. end
  293. while wait() do
  294. function generateblock()
  295. local P
  296. if tp == true then
  297. P = Instance.new("SpawnLocation", workspace)
  298. else
  299. P = Instance.new("Part", workspace)
  300. end
  301. P.Size = Vector3.new(minimedrandom(-80, -30, 30, 80), 1, minimedrandom(-80, -30, 30, 80))
  302. P.CFrame = CFrame.new(math.random(-1, 1)*P.Size.X + LastPosition.X, 50, math.random(-1, 1)*P.Size.Z + LastPosition.Z)
  303. P.Name = "GPart"
  304. --[[for _,p in pairs(parts) do
  305. print(p.Position.X .. ", " .. p.Position.Y .. ", " .. p.Position.Z)
  306. local check = true
  307. if p.Position == nil and p.Size == nil then print("nope nil") check = false end
  308. if check then
  309. if block1insideblock2(p.Size, p.Position, P.Size, P.Position) then
  310. print("A block was way too much inside another block and was deleted.")
  311. P:Destroy()
  312. return
  313. end
  314. end
  315. end]]
  316. --if P:GetConnectedParts() then
  317. -- if P:GetConnectedParts()[1].Name ~= "GPart" then
  318. -- P:Destroy()
  319. -- return
  320. -- end
  321. --end
  322. if math.abs(MagXZ(P.Position.X, P.Position.Z) - MagXZ(LastPosition.X, LastPosition.Z)) >= (P.Size.X + P.Size.Z) then
  323. P:Destroy()
  324. return
  325. end
  326. local oldpos = P.CFrame
  327. local height = 1
  328. local treescanspawn = true
  329. local dirtcolor = BrickColor.new("Rust")
  330. P.BrickColor = BrickColor.new("Dark green")
  331. for _,h in pairs(Hills) do
  332. local closeness = -(P.CFrame.p - h.Position.p).magnitude + h.Range
  333. --local height2 = (Vector3.new(h.Position.X - P.Position.X, 0, h.Position.Z - P.Position.Z).Magnitude/15) - 20
  334. --if height2 < 0 then height2 = 0 end
  335. if h.Range > closeness and closeness > 0 then
  336. height = math.min(h.Height, height) + closeness
  337. P.BrickColor = h.Color
  338. dirtcolor = h.DirtColor
  339. if h.TreeSpawn == false then
  340. treescanspawn = false
  341. end
  342. --print("SUCCESS closeness:" .. closeness)
  343. else
  344. --warn("FAIL closeness:" .. closeness)
  345. end
  346. end
  347. height = height + 100-math.noise(P.CFrame.p.X/10, 6421.1761, P.CFrame.p.Z/10)*30
  348. print(height)
  349. --print(height)
  350. --Add dirt
  351. local PD = Instance.new("Part", workspace)
  352. PD.Size = Vector3.new(P.Size.X - (math.random(1, 50)/100), height - 4, P.Size.Z - (math.random(1, 50)/100))
  353. PD.CFrame = CFrame.new(P.Position.X, 50, P.Position.Z)
  354. PD.BrickColor = dirtcolor
  355. PD.Anchored = true
  356. PD.Name = "Dirt"
  357. --Add grass on top
  358. P.Size = Vector3.new(P.Size.X, 3, P.Size.Z)
  359. P.CFrame = CFrame.new(oldpos.X, oldpos.Y + ((height-4)/2), oldpos.Z)
  360. P.Anchored = true
  361. P.Name = "Grass"
  362. --Add sand
  363. local PS = Instance.new("Part", workspace)
  364. PS.Size = Vector3.new(P.Size.X + 4, 100, P.Size.Z + 4)
  365. PS.CFrame = CFrame.new(P.Position.X, -0.5, P.Position.Z)
  366. PS.BrickColor = BrickColor.new("Cool yellow")
  367. PS.Anchored = true
  368. PS.Name = "Sand"
  369. --Add underbase
  370. local PB = Instance.new("Part", workspace)
  371. PB.Size = Vector3.new(PS.Size.X + 4, PS.Size.Y - 2, PS.Size.Z + 4)
  372. PB.CFrame = CFrame.new(PS.Position.X, -0.5, PS.Position.Z)
  373. PB.BrickColor = BrickColor.new("Dark stone grey")
  374. PB.Anchored = true
  375. PB.Name = "UnderBase"
  376. if tp == true then
  377. tp = false
  378. for _,p in pairs(workspace:GetChildren()) do
  379. if game.Players:FindFirstChild(p.Name) then
  380. p:MoveTo(Vector3.new(P.Position.X + math.random(-P.Size.X/2, P.Size.X/2), P.Position.Y + 5, P.Position.Z + math.random(-P.Size.Z/2, P.Size.Z/2)))
  381. end
  382. end
  383. end
  384. if treescanspawn == true and math.random(1, 6) == 6 then
  385. for i = 1, math.random(1, 4) do
  386. local tree = treemodel:Clone()
  387. tree.Parent = workspace
  388. tree.stump.CFrame = CFrame.new(P.Position.X + math.random(-P.Size.X/2, P.Size.X/2), P.Position.Y + P.Size.Y/2 + tree.stump.Size.Y/2, P.Position.Z + math.random(-P.Size.Z/2, P.Size.Z/2))
  389. tree.bottom_leave.CFrame = CFrame.new(tree.stump.Position.X, tree.stump.Position.Y + tree.stump.Size.Y/2 + tree.bottom_leave.Size.Y/2, tree.stump.Position.Z)
  390. tree.top_leave.CFrame = CFrame.new(tree.stump.Position.X, tree.bottom_leave.Position.Y + tree.bottom_leave.Size.Y/2 + tree.top_leave.Size.Y/2, tree.stump.Position.Z)
  391. tree.stump.Parent = workspace
  392. tree.bottom_leave.Parent = workspace
  393. tree.top_leave.Parent = workspace
  394. tree:Destroy()
  395. end
  396. end
  397. table.insert(parts, 0, {
  398. P.Size;
  399. P.Position
  400. })
  401. --print(P.Position.Z .. ", " .. P.Position.Y .. ", " .. P.Position.Z)
  402. LastPosition = P.Position
  403. print(math.noise(LastPosition.X - P.Position.X/100, LastPosition.Y - P.Position.Y/100, LastPosition.Z - P.Position.Z/100))
  404. end
  405. generateblock()
  406. if chunks >= max then break end
  407. chunks = chunks + 1
  408. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement