2b690630cf64714cac44867f69059ecca7f37aae
[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
26 #include <string>
27 #include "player_status.hpp"
28 #endif
29
30 namespace Scripting
31 {
32
33 //TODO: Get this from PlayerStatus (update MiniSwig!)
34 static const int KEY_BRASS  = 0x001;
35 static const int KEY_IRON   = 0x002;
36 static const int KEY_BRONZE = 0x004;
37 static const int KEY_SILVER = 0x008;
38 static const int KEY_GOLD   = 0x010;
39
40 /**
41  * Display the value of the argument. This is usefull for inspecting tables.
42  */
43 int display(HSQUIRRELVM vm) __custom;
44
45 /**
46  * Displays contents of the current stack
47  */
48 void print_stacktrace(HSQUIRRELVM vm);
49
50 /**
51  * returns the currently running thread
52  */
53 int get_current_thread(HSQUIRRELVM vm) __custom;
54
55 /**
56  * Display a text file and scrolls it over the screen (on next screenswitch)
57  */
58 void display_text_file(const std::string& filename);
59
60 /**
61  * Load and display a worldmap (on next screenswitch)
62  */
63 void load_worldmap(const std::string& filename);
64
65 /**
66  * Load and display a level (on next screenswitch)
67  */
68 void load_level(const std::string& filename);
69
70 /**
71  * Suspend the script execution for the specified number of seconds
72  */
73 void wait(HSQUIRRELVM vm, float seconds) __suspend;
74
75 /**
76  * Suspend the script execution until the current screen has been changed
77  */
78 void wait_for_screenswitch(HSQUIRRELVM vm) __suspend;
79
80 /**
81  * Exits the currently running screen (force exit from worldmap or scrolling
82  * text for example)
83  */
84 void exit_screen();
85
86 /**
87  * Does a fadeout for the specified number of seconds before next screenchange
88  */
89 void fadeout_screen(float seconds);
90
91 /**
92  * Does a shrinking fade towards the destposition for the specified number of
93  * seconds before next screenchange
94  */
95 void shrink_screen(float dest_x, float dest_y, float seconds);
96
97 /**
98  * Translate a text into the users language (by looking it up in the .po
99  * files)
100  */
101 std::string translate(const std::string& text);
102
103 /**
104  * Load a script file and executes it. This is typically used to import
105  * functions from external files.
106  */
107 void import(HSQUIRRELVM v, const std::string& filename);
108
109 /**
110  * Save world state to savegame
111  */
112 void save_state();
113
114 /**
115  * Add a key to the inventory
116  */
117 void add_key(int new_key);
118
119 /**
120  * enable/disable drawing of collision rectangles
121  */
122 void debug_collrects(bool enable);
123
124 /**
125  * enable/disable drawing of fps
126  */
127 void debug_draw_fps(bool enable);
128
129 /**
130  * enable/disable drawing of non-solid layers
131  */
132 void debug_draw_solids_only(bool enable);
133
134 /**
135  * speeds Tux up
136  */
137 void grease();
138
139 /**
140  * makes Tux invincible for 10000 units of time
141  */
142 void invincible();
143
144 /**
145  * recall Tux's invincibility
146  */
147 void mortal();
148
149 /**
150  * hurt Tux (kill when Small Tux, otherwise lose powerup or shrink)
151  */
152 void shrink();
153
154 /**
155  * kill Tux
156  */
157 void kill();
158
159 /**
160  * reinitialise and respawn Tux at the beginning of the current level
161  */
162 void restart();
163
164 /**
165  * print Tux's current coordinates in a level
166  */
167 void whereami();
168
169 /**
170  * move Tux near the end of the level
171  */
172 void gotoend();
173
174 /**
175  * show the camera's coordinates
176  */
177 void camera();
178
179 /**
180  * exit the game
181  */
182 void quit();
183 }
184
185 #endif
186