This repository was archived by the owner on Aug 29, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathLuaWorld.h
More file actions
168 lines (154 loc) · 2.86 KB
/
Copy pathLuaWorld.h
File metadata and controls
168 lines (154 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#ifndef __LUAWORLD_H__
#define __LUAWORLD_H__
class World {
public:
static int GetTime(lua_State* L)
{
const int args = lua_gettop(L);
if (args == 0)
{
int hour, minute, second;
API::World::GetTime(&hour, &minute, &second);
lua_pushinteger(L, hour);
lua_pushinteger(L, minute);
lua_pushinteger(L, second);
}
else
{
API::Log::Warning("GetTime requires no args.");
lua_pushnil(L);
lua_pushnil(L);
lua_pushnil(L);
}
lua_pop(L, args);
return 3;
}
static int SetTime(lua_State* L)
{
const int args = lua_gettop(L);
if (args == 3)
{
API::World::SetTime(lua_tointeger(L, 1), lua_tointeger(L, 2), lua_tointeger(L, 3));
}
else
{
API::Log::Warning("SetTime requires args (int hour, int minute, int second).");
}
lua_pop(L, args);
return 0;
}
static int GetWeather(lua_State* L)
{
const int args = lua_gettop(L);
if (args == 0)
{
lua_pushstring(L, API::World::GetWeather().c_str());
}
else
{
API::Log::Warning("GetWeather requires no args.");
lua_pushnil(L);
}
lua_pop(L, args);
return 1;
}
static int SetWeather(lua_State* L)
{
const int args = lua_gettop(L);
if (args == 1)
{
API::World::SetWeather(lua_tostring(L, 1));
}
else
{
API::Log::Warning("SetWeather requires args (string weather).");
}
lua_pop(L, args);
return 0;
}
static int LoadIPL(lua_State* L)
{
const int args = lua_gettop(L);
if (args == 1)
{
API::World::LoadIPL(lua_tostring(L, 1));
}
else
{
API::Log::Warning("LoadIPL requires args (string ipl).");
}
lua_pop(L, args);
return 0;
}
static int UnloadIPL(lua_State* L)
{
const int args = lua_gettop(L);
if (args == 1)
{
API::World::UnloadIPL(lua_tostring(L, 1));
}
else
{
API::Log::Warning("UnloadIPL requires args (string ipl).");
}
lua_pop(L, args);
return 0;
}
static int IsBlackout(lua_State* L)
{
const int args = lua_gettop(L);
if (args == 0)
{
lua_pop(L, args);
lua_pushboolean(L, API::World::IsBlackout());
}
else
{
API::Log::Warning("IsBlackout requires no args.");
}
return 1;
}
static int SetBlackout(lua_State* L)
{
const int args = lua_gettop(L);
if (args == 1)
{
API::World::SetBlackout(lua_toboolean(L, 1));
}
else
{
API::Log::Warning("SetBlackout requires args (bool state).");
}
lua_pop(L, args);
return 0;
}
static int IsGroundSnow(lua_State* L)
{
const int args = lua_gettop(L);
if (args == 0)
{
lua_pop(L, args);
lua_pushboolean(L, API::World::IsGroundSnow());
}
else
{
API::Log::Warning("IsGroundSnow requires no args.");
}
return 1;
}
static int SetGroundSnow(lua_State* L)
{
const int args = lua_gettop(L);
if (args == 1)
{
API::World::SetGroundSnow(lua_toboolean(L, 1));
}
else
{
API::Log::Warning("SetGroundSnow requires args (bool state).");
}
lua_pop(L, args);
return 0;
}
};
#endif