Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- admin = "Legojumper"
- seed = math.random(0,555)..math.random(555,962) math.randomseed(seed)
- line = math.random(5,7)
- colour = 0xAEEEEE
- alpha = 100 /100
- ang_add_by = math.random(-25,25)
- steps_num = math.random(7, 16)
- branching = math.random(2,5)
- foreground = true
- side_num = 6
- len_min, len_max = 20,40
- map = "@6429343"
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAfkDeath(true)
- local jn0make = tfm.exec.addJoint
- local id = 0
- local ____ld = 0
- function tfm.exec.addJoint(_id, g1, g2, jo0nt)
- if id>=1200 then
- ____ld = ____ld + 1
- tfm.exec.removeJoint(____ld)
- end
- if _id then
- jn0make(_id, g1, g2, jo0nt)
- else
- id = id + 1
- jn0make(id, g1, g2, jo0nt)
- end
- end
- local draws = {}
- local _step = 1
- local ang = 0
- local to_branch = nil
- function eventNewGame()
- tfm.exec.addPhysicObject(1, -400, -200, {type=14,dynamic = false, miceCollision=false, groundCollision=false})
- end
- eventNewGame()
- function draw(step, x, y, angl)
- local tbb = {-1,1}
- local neg_pos = tbb[math.random(1,2)]
- local angl = angl and angl* neg_pos or 0
- local sides = side_num
- if not draws[step-1] then
- draws[step] = {}
- local r = math.random(len_min,len_max)
- for i=1,sides do
- local ang = math.rad(i * 360/sides) + math.rad(angl)
- local xl = math.ceil(x + r*math.cos(ang))
- local yl = math.ceil(y + r*math.sin(ang))
- local p1 = x..","..y
- local p2 = xl..","..yl
- tfm.exec.addJoint(nil, 1,1, {type=0, point1=p1, point2=p2, line=line, color = colour, alpha=alpha, foreground=foreground})
- draws[step][i] = {x=xl, y=yl}
- end
- local l = math.random(0,4)
- to_branch = l==1 and branching or nil
- else
- local r = math.random(len_min,len_max)
- colour = colour + math.random(-5, 5)
- draws[step] = {}
- for i=1,sides do
- if draws[step-1][1].branched == true then
- draws[step][i] = {branched = true, branches = {}}
- for l,v in ipairs(draws[step-1][i].branches) do
- local ang = math.rad(i * 360/sides) + math.rad(angl)
- local xl = math.ceil(r*math.cos(ang) + v.x)
- local yl = math.ceil(r*math.sin(ang) + v.y)
- local p1 = v.x..","..v.y
- local p2 = xl..","..yl
- tfm.exec.addJoint(nil, 1,1, {type=0, point1=p1, point2=p2, line=line, color = colour, alpha=alpha, foreground=foreground})
- draws[step][i].branches[l] = {x=xl, y=yl}
- end
- else
- if to_branch then
- draws[step][i] = {branched = true, branches = {}}
- local p_ang = 0
- for l=1,to_branch do
- local tbl = draws[step-1][i]
- local ang = math.rad(i * 360/sides) + math.rad(angl) + math.rad(p_ang)
- local xl = math.ceil(r*math.cos(ang) + tbl.x)
- local yl = math.ceil(r*math.sin(ang) + tbl.y)
- local p1 = tbl.x..","..tbl.y
- local p2 = xl..","..yl
- tfm.exec.addJoint(nil, 1,1, {type=0, point1=p1, point2=p2, line=line, color = colour, alpha=alpha, foreground=foreground})
- draws[step][i].branches[l] = {x=xl, y=yl}
- p_ang = p_ang + 20*neg_pos
- end
- else
- local tbl = draws[step-1][i]
- local ang = math.rad(i * 360/sides) + math.rad(angl)
- local xl = math.ceil(r*math.cos(ang) + tbl.x)
- local yl = math.ceil(r*math.sin(ang) + tbl.y)
- local p1 = tbl.x..","..tbl.y
- local p2 = xl..","..yl
- tfm.exec.addJoint(nil, 1,1, {type=0, point1=p1, point2=p2, line=line, color = colour, alpha=alpha, foreground=foreground})
- draws[step][i] = {x=xl, y=yl}
- end
- end
- end
- if not to_branch then
- local l = math.random(0,4)
- to_branch = l==1 and branching or nil
- end
- end
- local ran = math.random(-1,1)
- line = line + ran > 0 and line+ran or line+1
- end
- function reset(seeed, branche_)
- math.randomseed(seeed)
- line = math.random(5,7)
- colour = colour
- alpha = aplha or 100/100
- ang_add_by = math.random(-25,25)
- steps_num = math.random(7, 16)
- branching = branche_ or math.random(2,5)
- foreground = true
- side_num = side_num or 6
- len_min, len_max = len_min or 20,len_max or 40
- end
- function eventChatCommand(name, cmd)
- local args = {}
- for arg in cmd:gmatch("%S+") do
- args[#args+1] = arg
- end
- if name ~= admin then return end
- if args[1] == "new" then
- ang = 0
- _step = 0
- seed = math.random(math.random(1,300), math.random(300,400))..math.random(math.random(0,500), math.random(0,900))
- reset(seed)
- for i = 1,id do
- tfm.exec.removeJoint(i)
- end
- id = 0
- stop = false
- elseif args[1] == "redraw" then
- reset(seed)
- ang = 0
- _step = 0
- for i = 1,id do
- tfm.exec.removeJoint(i)
- end
- id = 0
- stop = false
- elseif args[1] == "set" and _step>steps_num then
- if args[2] == "branching" then
- if tonumber(args[3]) then
- branching = tonumber(args[3])
- end
- elseif args[2] == "colour" or args[2] == "color" then
- ui.showColorPicker(1, name, colour, "Choose a color !")
- elseif args[2] == "sides" then
- if tonumber(args[3]) then
- side_num = tonumber(args[3])
- end
- elseif args[2] == "seed" then
- if tonumber(args[3]) then
- seed = tonumber(args[3])
- reset(seed)
- end
- end
- elseif args[1] == "get" then
- if args[2] == "seed" then
- ui.addTextArea(0, "<J>Seed is : <N>"..seed, nil, nil, nil, nil, nil, nil, nil, nil, true)
- print(seed)
- end
- end
- end
- function eventColorPicked(id ,name , color)
- colour = color
- end
- x = 500
- y = 300
- function eventLoop(tr, rt)
- if stop then
- return
- elseif _step > steps_num then
- stop = true
- return
- else
- draw(_step, x, y, ang)
- ang = ang + ang_add_by
- _step = _step + 1
- end
- end
- for i = 1,300 do
- tfm.exec.removeJoint(i)
- end
- tfm.exec.newGame(map)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement