# Solved Create outline of square with particles

Comments in 'Plugin Development' started by MCPEPIG, Mar 20, 2016.

1. Offline

### MCPEPIGNotable Member

Joined:
Jun 22, 2014
Posts:
349
Minecraft User:
What's the best way to create an outline of a square with particles?
2. Offline

### xBeastMode

Joined:
Nov 27, 2015
Posts:
292
Do you mean the outer part of a square? The walls of a square?
If you want to create a aquare use this:
PHP:
``` public function squareParticles(){        \$startX = 130;//STARTING POINT X        \$endX = 140;//END POINT X        \$startY = 4;//STARTING POINT Y        \$endY = 14;//END POINT Y        \$startZ = 130;//STARTING POINT Z        \$endZ = 140;//END POINT Z        for(\$x = \$startX; \$x <= \$endX; ++\$x){            for(\$y = \$startY; \$y <= \$endY; ++\$y){                for(\$z = \$startZ; \$z <= \$endZ; ++\$z){                    \$level = \$this->getServer()->getLevelByName("world");                    \$level->addParticle(new DustParticle(new Vector3(\$x, \$y, \$z), 0, 0, 0));                }            }        }    } ```
3. Offline

### MCPEPIGNotable Member

Joined:
Jun 22, 2014
Posts:
349
Minecraft User:
I don't need an entire square, I need the outer part.
PEMapModder likes this.
4. Offline

### xBeastMode

Joined:
Nov 27, 2015
Posts:
292
PHP:
```     public function squareParticles(){        \$startX = 130;//STARTING POINT X        \$endX = 140;//END POINT X        \$startY = 4;//STARTING POINT Y        \$endY = 14;//END POINT Y        \$startZ = 130;//STARTING POINT Z        \$endZ = 140;//END POINT Z        for(\$x = \$startX; \$x <= \$endX; ++\$x){            for(\$y = \$startY; \$y <= \$endY; ++\$y){                for(\$z = \$startZ; \$z <= \$endZ; ++\$z){                    if(                        \$x == \$startX || \$x == \$endX ||                        \$y == \$startY || \$y == \$endY ||                        \$z == \$startZ || \$z == \$endZ                    ) {                        \$level = \$this->getServer()->getLevelByName("world");                        \$level->addParticle(new DustParticle(new Vector3(\$x, \$y, \$z), 0, 0, 0));                    }                }            }        }    } ```
5. Offline

### MCPEPIGNotable Member

Joined:
Jun 22, 2014
Posts:
349
Minecraft User:
Doesn't that only do the 2 corners?
6. Offline

### MCPEPIGNotable Member

Joined:
Jun 22, 2014
Posts:
349
Minecraft User:
Wait, nvm.
7. Offline

### MCPEPIGNotable Member

Joined:
Jun 22, 2014
Posts:
349
Minecraft User:
PHP:
``` \$y == \$startY || \$y == \$endY || ```
will make the function create an entire square btw :3
8. Offline

Joined:
Nov 27, 2015
Posts:
292
No.
9. Offline

### MCPEPIGNotable Member

Joined:
Jun 22, 2014
Posts:
349
Minecraft User:
\$y == \$startY... If \$y == \$startY, it'll spawn the particle...
10. Offline

Joined:
Nov 27, 2015
Posts:
292
What?
11. Offline

### PEMapModderNotable MemberPlugin Developer

Joined:
Oct 9, 2013
Posts:
7,230
Plugins:
11
Minecraft User:
This is too slow.
(And this is a cuboid, not a square, but never mind)
PHP:
``` for(\$x = \$startX; \$x <= \$endX; \$x++){  addParticle(\$x, \$y, \$startZ);  addParticle(\$x, \$y, \$endZ);}for(\$z = \$startZ + 1; \$z < \$endZ; \$z++){  addParticle(\$startX, \$y, \$z);  addParticle(\$endX, \$y, \$z);} ```
12. Offline

### xBeastMode

Joined:
Nov 27, 2015
Posts:
292
Ah OK. I heard `++\$var` was faster.
13. Offline

### PEMapModderNotable MemberPlugin Developer

Joined:
Oct 9, 2013
Posts:
7,230
Plugins:
11
Minecraft User:
I am not sure about that, but I'm quite sure that the difference is very negligible. Both exist in low-level instructions, so there shouldn't really be any difference.
14. Offline

### jojoe77777Notable MemberPlugin Developer

Joined:
May 28, 2015
Posts:
653
Plugins:
1
Minecraft User:
http://php.net/manual/en/language.operators.increment.php Look in the comments, second from the top
15. Offline

### Tim // robske BübaNotable Member

Joined:
Feb 26, 2014
Posts:
606
Minecraft User:
and the third says \$var += 1 is the fastest
16. Offline

### PEMapModderNotable MemberPlugin Developer

Joined:
Oct 9, 2013
Posts:
7,230
Plugins:
11
Minecraft User:
xXNiceAssassinlo likes this.