/
functions.hpp
306 lines (256 loc) · 7.2 KB
/
functions.hpp
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
// SuperTux
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef HEADER_SUPERTUX_SCRIPTING_FUNCTIONS_HPP
#define HEADER_SUPERTUX_SCRIPTING_FUNCTIONS_HPP
#ifndef SCRIPTING_API
#include <squirrel.h>
#include <string>
#define __suspend
#define __custom(x)
#endif
namespace scripting {
#ifdef DOXYGEN_SCRIPTING
/**
* @summary This module contains global methods.
*/
class Globals
{
public:
#endif
/**
* Displays the value of an argument. This is useful for inspecting tables.
* @param ANY $object
*/
SQInteger display(HSQUIRRELVM vm) __custom("t.");
/**
* Displays the contents of the current stack.
*/
void print_stacktrace(HSQUIRRELVM vm);
/**
* Returns the currently running thread.
*/
SQInteger get_current_thread(HSQUIRRELVM vm) __custom("t");
/**
* Returns whether the game is in christmas mode.
*/
bool is_christmas();
/**
* Displays a text file and scrolls it over the screen (on next screenswitch).
* @param string $filename
*/
void display_text_file(const std::string& filename);
/**
* Loads and displays a worldmap (on next screenswitch), using the savegame of the current worldmap.
* @param string $filename
* @param string $sector Forced sector to spawn in the worldmap on. Leave empty to use last sector from savegame.
* @param string $spawnpoint Forced spawnpoint to spawn in the worldmap on. Leave empty to use last position from savegame.
*/
void load_worldmap(const std::string& filename, const std::string& sector, const std::string& spawnpoint);
/**
* Switches to a different worldmap after unloading the current one, after ""exit_screen()"" is called.
* @param string $dirname The world directory, where the "worldmap.stwm" file is located.
* @param string $sector Forced sector to spawn in the worldmap on. Leave empty to use last sector from savegame.
* @param string $spawnpoint Forced spawnpoint to spawn in the worldmap on. Leave empty to use last position from savegame.
*/
void set_next_worldmap(const std::string& dirname, const std::string& sector, const std::string& spawnpoint);
/**
* Loads and displays a level (on next screenswitch), using the savegame of the current level.
* @param string $filename
*/
void load_level(const std::string& filename);
/**
* Starts a skippable cutscene.
*/
void start_cutscene();
/**
* Ends a skippable cutscene.
*/
void end_cutscene();
/**
* Checks if a skippable cutscene is currently running.
*/
bool check_cutscene();
/**
* Suspends the script execution for a specified number of seconds.
* @param float $seconds
*/
void wait(HSQUIRRELVM vm, float seconds) __suspend;
/**
* Suspends the script execution until the current screen has been changed.
*/
void wait_for_screenswitch(HSQUIRRELVM vm) __suspend;
/**
* Exits the currently running screen (for example, force exits from worldmap or scrolling text).
*/
void exit_screen();
/**
* Translates a text into the user's language (by looking in the "".po"" files).
* @param string $text
*/
std::string translate(const std::string& text);
/**
* Same function as ""translate()"".
* @param string $text
*/
std::string _(const std::string& text);
/**
* Translates a text into the user's language (by looking in the "".po"" files).
Returns ""text"" or ""text_plural"", depending on ""num"" and the locale.
* @param string $text
* @param string $text_plural
* @param int $num
*/
std::string translate_plural(const std::string& text, const std::string&
text_plural, int num);
/**
* Same function as ""translate_plural()"".
* @param string $text
* @param string $text_plural
* @param int $num
*/
std::string __(const std::string& text, const std::string& text_plural, int num);
/**
* Loads a script file and executes it. This is typically used to import functions from external files.
* @param string $filename
*/
void import(HSQUIRRELVM v, const std::string& filename);
/**
* Saves world state to scripting table.
*/
void save_state();
/**
* Loads world state from scripting table.
*/
void load_state();
/**
* Enables/disables drawing of collision rectangles.
* @param bool $enable
*/
void debug_collrects(bool enable);
/**
* Enables/disables drawing of FPS.
* @param bool $enable
*/
void debug_show_fps(bool enable);
/**
* Enables/disables drawing of non-solid layers.
* @param bool $enable
*/
void debug_draw_solids_only(bool enable);
/**
* Enables/disables drawing of editor images.
* @param bool $enable
*/
void debug_draw_editor_images(bool enable);
/**
* Enables/disables worldmap ghost mode.
* @param bool $enable
*/
void debug_worldmap_ghost(bool enable);
/**
* Changes the music to ""musicfile"".
* @param string $musicfile
*/
void play_music(const std::string& musicfile);
/**
* Fades in the music from ""musicfile"" for ""fadetime"" seconds.
* @param string $musicfile
* @param float $fadetime
*/
void fade_in_music(const std::string& musicfile, float fadetime);
/**
* Fades out the music for ""fadetime"" seconds.
* @param float $fadetime Set to "0" for no fade-out.
*/
void stop_music(float fadetime);
/**
* Resumes and fades in the music for ""fadetime"" seconds.
* @param float $fadetime Set to "0" for no fade-in.
*/
void resume_music(float fadetime);
/**
* Pauses the music with a fade-out for ""fadetime"" seconds.
* @param float $fadetime Set to "0" for no fade-out.
*/
void pause_music(float fadetime);
/**
* Plays ""soundfile"" as a sound.
* @param string $soundfile
*/
void play_sound(const std::string& soundfile);
/**
* Sets the game speed to ""speed"".
* @param float $speed
*/
void set_game_speed(float speed);
/**
* Speeds Tux up.
*/
void grease();
/**
* Makes Tux invincible for 10000 units of time.
*/
void invincible();
/**
* Makes Tux a ghost, i.e. lets him float around and through solid objects.
*/
void ghost();
/**
* Recalls Tux's invincibility and ghost status.
*/
void mortal();
/**
* Re-initializes and respawns Tux at the beginning of the current level.
*/
void restart();
/**
* Prints Tux's current coordinates in the current level.
*/
void whereami();
/**
* Moves Tux near the end of the current level.
*/
void gotoend();
/**
* Moves Tux to the X and Y blocks, relative to his position.
* @param float $offset_x
* @param float $offset_y
*/
void warp(float offset_x, float offset_y);
/**
* Shows the camera's coordinates.
*/
void camera();
/**
* Adjusts the gamma.
* @param float $gamma
*/
void set_gamma(float gamma);
/**
* Returns a random integer.
*/
int rand();
/**
* Sets the frame, displayed on the title screen.
* @param string $image
*/
void set_title_frame(const std::string& image);
#ifdef DOXYGEN_SCRIPTING
}
#endif
} // namespace scripting
#endif
/* EOF */