4496c13794a8ea73abc8a375ae25a78094ebd19d
[supertux.git] / src / scripting / functions.hpp
1 //  $Id$
2 //
3 //  SuperTux
4 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 #ifndef __FUNCTIONS_H__
21 #define __FUNCTIONS_H__
22
23 #ifndef SCRIPTING_API
24 #define __suspend
25 #define __custom(x)
26 #include <string>
27 #endif
28
29 namespace Scripting
30 {
31
32 /**
33  * Display the value of the argument. This is useful for inspecting tables.
34  */
35 SQInteger display(HSQUIRRELVM vm) __custom("t.");
36
37 /**
38  * Displays contents of the current stack
39  */
40 void print_stacktrace(HSQUIRRELVM vm);
41
42 /**
43  * returns the currently running thread
44  */
45 SQInteger get_current_thread(HSQUIRRELVM vm) __custom("t");
46
47 /**
48  * Display a text file and scrolls it over the screen (on next screenswitch)
49  */
50 void display_text_file(const std::string& filename);
51
52 /**
53  * Load and display a worldmap (on next screenswitch)
54  */
55 void load_worldmap(const std::string& filename);
56
57 /**
58  * Load and display a level (on next screenswitch)
59  */
60 void load_level(const std::string& filename);
61
62 /**
63  * Suspend the script execution for the specified number of seconds
64  */
65 void wait(HSQUIRRELVM vm, float seconds) __suspend;
66
67 /**
68  * Suspend the script execution until the current screen has been changed
69  */
70 void wait_for_screenswitch(HSQUIRRELVM vm) __suspend;
71
72 /**
73  * Exits the currently running screen (force exit from worldmap or scrolling
74  * text for example)
75  */
76 void exit_screen();
77
78 /**
79  * Does a fadeout for the specified number of seconds before next screenchange
80  */
81 void fadeout_screen(float seconds);
82
83 /**
84  * Does a shrinking fade towards the destposition for the specified number of
85  * seconds before next screenchange
86  */
87 void shrink_screen(float dest_x, float dest_y, float seconds);
88
89 /**
90  * Aborts any kind of previous screen fade; the screenchange will happen
91  * anyway.
92  */
93 void abort_screenfade();
94
95 /**
96  * Translate a text into the users language (by looking it up in the .po
97  * files)
98  */
99 std::string translate(const std::string& text);
100
101 /**
102  * Load a script file and executes it. This is typically used to import
103  * functions from external files.
104  */
105 void import(HSQUIRRELVM v, const std::string& filename);
106
107 /**
108  * Save world state to savegame
109  */
110 void save_state();
111
112 /**
113  * Update worldmap from worldmap state (state.world variable)
114  */
115 void update_worldmap();
116
117 /**
118  * enable/disable drawing of collision rectangles
119  */
120 void debug_collrects(bool enable);
121
122 /**
123  * enable/disable drawing of fps
124  */
125 void debug_show_fps(bool enable);
126
127 /**
128  * enable/disable drawing of non-solid layers
129  */
130 void debug_draw_solids_only(bool enable);
131
132 /**
133  * enable/disable worldmap ghost mode
134  */
135 void debug_worldmap_ghost(bool enable);
136
137 /**
138  * Changes music to musicfile
139  */
140 void play_music(const std::string& musicfile);
141
142 /**
143  * Plays a soundfile
144  */
145 void play_sound(const std::string& soundfile);
146
147 /**
148  *  Set the game_speed
149  */
150 void set_game_speed(float speed);
151
152 /**
153  * speeds Tux up
154  */
155 void grease();
156
157 /**
158  * makes Tux invincible for 10000 units of time
159  */
160 void invincible();
161
162 /**
163  * makes Tux a ghost, i.e. lets him float around and through solid objects
164  */
165 void ghost();
166
167 /**
168  * recall Tux's invincibility and ghost status
169  */
170 void mortal();
171
172 /**
173  * reinitialise and respawn Tux at the beginning of the current level
174  */
175 void restart();
176
177 /**
178  * print Tux's current coordinates in a level
179  */
180 void whereami();
181
182 /**
183  * move Tux near the end of the level
184  */
185 void gotoend();
186
187 /**
188  * show the camera's coordinates
189  */
190 void camera();
191
192 /**
193  * adjust gamma
194  */
195 void set_gamma(float gamma);
196
197 /**
198  * exit the game
199  */
200 void quit();
201
202 /**
203  * Returns a random integer
204  */
205 int rand();
206
207 /**
208  * Record a demo to the given file.
209  */
210 void record_demo(const std::string& filename);
211
212 /**
213  * Play back a demo from the given file.
214  */
215 void play_demo(const std::string& filename);
216
217 }
218
219 #endif