Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tfm.exec.disableAutoNewGame(true)
- local map = '@6214583'
- local level = 1
- local loss = 1
- local height = 20
- local branchwidth = 10
- local joint = {alpha = 0.1, foreground = true}
- joint.color = 0x2BFF07
- local id = 0
- local args = {400,760,0,-1,height}
- local togrow = {}
- local growtime = os.time()*565
- local color = {0xFFFFFF, 0xEFEFEF, 0xE0E0E0, 0xC4C4C4, 0xA6A6A6, 0x8B8B8B, 0x6F6F6F, 0x3F3F3F, 0x2F2F2F}
- local colorid = 1
- cmds = {'new','stop','start'}
- for _, cm in pairs(cmds) do
- system.disableChatCommandDisplay(cm, true)
- end
- function grow(x,y,dx,dy,w,isbranch)
- id = id+1
- width = w-level*loss;
- math.randomseed(math.random(0x0000, 0xFFFF)*os.time())
- joint.line = width
- joint.alpha = joint.alpha+0.1
- if joint.alpha > 1 then
- joint.alpha = 0.1
- end
- colorid = colorid+1
- if colorid > #color then
- colorid = 1
- end
- joint.color = color[colorid]
- level = level+1
- joint.point1 = x..','..y
- x = x+dx
- y = y+dy
- dx = math.ceil(dx+math.sin(math.random()+level)*branchwidth)
- dy = math.floor(dy+math.cos(math.random()+level)*branchwidth)
- args = {x,y,dx,dy,w}
- joint.point2 = x..','..y
- tfm.exec.addJoint(id, 1, 1, joint)
- perc = math.random(0, 100)
- if level > 5 then
- if perc < 60 and width > 1 then
- table.insert(togrow, {x, y, 4, (width/2)+(width/3)})
- end
- end
- if width > 0 then
- grow(args[1],args[2],args[3],args[4],args[5], isbranch)
- end
- end
- function eventChatCommand(player, cmd)
- if cmd == "start" then
- growtime = os.time()
- elseif cmd == "stop" then
- growtime = os.time()*5665
- elseif cmd == "new" then
- growtime = os.time()*5665
- togrow = {}
- level = 1
- args = {400,760,0,-1,40}
- newTree()
- end
- end
- function newgrow()
- if (#togrow > 1) then
- d = math.random(#togrow)
- ar = togrow[d]
- table.remove(togrow, d)
- grow(ar[1], ar[2], math.floor(2*math.sin(math.random()+ar[3])), math.ceil(2*math.cos(math.random()+ar[3])), ar[4]+level, true);
- end
- end
- function eventLoop()
- if growtime < os.time()-1000 then
- newgrow()
- growtime = os.time()
- end
- end
- function newTree()
- for x = 400,0, -1 do
- tfm.exec.removeJoint(x)
- end
- tfm.exec.addPhysicObject(1, 200, 400, {type = 12})
- grow(args[1],args[2],args[3],args[4],args[5], false)
- end
- tfm.exec.newGame(map)
- newTree()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement