SirHorse
|
  |
| Joined: 12 Mar 2010 |
| Total Posts: 83 |
|
|
| 23 Nov 2013 12:09 PM |
Hi there! I would love a bit of help debugging this little fella:
function isPartInRange(Part) if Part ~= nil then Plots = game.Workspace.Plots:GetChildren() for i = 1, #Plots do Point1 = Vector3.new(Plots[i].Position.x - Plots[i].Size.x/2, Plots[i].Position.y, Plots[i].Position.z - Plots[i].Size.z/2) Point2 = Vector3.new(Plots[i].Position.x + Plots[i].Size.x/2, Plots[i].Position.y + 20, Plots[i].Position.z + Plots[i].Size.z/2) Region = Region3.new(Point1, Point2) for k, v in pairs(Workspace:FindPartsInRegion3(Region)) do if v == Part then return true end end return false end end end
This function is supposed to detect whether a part is within the region of a plot and then return true or false. The bizarre part is that it will have random parts on the block where it returns false. For example I can put blocks around the perimeter but 2 random blocks will not be placed. This code is a but beyond me as I have entered unknown territory. Any help would be appreciated!
Thanks, SirHorse |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2013 12:25 PM |
Fascinating! :D Have you tried placing print statements throughout the code to display the codes current state? i.e. "Drawing region from point "..a.." to "..b.. and "returning true for part " .. part and such? That may give you some insight on what is going on. |
|
|
| Report Abuse |
|
|
SirHorse
|
  |
| Joined: 12 Mar 2010 |
| Total Posts: 83 |
|
|
| 23 Nov 2013 01:30 PM |
Thanks for not immediately putting me down :D I have and its bizarre because it still is not functioning. |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2013 01:34 PM |
| Not functioning as in not posting any output for the bricks that don't appear? |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2013 02:29 PM |
Sir,
You must READ the printed output as well, then logically figure-out why it is printing what it is printing; thus u find the problem.
Another option is to post the debugging code with the print statements; the results; then let someone else figure it out.
People love little self-contained puzzles; like Sudoku..... And r more likely to help; the more info they r given.
Love, Bri
|
|
|
| Report Abuse |
|
|
|
| 23 Nov 2013 02:34 PM |
Also: Comment your code. And ALWAYS comment all of your 'End's.
If you will notice, job postings for programmers, always state, "...must be able to write maintainable code."
This means code that any-one can read with no fancy "efficient" shorts-cuts; lots of comment at every line; and meaningful variable names.
That's because: Everybody dies, but the code lives-on....
Love, Bri
|
|
|
| Report Abuse |
|
|