| |
|
»
»
|
|
| |
Re: .
|
|
|
|
| 21 Mar 2013 09:54 PM |
SO PROUD! :D
--Lua Graphic Calculator --Created by Patrickbsoccerboy --Set Variables Config = game.Workspace.Configuration Slope = Config.Slope.Value YIntercept = Config.YIntercept.Value YIntercept = (YIntercept * 1.2) Middle = game.Workspace.Lines.Base Middle.CFrame = CFrame.new(-1.5, 23.4, 0.5) ShowBrick = Config.ShowBricks.Value Slope = (Slope*1) IsA = Config.IsAParabola.Value MiddleX = Middle.CFrame.X MiddleY = Middle.CFrame.Y MiddleZ = Middle.CFrame.Z --End of variables --Check for Variables print("Making sure all variables are here.") if (Config.Parent == nil) then print("Config missing!") if (Slope.Parent == nil) then print("Slope missing!") if (SlopeNegative.Parent == nil) then print("Slope Bool missing!") if (YIntercept.Parent == nil) then print("Y intercept missing!") if (YInterceptNegative.Parent == nil) then print("Y intercept Bool missing!") end end end end end print("All here.") wait() --End of check --Start work Middle.CFrame = CFrame.new(-2.5, 23.4, 0.5) print("Starting.") if (IsA == false) then for i = 1,2 do if i == 1 then Brick = Instance.new("Part") Brick.Name = "Position "..i.."" Brick.Parent = game.Workspace Brick.Anchored = true print(Brick.Name) print("Making Slope Intercept.") Brick.CFrame = CFrame.new(MiddleX, (MiddleY + YIntercept), MiddleZ) Brick.Size = Vector3.new(1,1,1) else Brick2 = Instance.new("Part") Brick2.Name = "Position "..i.."" Brick2.Parent = game.Workspace Brick2.Anchored = true print(Brick2.Name) Brick2.CFrame = CFrame.new(Brick.CFrame.X, (Brick.CFrame.Y + Slope), (Brick.CFrame.Z - 1.2)) Brick2.Size = Vector3.new(1,1,1) end end else for i = 1,3 do if i == 1 then Brick3 = Instance.new("Part") Brick3.Name = "Position "..i.."" Brick3.Parent = game.Workspace Brick3.Anchored = true print(Brick3.Name) Brick3.CFrame = CFrame.new(Brick.CFrame.X, (Brick.CFrame.Y + Slope), (Brick.CFrame.Z - 1.2)) Brick3.Size = Vector3.new(1,1,1) elseif i == 2 then Brick4 = Instance.new("Part") Brick4.Name = "Position "..i.."" Brick4.Parent = game.Workspace Brick4.Anchored = true print(Brick4.Name) Brick4.CFrame = CFrame.new(Brick.CFrame.X, (Brick.CFrame.Y + Slope), (Brick.CFrame.Z - 1.2)) Brick4.Size = Vector3.new(1,1,1) else Brick5 = Instance.new("Part") Brick5.Name = "Position "..i.."" Brick5.Parent = game.Workspace Brick5.Anchored = true print(Brick5.Name) Brick5.CFrame = CFrame.new(Brick.CFrame.X, (Brick.CFrame.Y + Slope), (Brick.CFrame.Z - 1.2)) Brick5.Size = Vector3.new(1,1,1) end end end --End of Work --Start making beams (code thanks to the wiki) local distance = (Brick.CFrame.p - Brick2.CFrame.p).magnitude local rayPart = Instance.new("Part", game.Workspace) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Really red") rayPart.Transparency = 0 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, (distance + 35)) rayPart.CFrame = CFrame.new(Brick.CFrame.p, Brick2.CFrame.p) * CFrame.new(0, 0, -distance/2) --Beam Finished --Check if Parabola if (ShowBrick == false) then Brick.Transparency = 1 Brick2.Transparency = 1 end --Done with all --Made by Patrickbsoccerboy
#cut4patrick |
|
|
| Report Abuse |
|
|
|
| 21 Mar 2013 10:00 PM |
| Half of that script is just setting properties for Parts. |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Mar 2013 11:00 PM |
Sorry to break the news... But here's a brief script I wrote that graphs complex functions with the terrain.
--Terrain Grapher By xXxMoNkEyMaNxXx local clearterrain=true local wedgecells=true local chunksize=Vector2.new(32,32) local window=Vector2.new(192,192) local scale=Vector3.new(16,1,16) local origin=Vector3.new(0,0,0) local next=next local unpack=unpack local min=math.min local max=math.max local ceil=math.ceil local floor=math.floor --Complex Number Library by xXxMoNkEyMaNxXx (_G.cmath) local type=type local select=select local tonumber=tonumber local tostring=tostring local setmetatable=setmetatable local e=math.exp(1) local pi=math.pi local abs=math.abs local exp=math.exp local log=math.log local cos=math.cos local sin=math.sin local cosh=math.cosh local sinh=math.sinh local sqrt=math.sqrt local atan2=math.atan2 local forget=1e-14--Forget ridiculously small values. Remove if you want to keep all values. (Not recommended for sanity, shouldn't make a difference in performance or output.) --The reason that this is here is because i^2 yields -1+0.0000000000000001i, and (-1)^0.5 yields 0.00000000000000006+i. (Should be just -1 and i) local function istype(c) local t=type(c) return t=="table" and c.type or t end local complex_mt --Locally used and desirable functions-- local function re(n) local t=type(n) return t=="table" and (n.re or 0) or t=="number" and n or 0 end local function im(n) return type(n)=="table" and n.im or 0 end local function complex(re,im) if forget then if re and abs(re)<=forget then re=0 end if im and abs(im)<=forget then im=0 end end return setmetatable({re=re or 0,im=im or 0,type="complex"},complex_mt) end local function rect(r,phi)--r*e^(i*phi) -> x+iy return complex(r*cos(phi),r*sin(phi)) end local function arg(z)--Lol, no documentation return atan2(im(z),re(z)) end local function ln(c)--Natural logarithm local r1,i1=re(c),im(c) return complex(log(r1^2+i1^2)/2,atan2(i1,r1)) end ----------------------------------------- --Complex number metatable-- complex_mt={ __add=function(c1,c2) return complex(re(c1)+re(c2),im(c1)+im(c2)) end, __sub=function(c1,c2) return complex(re(c1)-re(c2),im(c1)-im(c2)) end, __mul=function(c1,c2) local r1,i1,r2,i2=re(c1),im(c1),re(c2),im(c2) return complex(r1*r2-i1*i2,r1*i2+r2*i1) end, __div=function(c1,c2) local r1,i1,r2,i2=re(c1),im(c1),re(c2),im(c2) local rsq=r2^2+i2^2 return complex((r1*r2+i1*i2)/rsq,(r2*i1-r1*i2)/rsq) end, __pow=function(c1,c2)--Aww ye local r1,i1,r2,i2=re(c1),im(c1),re(c2),im(c2) local rsq=r1^2+i1^2 if rsq==0 then--Things work better like this. if r2==0 and i2==0 then return 1 end return 0 end local phi=atan2(i1,r1) return rect(rsq^(r2/2)*exp(-i2*phi),i2*log(rsq)/2+r2*phi) end, __unm=function(c) return complex(-re(c),-im(c)) end, __tostring=function(c) local r,i=re(c),im(c) if i==0 then return tostring(r) elseif r==0 then if i==1 then return "i" elseif i==-1 then return "-i" end return i.."i" elseif i<0 then if i==-1 then return r.."-i" end return r..i.."i" else if i==1 then return r.."+i" end return r.."+"..i.."i" end end } ---------------------------- --Allow complex arguments for regular math functions with cmath namespace-- --Note that all these functions still work for regular numbers! --The added bonus is that they can handle things like (-1)^0.5. (=i) local i=complex(0,1) local cmath={e=e,i=i,pi=pi,re=re,im=im,complex=complex,arg=arg,rect=rect,ln=ln} _G.cmath=cmath function cmath.abs(c)--This always returns a pure real value return sqrt(re(c)^2+im(c)^2) end function cmath.diff(c) return re(c)^2-im(c)^2 end function cmath.exp(c) return e^c end function cmath.sqrt(c) local num=istype(c)=="complex" and c^0.5 or complex(c)^0.5 if im(num)==0 then return re(num) end return num end --Trig functions function cmath.sin(c) local r,i=re(c),im(c) return complex(sin(r)*cosh(i),cos(r)*sinh(i)) end function cmath.cos(c) local r,i=re(c),im(c) return complex(cos(r)*cosh(i),sin(r)*sinh(i)) end function cmath.tan(c) local r,i=2*re(c),2*im(c) local div=cos(r)+cosh(i) return complex(sin(r)/div,sinh(i)/div) end --Hyperbolic trig functions function cmath.sinh(c) local r,i=re(c),im(c) return complex(cos(i)*sinh(r),sin(i)*cosh(r)) end function cmath.cosh(c) local r,i=re(c),im(c) return complex(cos(i)*cosh(r),sin(i)*sinh(r)) end function cmath.tanh(c) local r,i=2*re(c),2*im(c) local div=cos(i)+cosh(r) return complex(sinh(r)/div,sin(i)/div) end --Caution! Mathematical laziness beyond this point! --Inverse trig functions function cmath.asin(c) return -i*ln(i*c+(1-c^2)^0.5) end function cmath.acos(c) return pi/2+i*ln(i*c+(1-c^2)^0.5) end function cmath.atan(c) local r2,i2=re(c),im(c) local c3,c4=complex(1-i2,r2),complex(1+r2^2-i2^2,2*r2*i2) return complex(arg(c3/c4^0.5),-ln(cmath.abs(c3)/cmath.abs(c4)^0.5)) end function cmath.atan2(c2,c1)--y,x local r1,i1,r2,i2=re(c1),im(c1),re(c2),im(c2) if r1==0 and i1==0 and r2==0 and i2==0 then--Indeterminate return 0 end local c3,c4=complex(r1-i2,i1+r2),complex(r1^2-i1^2+r2^2-i2^2,2*(r1*i1+r2*i2)) return complex(arg(c3/c4^0.5),-ln(cmath.abs(c3)/cmath.abs(c4)^0.5)) end --Inverse hyperbolic trig functions. Why do they all look different but give correct results!? e.e function cmath.asinh(c) return ln(c+(1+c^2)^0.5) end function cmath.acosh(c) return 2*ln((c-1)^0.5+(c+1)^0.5)-log(2) end function cmath.atanh(c) return (ln(1+c)-ln(1-c))/2 end --Miscellaneous functions function cmath.zeta(s,a) local sum=0 for n=a,accuracy or 10000 do sum=sum+n^-s end return sum end --End of non-optimized terrors. --Linear integration, evenly spaced slices --f=function(x),low=0,high=100,slices=10000 function cmath.lintegrate(f,H,L,n) n=n or floor(10*sqrt(H)) L=L or 0 local LH=H-L local A=(f(L)+f(H))/2 for x=1,n-1 do A=A+f(L+LH*x/n) end return LH*A/n end --cmath.log: Complex base logarithm! One argument (z=c1) gives log(z). Two arguments (b=c1,z=c2) gives log_b(z), which is identical to log(c2)/log(c1). function cmath.log(c2,c1) local r1,i1=re(c1),im(c1) local r2,i2=re(c2),im(c2) local r3,i3=log(r1^2+i1^2)/2,atan2(i1,r1) local r4,i4=log(r2^2+i2^2)/2,atan2(i2,r2) local rsq=r4^2+i4^2 return complex((r3*r4+i3*i4)/rsq,(r4*i3-r3*i4)/rsq) end cmath.pow=complex_mt.__pow --------------------------------------------------------------------------- --These are just some useful tools when working with complex numbers.-- --cmath.polar: x+iy -> r*e^(i*phi) One complex argument, or two real arguments can be given. --This is basically return cmath.abs(z),cmath.arg(z) function cmath.polar(cx,oy) local x,y if oy then x,y=cx,oy else x,y=re(cx),im(cx) end return sqrt(x^2+y^2),atan2(y,x) end --cmath.cx: Define complex numbers from a string. function cmath.cx(a,b) local r,i=0,0 if type(a)=="string" and type(b)=="nil" then local query=a:gsub("[^%d.+-i]","") if #query>0 then for sgn,im in query:gmatch'([+-]*)(%d*%.?%d*)i' do i=i+(-1)^select(2,sgn:gsub("-",""))*(tonumber(im) or 1) end for sgn,re in query:gsub("[+-]*%d*%.?%d*i",""):gmatch'([+-]*)(%d*%.?%d*)()' do r=r+(-1)^select(2,sgn:gsub("-",""))*(tonumber(re) or #sgn>0 and 1 or 0) end end else r,i=tonumber(a) or 0,tonumber(b) or 0 end if forget then if abs(r)<=forget then r=0 end if abs(i)<=forget then i=0 end end return complex(r,i) end ----------------------------------------------------------------------- --Globalize. _G.cmath=cmath local cabs=cmath.abs function cdiff(c) local a=re(c)^2-im(c)^2 return a<0 and -sqrt(-a) or sqrt(a) end local t=workspace.Terrain local s=t.SetCell do local pow=2 function ellipsoid(x,z,v) return -(1-x^pow-z^pow)^(1/pow) end end do local period=2*pi/256 function sinusoid(x,z) return cmath.sin((x^2+z^2)^0.5*period+atan2(re(z),re(x))/2)^2 end end do function paraboloid(x,z) return x^2+z^2 end end do function hyperbola(x,z) return x^2-z^2 end end do function xpowz(x,z) return x^z end function xplusz(x,z) return x^x+z^z end end local f=xpowz local eq=function(x,z,v) local y=f(complex((x-origin.x)/scale.x),complex((z-origin.z)/scale.z),v) if y then return floor(0.5+origin.y+scale.y*cdiff(y)) end end local function min4(a,b,c,d) if a and (not b or a<b) and (not c or a<c) and (not d or a<d) then return a end if b and (not c or b<c) and (not d or b<d) then return b end if c and (not d or c<d) then return c end return d end local function add(a,b) return a and a+b end local function chunk(chx,chy,wedge) local max_y=0 local one=wedge and 0 or 1 for x=chx*chunksize.x,(chx+1)*chunksize.x-1 do for z=chy*chunksize.y,(chy+1)*chunksize.y-1 do local v={} v[#v+1]=eq(x+1,z ) v[#v+1]=eq(x ,z+1) v[#v+1]=eq(x-1,z ) v[#v+1]=eq(x ,z-1) if wedge then v[#v+1]=eq(x+1,z+1) v[#v+1]=eq(x-1,z+1) v[#v+1]=eq(x-1,z-1) v[#v+1]=eq(x+1,z-1) v[#v+1]=eq(x+2,z+2) v[#v+1]=eq(x+2,z+1) v[#v+1]=eq(x+2,z ) v[#v+1]=eq(x+2,z-1) v[#v+1]=eq(x+2,z-2) v[#v+1]=eq(x+1,z-2) v[#v+1]=eq(x ,z-2) v[#v+1]=eq(x-1,z-2) v[#v+1]=eq(x-2,z-2) v[#v+1]=eq(x-2,z-1) v[#v+1]=eq(x-2,z ) v[#v+1]=eq(x-2,z+1) v[#v+1]=eq(x-2,z+2) v[#v+1]=eq(x-1,z+2) v[#v+1]=eq(x ,z+2) v[#v+1]=eq(x+1,z+2) end if #v>0 then local py=min(eq(x,z,true),64) local low=max(0,min(py,one+min(unpack(v)))) for y=low,py do s(t, x,y,z, 1,0,0) end max_y=max(max_y,py) else local y=eq(x,z) if y then s(t, x,min(y,64),z, 1,0,0) max_y=max(max_y,min(y,64)) end end end end return max_y end local function go(w) local max_y=0 local gsx,gsy=floor(window.x/chunksize.x),floor(window.y/chunksize.y) for y=-gsy,gsy do for x=-gsx,gsx do max_y=max(max_y,chunk(x,y,w)) wait(0.1) end end wait(0.1) if w then t:AutowedgeCells(Region3int16.new(Vector3int16.new(-window.x,0,-window.y),Vector3int16.new(window.x+1,max_y,window.y+1))) end end if clearterrain then t:Clear() end go(wedgecells)
|
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 21 Mar 2013 11:19 PM |
I'm sorry, but you'll have to beat my 4900 line monster first.... You can find it here:
http://www.roblox.com/Trade-Enterprise-place?id=86053530
And Monkey's CAS system kind of beats yours too. Still, very nice.
|
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 21 Mar 2013 11:40 PM |
Oh, I thought it said "Longest Script Ever Written" versus "Longest Script I've ever written"
In which case, congratulations (enjoy my out-of-context statements above). |
|
|
| Report Abuse |
|
|
Garnished
|
  |
| Joined: 09 Apr 2012 |
| Total Posts: 12695 |
|
|
| 21 Mar 2013 11:45 PM |
| I have a 3.5k line monster for parkour run physics. |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2013 12:33 AM |
| Seben tousand line paintball gaim :3 |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2013 12:35 AM |
| That's not my CAS... it's my complex number library with a terrain grapher... |
|
|
| Report Abuse |
|
|
oxcool1
|
  |
| Joined: 05 Nov 2009 |
| Total Posts: 15444 |
|
|
| 22 Mar 2013 01:41 AM |
| many MANY useless unneeded lines... |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2013 02:20 AM |
The most I actually write is about 2500 lines... I don't really want to make the whole game on one script and make the script longer since it'll make it harder to read.
☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞ |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2013 02:27 AM |
| I don't have much use for anything over 500 lines. |
|
|
| Report Abuse |
|
|
SN0X
|
  |
| Joined: 24 Oct 2011 |
| Total Posts: 7277 |
|
|
| 22 Mar 2013 02:49 AM |
I rarely go over 500...
I honestly don't know how people end up with 5000 lines. I can get the same thing done in 10 times less code :l
Why is it a contest to see who can write the most lines in a script? More lines = bad |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2013 02:55 AM |
| Did you ever think that maybe more lines can also mean more features? Yes, you can write it in 10 times less lines, but you have to write ten lines on each line without pressing enter. When I think of lines, I think of properly tabbed non-condensed into one line code. I have some functions in my code that I write on one line, but it's usually because it's a short function I'm assigning to an index of a table. If you look through my scripts, there's not too much room for "inefficiency", every line does something. |
|
|
| Report Abuse |
|
|
8SunTzu8
|
  |
| Joined: 30 Sep 2011 |
| Total Posts: 8199 |
|
|
| 22 Mar 2013 05:24 AM |
Number of lines doesn't really affect anything. Some GUIs I have made use a lot of lines, but each function is relatively small and does the job efficiently. The GUI just has many features.
One I'm working on now has reached 800 lines. Nothing compared to the monsters here, but I haven't needed that many.
Maybe the complicated holo facility I'm looking to build might reach over 1000. (Instead of one room, it uses 4, even if that's only a few extra lines of code, the system will be comprehensive).
"Consider, friend, as you pass by, as you are now, so once was I. As I am now, you too shall be. Prepare, therefore, to follow me." -Scottish Tombstone Epitaph |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2013 06:27 AM |
We should really have a 'standard line' convention. For example, we can spread out tables over many many lines, but a standard line for a table would contain the whole thing. And you can make strings that are huge but a standard line would have 1 string in, so that massive multi-line string is one standard line. |
|
|
| Report Abuse |
|
|
SN0X
|
  |
| Joined: 24 Oct 2011 |
| Total Posts: 7277 |
|
|
| 22 Mar 2013 08:04 AM |
Prehistoric can I make u a 10k post in off topic plz
PM me wen ur there ok
idk |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2013 08:51 AM |
Yeah, sorry for off topics, but this is relevant.
http://www.roblox.com/Forum/ShowPost.aspx?PostID=92469274 |
|
|
| Report Abuse |
|
|
Tenal
|
  |
| Joined: 15 May 2011 |
| Total Posts: 18684 |
|
|
| 22 Mar 2013 08:56 AM |
| Honestly, I've always wanted to hit a couple thousand lines in my scripts. However, I never partake in a project that big. |
|
|
| Report Abuse |
|
|
itunes89
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 1957 |
|
|
| 22 Mar 2013 09:27 AM |
| Same for me, I've written some big projects, but rarely go over 1 thousand. I do however create a lot of very small and efficient functions. |
|
|
| Report Abuse |
|
|
TeamDman
|
  |
| Joined: 04 Dec 2009 |
| Total Posts: 897 |
|
|
| 22 Mar 2013 02:00 PM |
6622 line administrative command script. 209883 characters
I like making admin scripts <3 |
|
|
| Report Abuse |
|
|
1waffle1
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
|
| 22 Mar 2013 02:05 PM |
| 7,000 line do-whatever-I-want-to script, seamless client-server communication, about 1.5 million characters worth of revisions. |
|
|
| Report Abuse |
|
|
| |
|
|
| |
|
|
| |
|
»
»
|
|
|
|
|