]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/lua_api/l_noise.h
Fix itemstack:add item not working correct
[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 extern "C" {
24 #include <lua.h>
25 #include <lauxlib.h>
26 }
27
28 #include "irr_v3d.h"
29 #include "noise.h"
30
31 class LuaPerlinNoise
32 {
33 private:
34         int seed;
35         int octaves;
36         float persistence;
37         float scale;
38         static const char className[];
39         static const luaL_reg methods[];
40
41         // Exported functions
42
43         // garbage collector
44         static int gc_object(lua_State *L);
45
46         static int l_get2d(lua_State *L);
47         static int l_get3d(lua_State *L);
48
49 public:
50         LuaPerlinNoise(int a_seed, int a_octaves, float a_persistence,
51                         float a_scale);
52
53         ~LuaPerlinNoise();
54
55         // LuaPerlinNoise(seed, octaves, persistence, scale)
56         // Creates an LuaPerlinNoise and leaves it on top of stack
57         static int create_object(lua_State *L);
58
59         static LuaPerlinNoise* checkobject(lua_State *L, int narg);
60
61         static void Register(lua_State *L);
62 };
63
64 /*
65   PerlinNoiseMap
66  */
67 class LuaPerlinNoiseMap
68 {
69 private:
70         Noise *noise;
71         static const char className[];
72         static const luaL_reg methods[];
73
74         static int gc_object(lua_State *L);
75
76         static int l_get2dMap(lua_State *L);
77
78         static int l_get3dMap(lua_State *L);
79
80 public:
81         LuaPerlinNoiseMap(NoiseParams *np, int seed, v3s16 size);
82
83         ~LuaPerlinNoiseMap();
84
85         // LuaPerlinNoiseMap(np, size)
86         // Creates an LuaPerlinNoiseMap and leaves it on top of stack
87         static int create_object(lua_State *L);
88
89         static LuaPerlinNoiseMap *checkobject(lua_State *L, int narg);
90
91         static void Register(lua_State *L);
92 };
93
94 /*
95         LuaPseudoRandom
96 */
97
98
99 class LuaPseudoRandom
100 {
101 private:
102         PseudoRandom m_pseudo;
103
104         static const char className[];
105         static const luaL_reg methods[];
106
107         // Exported functions
108
109         // garbage collector
110         static int gc_object(lua_State *L);
111
112         // next(self, min=0, max=32767) -> get next value
113         static int l_next(lua_State *L);
114
115 public:
116         LuaPseudoRandom(int seed);
117
118         ~LuaPseudoRandom();
119
120         const PseudoRandom& getItem() const;
121         PseudoRandom& getItem();
122
123         // LuaPseudoRandom(seed)
124         // Creates an LuaPseudoRandom and leaves it on top of stack
125         static int create_object(lua_State *L);
126
127         static LuaPseudoRandom* checkobject(lua_State *L, int narg);
128
129         static void Register(lua_State *L);
130 };
131
132 NoiseParams *read_noiseparams(lua_State *L, int index);
133
134 #endif /* L_NOISE_H_ */