Exemplo n.º 1
0
int LuaPerlinNoise::l_get2d(lua_State *L)
{
    NO_MAP_LOCK_REQUIRED;
    LuaPerlinNoise *o = checkobject(L, 1);
    v2f p = check_v2f(L, 2);
    lua_Number val = NoisePerlin2D(&o->np, p.X, p.Y, 0);
    lua_pushnumber(L, val);
    return 1;
}
Exemplo n.º 2
0
int LuaPerlinNoiseMap::l_calc2dMap(lua_State *L)
{
    NO_MAP_LOCK_REQUIRED;

    LuaPerlinNoiseMap *o = checkobject(L, 1);
    v2f p                = check_v2f(L, 2);

    Noise *n = o->noise;
    n->perlinMap2D(p.X, p.Y);

    return 0;
}
Exemplo n.º 3
0
int LuaPerlinNoiseMap::l_get2dMap_flat(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;

	LuaPerlinNoiseMap *o = checkobject(L, 1);
	v2f p = check_v2f(L, 2);

	Noise *n = o->noise;
	n->perlinMap2D(p.X, p.Y);

	size_t maplen = n->sx * n->sy;

	lua_newtable(L);
	for (size_t i = 0; i != maplen; i++) {
		lua_pushnumber(L, n->result[i]);
		lua_rawseti(L, -2, i + 1);
	}
	return 1;
}
Exemplo n.º 4
0
int LuaPerlinNoiseMap::l_get2dMap(lua_State *L)
{
    NO_MAP_LOCK_REQUIRED;
    size_t i = 0;

    LuaPerlinNoiseMap *o = checkobject(L, 1);
    v2f p = check_v2f(L, 2);

    Noise *n = o->noise;
    n->perlinMap2D(p.X, p.Y);

    lua_newtable(L);
    for (u32 y = 0; y != n->sy; y++) {
        lua_newtable(L);
        for (u32 x = 0; x != n->sx; x++) {
            lua_pushnumber(L, n->result[i++]);
            lua_rawseti(L, -2, x + 1);
        }
        lua_rawseti(L, -2, y + 1);
    }
    return 1;
}