Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1708,6 +1708,8 @@ Helper functions | |
* Convert position to a printable string | ||
* `minetest.string_to_pos(string)`: returns a position | ||
* Same but in reverse. Returns `nil` if the string can't be parsed to a position. | ||
* `minetest.string_to_area("(X1, Y1, Z1) (X2, Y2, Z2)")`: returns two positions | ||
* Converts a string representing an area box into two positions | ||
* `minetest.formspec_escape(string)`: returns a string | ||
* escapes the characters "[", "]", "\", "," and ";", which can not be used in formspecs | ||
* `minetest.is_yes(arg)` | ||
|
@@ -2020,6 +2022,9 @@ and `minetest.auth_reload` call the authetification handler. | |
* `pos1` and `pos2` are optional and default to mapchunk minp and maxp. | ||
* `minetest.clear_objects()` | ||
* clear all objects in the environments | ||
* `minetest.emerge_area(pos1, pos2)` | ||
* queues all mapblocks in the area from pos1 to pos2, inclusive, for emerge | ||
* i.e. asynchronously loads blocks from disk, or if inexistent, generates them | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
est31
Contributor
|
||
* `minetest.delete_area(pos1, pos2)` | ||
* delete all mapblocks in the area from pos1 to pos2, inclusive | ||
* `minetest.line_of_sight(pos1, pos2, stepsize)`: returns `boolean, pos` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc., | |
#include "util/pointedthing.h" | ||
#include "content_sao.h" | ||
#include "treegen.h" | ||
#include "emerge.h" | ||
#include "pathfinder.h" | ||
|
||
#define GET_ENV_PTR ServerEnvironment* env = \ | ||
|
@@ -751,6 +752,29 @@ int ModApiEnvMod::l_line_of_sight(lua_State *L) | |
return 1; | ||
} | ||
|
||
|
||
// emerge_area(p1, p2) | ||
// emerge mapblocks in area p1..p2 | ||
int ModApiEnvMod::l_emerge_area(lua_State *L) | ||
{ | ||
GET_ENV_PTR; | ||
|
||
EmergeManager *emerge = getServer(L)->getEmergeManager(); | ||
|
||
v3s16 bpmin = getNodeBlockPos(read_v3s16(L, 1)); | ||
v3s16 bpmax = getNodeBlockPos(read_v3s16(L, 2)); | ||
sortBoxVerticies(bpmin, bpmax); | ||
|
||
for (s16 z = bpmin.Z; z <= bpmax.Z; z++) | ||
for (s16 y = bpmin.Y; y <= bpmax.Y; y++) | ||
for (s16 x = bpmin.X; x <= bpmax.X; x++) { | ||
v3s16 chunkpos(x, y, z); | ||
emerge->enqueueBlockEmerge(PEER_ID_INEXISTENT, chunkpos, false, true); | ||
This comment has been minimized.
Sorry, something went wrong.
RobertZenz
Contributor
|
||
} | ||
|
||
return 0; | ||
} | ||
|
||
// delete_area(p1, p2) | ||
// delete mapblocks in area p1..p2 | ||
int ModApiEnvMod::l_delete_area(lua_State *L) | ||
|
@@ -954,6 +978,7 @@ void ModApiEnvMod::Initialize(lua_State *L, int top) | |
API_FCT(find_node_near); | ||
API_FCT(find_nodes_in_area); | ||
API_FCT(find_nodes_in_area_under_air); | ||
API_FCT(emerge_area); | ||
API_FCT(delete_area); | ||
API_FCT(get_perlin); | ||
API_FCT(get_perlin_map); | ||
|
Can l use this before using minetest.get_node in unloaded chunks?