alexmach1
|
  |
| Joined: 02 May 2008 |
| Total Posts: 1977 |
|
|
| 19 Jul 2011 10:43 PM |
this script is a mapping sort of thing, and it has no output. what it is supposed to do: create effectively a web between parts, and then a line that connects the first dot to the target dot. it only makes a dot (part) at the center of the baseplate. oh, and there are the correct amount of ends, i just posted the broken bit.
function checkavailablepaths(main, pos, obj, target) local obj={} for i, v in pairs(main)do if v~=pos then part=Instance.new("Part",workspace) part.formFactor=Enum.FormFactor.Custom part.Size=Vector3.new(.2,.2,.2) part.Anchored=true part.CanCollide=false part.Transparency=1 part.Position=Vector3.new(v.x,script.Parent.Torso.Position.y,v.z) local ray2 = Ray.new(pos,(v-pos).unit*500) s1,p1=game.Workspace:FindPartOnRay(ray2) if s1~=nil and s1==part then table.insert(obj, v) table.insert(path, part) else part:remove() end end end for i, v in pairs(obj)do local ray2 = Ray.new(v,(target.CFrame.p-v).unit*500) s1,p1=game.Workspace:FindPartOnRay(ray2) if s1~=nil and s1.Parent==target.Parent then point=v return point else point=nil end end return obj, path end
while true do wait()
local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil and script.Parent.Following.Value==true then local ray = Ray.new(script.Parent.Torso.Position,(target.Position-script.Parent.Torso.Position).unit*500)
s,p=game.Workspace:FindPartOnRay(ray, script.Parent) --print(s,p) if s~=nil and s.Parent~=target.Parent and s.Anchored==true then path={} local tabl=worldcoords local new = script.Parent.Torso.CFrame.p local ps0={} checkavailablepaths(tabl, new, ps0, target) tabl=obj if point~=nil then else repeat wait() for i,v in pairs(ps0)do checkavailablepaths(tabl, v, ps0, target) local tabl=obj end until point~=nil
print(point)
end |
|
|
| Report Abuse |
|
|
alexmach1
|
  |
| Joined: 02 May 2008 |
| Total Posts: 1977 |
|
|
| 19 Jul 2011 11:01 PM |
tl;dr? too bad. main issue(s): with the function and the calling of the function.
function checkavailablepaths(main, pos, obj, target) local obj={} for i, v in pairs(main)do if v~=pos then part=Instance.new("Part",workspace) part.formFactor=Enum.FormFactor.Custom part.Size=Vector3.new(.2,.2,.2) part.Anchored=true part.CanCollide=false part.Transparency=1 part.Position=Vector3.new(v.x,script.Parent.Torso.Position.y,v.z) local ray2 = Ray.new(pos,(v-pos).unit*500) s1,p1=game.Workspace:FindPartOnRay(ray2) if s1~=nil and s1==part then table.insert(obj, v) table.insert(path, part) else part:remove() end end end for i, v in pairs(obj)do local ray2 = Ray.new(v,(target.CFrame.p-v).unit*500) s1,p1=game.Workspace:FindPartOnRay(ray2) if s1~=nil and s1.Parent==target.Parent then point=v return point else point=nil end end return obj, path end
path={} local tabl=worldcoords local new = script.Parent.Torso.CFrame.p local ps0={} checkavailablepaths(tabl, new, ps0, target) tabl=obj if point~=nil then else repeat wait() for i,v in pairs(ps0)do checkavailablepaths(tabl, v, ps0, target) local tabl=obj end until point~=nil print(point) |
|
|
| Report Abuse |
|
|
alexmach1
|
  |
| Joined: 02 May 2008 |
| Total Posts: 1977 |
|
| |
|
| |
|
alexmach1
|
  |
| Joined: 02 May 2008 |
| Total Posts: 1977 |
|
| |
|
alexmach1
|
  |
| Joined: 02 May 2008 |
| Total Posts: 1977 |
|
| |
|
|
| 20 Jul 2011 02:53 PM |
| You should look at oysi's raycast function. Simple and easy to use |
|
|
| Report Abuse |
|
|
alexmach1
|
  |
| Joined: 02 May 2008 |
| Total Posts: 1977 |
|
|
| 20 Jul 2011 03:17 PM |
| i know how to raycast -_- in the script, i have a series of coordinates in a table called worldcoords and each worldcoord gets a part applied to it and raycasts to eachother, and sees which worldcoord can see eachother until one can connect a series of coords with the target and the main, creating a web between the 2. |
|
|
| Report Abuse |
|
|