Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tfm.exec.disableAutoNewGame(true)
- local map = '@6219515'
- local level = 1
- local loss = 1
- local height = 30
- local branchwidth = 5
- local joint = {alpha = 0.9, foreground = true, color = 0xFFFFFF}
- local id = 0
- local args = {400,760,0,-1,height}
- local togrow = {}
- local growtime = os.time()*565
- 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;
- joint.line = width
- level = level+1
- joint.point1 = x..','..y
- x = x+dx
- y = y+dy
- dx = math.floor(dx+math.sin(math.random()+level)*branchwidth)
- dy = -math.abs(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 > (height/2)/2 then
- if perc < 60 and width > 1 then
- table.insert(togrow, {x, y, 4, width})
- 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()
- id = 0
- 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);
- grow(ar[1], ar[2], 0, 1, ar[4]+level, true);
- end
- end
- function eventLoop()
- if growtime < os.time()-100 then
- newgrow()
- growtime = os.time()
- end
- end
- function newTree()
- tfm.exec.newGame(map)
- tfm.exec.addPhysicObject(1, 200, 400, {type = 12})
- grow(args[1],args[2],args[3],args[4],args[5], false)
- end
- newTree()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement