3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "lua_api/l_base.h"
30 class LuaPerlinNoise : public ModApiBase {
33 static const char className[];
34 static const luaL_reg methods[];
39 static int gc_object(lua_State *L);
41 static int l_get2d(lua_State *L);
42 static int l_get3d(lua_State *L);
45 LuaPerlinNoise(NoiseParams *params);
48 // LuaPerlinNoise(seed, octaves, persistence, scale)
49 // Creates an LuaPerlinNoise and leaves it on top of stack
50 static int create_object(lua_State *L);
52 static LuaPerlinNoise *checkobject(lua_State *L, int narg);
54 static void Register(lua_State *L);
60 class LuaPerlinNoiseMap : public ModApiBase {
64 static const char className[];
65 static const luaL_reg methods[];
70 static int gc_object(lua_State *L);
72 static int l_get2dMap(lua_State *L);
73 static int l_get2dMap_flat(lua_State *L);
74 static int l_get3dMap(lua_State *L);
75 static int l_get3dMap_flat(lua_State *L);
78 LuaPerlinNoiseMap(NoiseParams *np, int seed, v3s16 size);
82 // LuaPerlinNoiseMap(np, size)
83 // Creates an LuaPerlinNoiseMap and leaves it on top of stack
84 static int create_object(lua_State *L);
86 static LuaPerlinNoiseMap *checkobject(lua_State *L, int narg);
88 static void Register(lua_State *L);
94 class LuaPseudoRandom : public ModApiBase {
96 PseudoRandom m_pseudo;
98 static const char className[];
99 static const luaL_reg methods[];
101 // Exported functions
104 static int gc_object(lua_State *L);
106 // next(self, min=0, max=32767) -> get next value
107 static int l_next(lua_State *L);
110 LuaPseudoRandom(int seed) :
113 // LuaPseudoRandom(seed)
114 // Creates an LuaPseudoRandom and leaves it on top of stack
115 static int create_object(lua_State *L);
117 static LuaPseudoRandom *checkobject(lua_State *L, int narg);
119 static void Register(lua_State *L);
125 class LuaPcgRandom : public ModApiBase {
129 static const char className[];
130 static const luaL_reg methods[];
132 // Exported functions
135 static int gc_object(lua_State *L);
137 // next(self, min=-2147483648, max=2147483647) -> get next value
138 static int l_next(lua_State *L);
140 // rand_normal_dist(self, min=-2147483648, max=2147483647, num_trials=6) ->
141 // get next normally distributed random value
142 static int l_rand_normal_dist(lua_State *L);
145 LuaPcgRandom(u64 seed) :
147 LuaPcgRandom(u64 seed, u64 seq) :
150 // LuaPcgRandom(seed)
151 // Creates an LuaPcgRandom and leaves it on top of stack
152 static int create_object(lua_State *L);
154 static LuaPcgRandom *checkobject(lua_State *L, int narg);
156 static void Register(lua_State *L);
159 #endif /* L_NOISE_H_ */