diff options
| author | sapier <sapier at gmx dot net> | 2012-01-15 20:09:55 +0100 |
|---|---|---|
| committer | sapier <sapier at gmx dot net> | 2012-01-15 20:09:55 +0100 |
| commit | 285f5a025975207f9251165e82dadb50d4744991 (patch) | |
| tree | a4102bff145e67b86ce6904801e6a7b8d911511c /src/environment.cpp | |
| parent | 71186974fa30b68292b66bb43124040957edfc31 (diff) | |
| download | minetest-285f5a025975207f9251165e82dadb50d4744991.tar.xz | |
added lua command get_nodes_inside_radius
Diffstat (limited to 'src/environment.cpp')
| -rw-r--r-- | src/environment.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/environment.cpp b/src/environment.cpp index 3a294086c..a3d0950f0 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -765,6 +765,21 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime) abmhandler.apply(block); } +core::list<MapNode> ServerEnvironment::getNodesInsideRadius(v3s16 pos, float radius) +{ + core::list<MapNode> nodes; + for (int i = pos.X - radius; i < pos.X + radius; i ++) + for (int j = pos.Y - radius; j < pos.Y + radius; j ++) + for (int k = pos.Z - radius; k < pos.Z + radius; k ++) { + v3s16 current_pos = v3s16(i,j,k); + if (current_pos.getDistanceFrom(pos) < radius) { + MapNode n = m_map->getNodeNoEx(current_pos); + nodes.push_back(n); + } + } + return nodes; +} + void ServerEnvironment::addActiveBlockModifier(ActiveBlockModifier *abm) { m_abms.push_back(ABMWithState(abm)); |
