|
| 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 |
|
| |