1// SuperTux
2// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17#ifndef HEADER_SUPERTUX_SCRIPTING_FUNCTIONS_HPP
18#define HEADER_SUPERTUX_SCRIPTING_FUNCTIONS_HPP
19
20#ifndef SCRIPTING_API
21#include <squirrel.h>
22#include <string>
23
24#define __suspend
25#define __custom(x)
26#endif
27
28namespace scripting {
29
30/** Display the value of the argument. This is useful for inspecting tables. */
31SQInteger display(HSQUIRRELVM vm) __custom("t.");
32
33/** Displays contents of the current stack */
34void print_stacktrace(HSQUIRRELVM vm);
35
36/** returns the currently running thread */
37SQInteger get_current_thread(HSQUIRRELVM vm) __custom("t");
38
39/** Should use christmas mode */
40bool is_christmas();
41
42/** Display a text file and scrolls it over the screen (on next screenswitch) */
43void display_text_file(const std::string& filename);
44
45/** Load and display a worldmap (on next screenswitch) */
46void load_worldmap(const std::string& filename);
47
48/** Switch to a different worldmap after unloading current one, after exit_screen() is called */
49void set_next_worldmap(const std::string& dirname, const std::string& spawnpoint);
50
51/** Load and display a level (on next screenswitch) */
52void load_level(const std::string& filename);
53
54/** Suspend the script execution for the specified number of seconds */
55void wait(HSQUIRRELVM vm, float seconds) __suspend;
56
57/** Suspend the script execution until the current screen has been changed */
58void wait_for_screenswitch(HSQUIRRELVM vm) __suspend;
59
60/** Exits the currently running screen (force exit from worldmap or scrolling text for example) */
61void exit_screen();
62
63/** Translate a text into the users language (by looking it up in the .po files) */
64std::string translate(const std::string& text);
65std::string _(const std::string& text);
66
67std::string translate_plural(const std::string& text, const std::string&
68 text_plural, int num);
69std::string __(const std::string& text, const std::string& text_plural, int num);
70
71/** Load a script file and executes it. This is typically used to import functions from external files. */
72void import(HSQUIRRELVM v, const std::string& filename);
73
74/** Save world state to scripting table */
75void save_state();
76
77/** Load world state from scripting table */
78void load_state();
79
80/** enable/disable drawing of collision rectangles */
81void debug_collrects(bool enable);
82
83/** enable/disable drawing of fps */
84void debug_show_fps(bool enable);
85
86/** enable/disable drawing of non-solid layers */
87void debug_draw_solids_only(bool enable);
88
89/** enable/disable drawing of editor images */
90void debug_draw_editor_images(bool enable);
91
92/** enable/disable worldmap ghost mode */
93void debug_worldmap_ghost(bool enable);
94
95/** Changes music to musicfile */
96void play_music(const std::string& musicfile);
97
98/** Stops the music */
99void stop_music(float fadetime);
100
101/** Plays a soundfile */
102void play_sound(const std::string& soundfile);
103
104/** Set the game_speed */
105void set_game_speed(float speed);
106
107/** speeds Tux up */
108void grease();
109
110/** makes Tux invincible for 10000 units of time */
111void invincible();
112
113/** makes Tux a ghost, i.e. lets him float around and through solid objects */
114void ghost();
115
116/** recall Tux's invincibility and ghost status */
117void mortal();
118
119/** reinitialise and respawn Tux at the beginning of the current level */
120void restart();
121
122/** print Tux's current coordinates in a level */
123void whereami();
124
125/** move Tux near the end of the level */
126void gotoend();
127
128/** move Tux to the X and Y blocks relative to his position */
129void warp(float offset_x, float offset_y);
130
131/** show the camera's coordinates */
132void camera();
133
134/** adjust gamma */
135void set_gamma(float gamma);
136
137/** exit the game */
138void quit();
139
140/** Returns a random integer */
141int rand();
142
143/** Record a demo to the given file. */
144void record_demo(const std::string& filename);
145
146/** Play back a demo from the given file. */
147void play_demo(const std::string& filename);
148
149} // namespace scripting
150
151#endif
152
153/* EOF */
154