]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/lua_api/l_noise.h
Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenu
[dragonfireclient.git] / src / script / lua_api / l_noise.h
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
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.
9
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.
14
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.
18 */
19
20 #ifndef L_NOISE_H_
21 #define L_NOISE_H_
22
23 #include "lua_api/l_base.h"
24 #include "irr_v3d.h"
25 #include "noise.h"
26
27 /*
28         LuaPerlinNoise
29 */
30 class LuaPerlinNoise : public ModApiBase {
31 private:
32         int seed;
33         int octaves;
34         float persistence;
35         float scale;
36         static const char className[];
37         static const luaL_reg methods[];
38
39         // Exported functions
40
41         // garbage collector
42         static int gc_object(lua_State *L);
43
44         static int l_get2d(lua_State *L);
45         static int l_get3d(lua_State *L);
46
47 public:
48         LuaPerlinNoise(int a_seed, int a_octaves, float a_persistence,
49                         float a_scale);
50
51         ~LuaPerlinNoise();
52
53         // LuaPerlinNoise(seed, octaves, persistence, scale)
54         // Creates an LuaPerlinNoise and leaves it on top of stack
55         static int create_object(lua_State *L);
56
57         static LuaPerlinNoise* checkobject(lua_State *L, int narg);
58
59         static void Register(lua_State *L);
60 };
61
62 /*
63         LuaPerlinNoiseMap
64 */
65 class LuaPerlinNoiseMap : public ModApiBase {
66 private:
67         Noise *noise;
68         static const char className[];
69         static const luaL_reg methods[];
70
71         static int gc_object(lua_State *L);
72
73         static int l_get2dMap(lua_State *L);
74         static int l_get2dMap_flat(lua_State *L);
75         static int l_get3dMap(lua_State *L);
76         static int l_get3dMap_flat(lua_State *L);
77
78 public:
79         LuaPerlinNoiseMap(NoiseParams *np, int seed, v3s16 size);
80
81         ~LuaPerlinNoiseMap();
82
83         // LuaPerlinNoiseMap(np, size)
84         // Creates an LuaPerlinNoiseMap and leaves it on top of stack
85         static int create_object(lua_State *L);
86
87         static LuaPerlinNoiseMap *checkobject(lua_State *L, int narg);
88
89         static void Register(lua_State *L);
90 };
91
92 /*
93         LuaPseudoRandom
94 */
95 class LuaPseudoRandom : public ModApiBase {
96 private:
97         PseudoRandom m_pseudo;
98
99         static const char className[];
100         static const luaL_reg methods[];
101
102         // Exported functions
103
104         // garbage collector
105         static int gc_object(lua_State *L);
106
107         // next(self, min=0, max=32767) -> get next value
108         static int l_next(lua_State *L);
109
110 public:
111         LuaPseudoRandom(int seed);
112
113         ~LuaPseudoRandom();
114
115         const PseudoRandom& getItem() const;
116         PseudoRandom& getItem();
117
118         // LuaPseudoRandom(seed)
119         // Creates an LuaPseudoRandom and leaves it on top of stack
120         static int create_object(lua_State *L);
121
122         static LuaPseudoRandom* checkobject(lua_State *L, int narg);
123
124         static void Register(lua_State *L);
125 };
126
127 #endif /* L_NOISE_H_ */