rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
|
| 31 Dec 2011 11:45 AM |
| I wanna make something with magninitude. i dont know how i use it. So as exemple. BlockA searches for blocks with magnitude = 1, theres a BlockB with magnitude = 1. How can i script that ? |
|
|
| Report Abuse |
|
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
| |
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
| |
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
| |
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 31 Dec 2011 12:23 PM |
Hello.
First, we must grasp the concept of the magnitude property. The magnitude property can is a member of a Vector3 data type or Vector2 data type. What this property does is give you the length of the Vector3/2. So.. please rephrase your question so I can give you some sample code. :)
~Flurite
|
|
|
| Report Abuse |
|
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
|
| 31 Dec 2011 12:27 PM |
hmm maybe then magnitude is the wrong thing... so lets make a pseudocode:
Theres a BlockA and BlockB
Get all blocks with distance 1 from BlockA
Returns BlockB
Maybe you understand know what im searching for. Sry for my bad English im swiss. |
|
|
| Report Abuse |
|
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
| |
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 31 Dec 2011 12:45 PM |
Actually, you are talking about the right thing. Here is an example that loops through all of Workspace finding all bricks that are within 1 stud away from BlockA. It will return a table..
blockA = game.Workspace.BlockA
function GetNearbyBricks(brick) local nearbyBricks = {} for index, child in pairs(game.Workspace:GetChildren()) do if child:IsA("BasePart") and (Vector3.new(blockA.Position) - Vector3.new(child.Position).magnitude <= 1 then table.insert(nearbyBricks, child) end end return nearbyBricks end
~Flurite |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 31 Dec 2011 12:50 PM |
> (Vector3.new(blockA.Position) - Vector3.new(child.Position).magnitude <= 1
um what?
(blockA.Position-child.Position).magnitude
You screwed that part up really badly. Also I would add a bit of a fuzz factor to the 1. |
|
|
| Report Abuse |
|
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
|
| 31 Dec 2011 12:50 PM |
| HOW COOL :D thx i will test it right now :DDDD one question. When all Objects are in one table, how can i "activate" them ? e.x. change their transpirancy |
|
|
| Report Abuse |
|
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
| |
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 31 Dec 2011 12:53 PM |
@rasta With the fixes I pointed out, just do like this.
local parts=GetNearbyBricks(blockA) for _,v in pairs(parts) do v.Transparency=0.5;--or whatever you want here end |
|
|
| Report Abuse |
|
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
|
| 31 Dec 2011 12:53 PM |
| Ok Duke you confused me xD |
|
|
| Report Abuse |
|
|
|
| 31 Dec 2011 12:53 PM |
for index, value in pairs(TableName) do if value:IsA("BasePart") then value.Transparency = 0.5 end end |
|
|
| Report Abuse |
|
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
|
| 31 Dec 2011 01:00 PM |
| Could someone pls post the whole Exemple ? im really confused xD |
|
|
| Report Abuse |
|
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
| |
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
|
| 31 Dec 2011 02:09 PM |
| Just a whole exemple please. Everyone above doesnt work |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 31 Dec 2011 02:20 PM |
Well my way is kinda long, but all I forgot a parenthesis..
blockA = game.Workspace.BlockA
function GetNearbyBricks(brick) local nearbyBricks = {} for index, child in pairs(game.Workspace:GetChildren()) do if child:IsA("BasePart") and (Vector3.new(blockA.Position) - Vector3.new(child.Position)).magnitude <= 1 then table.insert(nearbyBricks, child) end end return nearbyBricks end
~Flurite |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 31 Dec 2011 02:22 PM |
@flurite position is already a Vector3 value so there's no reason to change it into a Vector3. |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 31 Dec 2011 02:38 PM |
@Sduke
Oh yeah.. it works though. =/
@rasta
This is your transparency script:
blockA = game.Workspace.BlockA
function GetNearbyBricks(brick) for index, child in pairs(game.Workspace:GetChildren()) do if child:IsA("BasePart") and (Vector3.new(blockA.Position) - Vector3.new(child.Position)).magnitude <= 1 then child.Transparency = 0.5 end end end
~Flurite |
|
|
| Report Abuse |
|
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
|
| 31 Dec 2011 02:44 PM |
| Its does nothing, no output no transparency xD |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 31 Dec 2011 02:51 PM |
Oh yeah, make sure one brick is named BlockA, and the brick you want to be transparent is RIGHT NEXT to it.
~Flurite |
|
|
| Report Abuse |
|
|
rastamann
|
  |
| Joined: 27 May 2008 |
| Total Posts: 539 |
|
| |
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 31 Dec 2011 02:54 PM |
OOPS, you gotta call the function. x.x
blockA = game.Workspace.BlockA
function GetNearbyBricks(brick) for index, child in pairs(game.Workspace:GetChildren()) do if child:IsA("BasePart") and (Vector3.new(brick.Position) - Vector3.new(child.Position)).magnitude <= 1 then child.Transparency = 0.5 end end end
GetNearbyBricks(blockA)
~Flurite |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 31 Dec 2011 02:56 PM |
OKAY USE THIS SCRIPT. I ADDED A PART SO IT DOESNT MAKE ITSELF TRANSPARENT. X_X
blockA = game.Workspace.BlockA
function GetNearbyBricks(brick) for index, child in pairs(game.Workspace:GetChildren()) do if child:IsA("BasePart") and (Vector3.new(brick.Position) - Vector3.new(child.Position)).magnitude <= 1 and child ~= brick then child.Transparency = 0.5 end end end
GetNearbyBricks(blockA)
~Flurite |
|
|
| Report Abuse |
|
|