generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Generate Terrain Plugin - Scripting Help

Previous Thread :: Next Thread 
Dr3w99Dr3w is not online. Dr3w99Dr3w
Joined: 10 Nov 2011
Total Posts: 30
26 Nov 2013 05:02 PM
Hey, i just need help getting this Lua script to work. It is a pre-made script, mixed with the plugin creation part at the top. i think it just needs minor editing, but I;m not entire sure because I am a beginner to Lua AND scripting. So here it is:

PluginManager ()
:CreatePlugin ()
:CreateToolbar ("Terrain")
:CreateButton(
"Print Hello World",
"Click this button to generate terrain!",
"Tree.png"
).Click:connect(function())
print("Generating Terrain!")
local fluct = math.random(0,100)
local dampen = math.random(0,1)
local node = Vector3.new()
local width = 10
local bredth = 10

_G.DS = {}
_G.rand = function(hi, lo)
return math.random(hi*100, lo*100)/100
end

function DS.new(x, y, self)
if type(x) == "table" then x, y, self = y, self, x end
local nw = {}
function nw.get(x, y)
local row = nw[x] or {}
return row[y]
end
function nw.set(x, y, val)
local row = nw[x] or {}
row[y] = val
nw[x] = row
end
return nw
end

wait(rand(0, 1))

local pts = DS.new()
pts.set(-(width+1), -(bredth+1), rand(0, 30))
x = -(width+1)

for y = -bredth, bredth do
pts.set(x, y, pts.get(x, y-1) + rand(-fluct, fluct)*0.75)
end

for x = -width, width do
for y = -bredth, bredth do
local lastrow = pts.get(x-1, y)
if x % 2 == 0 then
lastrow = ((pts.get(x-1, y-1) or lastrow) + lastrow)/2
else
lastrow = ((pts.get(x-1, y+1) or lastrow) + lastrow)/2
end
local last = pts.get(x, y-1) or lastrow
local h = last + rand(-fluct, fluct)
h = h - (h - lastrow)*dampen
pts.set(x, y, h)
end
end

clone = true

function add(p)
if clone then
clone = false
script._Utility:clone().Parent = p
end
end
for x = -width, width do
for y = -bredth, bredth do
if pts.get(x, y) then
local p = Instance.new("SpawnLocation")
p.Position = Vector3.new(x*10, 0, y*10)
p.FormFactor = 0
p.Anchored = true
p.Parent = game.Workspace
add(p)
p.Size = Vector3.new(10, math.abs(pts.get(x, y)), 10)
p.BrickColor = BrickColor.new(math.ceil(p.Size.y/5))
wait()
end
end
end
Report Abuse
Dr3w99Dr3w is not online. Dr3w99Dr3w
Joined: 10 Nov 2011
Total Posts: 30
27 Nov 2013 10:17 AM
Bump.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image