minetest.register_on_placenode(func(pos, newnode, placer))
minetest.register_on_dignode(func(pos, oldnode, digger))
minetest.register_on_punchnode(func(pos, node, puncher))
-minetest.register_on_generated(func(minp, maxp))
+minetest.register_on_generated(func(minp, maxp, blockseed))
minetest.register_on_newplayer(func(ObjectRef))
minetest.register_on_dieplayer(func(ObjectRef))
minetest.register_on_respawnplayer(func(ObjectRef))
}
}
+#if 0
static void make_jungletree(VoxelManipulator &vmanip, v3s16 p0,
INodeDefManager *ndef)
{
}
}
-void make_papyrus(VoxelManipulator &vmanip, v3s16 p0,
+static void make_papyrus(VoxelManipulator &vmanip, v3s16 p0,
INodeDefManager *ndef)
{
MapNode papyrusnode(ndef->getId("mapgen_papyrus"));
}
}
-void make_cactus(VoxelManipulator &vmanip, v3s16 p0,
+static void make_cactus(VoxelManipulator &vmanip, v3s16 p0,
INodeDefManager *ndef)
{
MapNode cactusnode(ndef->getId("mapgen_cactus"));
p1.Y++;
}
}
+#endif
+#if 0
/*
Dungeon making routines
*/
}
}
+#endif
+#if 0
static void make_nc(VoxelManipulator &vmanip, PseudoRandom &random,
INodeDefManager *ndef)
{
vmanip.m_data[vmanip.m_area.index(p)] = MapNode(ndef->getId("mapgen_nyancat_rainbow"));
}
}
+#endif
/*
Noise functions. Make sure seed is mangled differently in each one.
return (sandnoise > -0.15);
}
+u32 get_blockseed(u64 seed, v3s16 p)
+{
+ s32 x=p.X, y=p.Y, z=p.Z;
+ return (u32)(seed%0x100000000ULL) + z*38134234 + y*42123 + x*23;
+}
+
#define VMANIP_FLAG_CAVE VOXELFLAG_CHECKED1
void make_block(BlockMakeData *data)
// Find out if block is completely underground
bool block_is_underground(u64 seed, v3s16 blockpos);
+ // Get a pseudorandom seed for a position on the map
+ u32 get_blockseed(u64 seed, v3s16 p);
+
// Main map generation routine
void make_block(BlockMakeData *data);
}
}
-void scriptapi_environment_on_generated(lua_State *L, v3s16 minp, v3s16 maxp)
+void scriptapi_environment_on_generated(lua_State *L, v3s16 minp, v3s16 maxp,
+ u32 blockseed)
{
realitycheck(L);
assert(lua_checkstack(L, 20));
// Call function
push_v3s16(L, minp);
push_v3s16(L, maxp);
- if(lua_pcall(L, 2, 0, 0))
+ lua_pushnumber(L, blockseed);
+ if(lua_pcall(L, 3, 0, 0))
script_error(L, "error: %s", lua_tostring(L, -1));
// value removed, keep key for next iteration
}
// On environment step
void scriptapi_environment_step(lua_State *L, float dtime);
// After generating a piece of map
-void scriptapi_environment_on_generated(lua_State *L, v3s16 minp, v3s16 maxp);
+void scriptapi_environment_on_generated(lua_State *L, v3s16 minp, v3s16 maxp,
+ u32 blockseed);
/* misc */
void scriptapi_on_newplayer(lua_State *L, ServerActiveObject *player);
v3s16 minp = block->getPos()*MAP_BLOCKSIZE;
v3s16 maxp = minp + v3s16(1,1,1)*(MAP_BLOCKSIZE-1);
scriptapi_environment_on_generated(m_server->m_lua,
- minp, maxp);
+ minp, maxp, mapgen::get_blockseed(data.seed, minp));
if(enable_mapgen_debug_info)
infostream<<"EmergeThread: ended up with: "