From a20fe3321bb51170db89493b769586debb625462 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20Ho=C5=A1ek?= Date: Sat, 8 Oct 2005 13:09:07 +0000 Subject: [PATCH] * Fixed an underquoted definition of PKG_CHECK_MODULES * Updated the scripting docs to mirror the current state of the code SVN-Revision: 2816 --- docs/scripting/scripting.xml | 173 +++++++++++++++++++++++++++++++++---------- mk/autoconf/pkg.m4 | 2 +- 2 files changed, 136 insertions(+), 39 deletions(-) diff --git a/docs/scripting/scripting.xml b/docs/scripting/scripting.xml index 637de978d..b2b6c98d8 100644 --- a/docs/scripting/scripting.xml +++ b/docs/scripting/scripting.xml @@ -21,7 +21,6 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --> - @@ -33,8 +32,7 @@ Suite 330, Boston, MA 02111-1307, USA. Since May 2005, SuperTux sports a Squirrel scripting interface useful for level designers who want to add some interactive pep to their levels. This document poses as a reference article for those who want to explore the various objects of the SuperTux scripting model. What is Squirrel? -One of your first questions might be, "What does a rodent have to do -with a penguin?" Squirrel is a language with a syntax not much unlike other C-like languages (C, C++, Java, ...). In the current implementation, it is integrated as elements in the SuperTux level files. +One of your first questions might be, "What does a rodent have to do with a penguin?" Squirrel is a language with a syntax not much unlike other C-like languages (C, C++, Java, ...). In the current implementation, it is integrated as elements in the SuperTux level files. Squirrel, Scheme and SuperTux I have no clue if the developers simply chose Squirrel just because the name so nicely integrates into the series of words "SuperTux" and "Scheme". Currently, the Squirrel code is integrated in string arguments of Scheme elements in SuperTux level files. (Whew.) This is an example code block inside a level: @@ -60,25 +58,76 @@ When this level loads, the screen fades out completely during two and a half sec If you are interested in an object and what cans of worms you can open with it, this section is for you. "(NYI)" after the function name symbolises functions that haven't been implemented yet. Calling them will result in a line being printed to standard output informing anybody who reads it that the script is using a function that actually doesn't exist. (Win32 users will happily ignore this, because they simply start the application by opening it with Explorer. Unix users are going to be more interested in what SuperTux can actually tell them, so it's better if you don't use non-existent functions in your scripts.) +Global Constants +These constants can be accessed from anywhere in the game code. + +KEY_BRASS +Type: integer +Value: 1 +Represents the brass key. +Used in: add_key as argument 1 + + +KEY_IRON +Type: integer +Value: 2 +Represents the iron key. +Used in: add_key as argument 1 + + +KEY_BRONZE +Type: integer +Value: 4 +Represents the bronze key. +Used in: add_key as argument 1 + + +KEY_SILVER +Type: integer +Value: 8 +Represents the silver key. +Used in: add_key as argument 1 + + +KEY_GOLD +Type: integer +Value: 16 +Represents the gold key. +Used in: add_key as argument 1 + + + + Global Functions These global functions access basic or generic methods of SuperTux. They are called without an object name. display_text_file Usage: display_text_file(string filename) -Effect: Displays the SuperTux text file named filename. (The path is relative to the level file.) +Displays the SuperTux text file named filename. (The path is relative to the level file.) See also: SuperTux file format reference, SuperTux texts -set_wakeup_time -Usage: set_wakeup_time(float waketime) -Effect: When used before a call to suspend(), the script only stays suspended for waketime seconds. +wait +Usage: wait(float time) +Pauses execution of the squirrel code for time seconds. translate Usage: translate(string text) Returns: Translated string -Effect: Translates text into the user's locale. -Note: This construct is not yet recognised by XGetText, and so is subject to change. +Translates text into the user's locale. +Note: This construct is unfortunately not yet recognised by XGetText, so translation files have to be written manually. + + +import +Usage: import(string filename) +Imports and runs the Squirrel script filename. (The path is relative to the level file.) + + +add_key +Usage: add_key(int key) +Adds or removes a key from the player's posession. key should be replaced with one of the KEY_ constants. +See also: src/player_status.hpp @@ -88,23 +137,33 @@ When this level loads, the screen fades out completely during two and a half sec fade_out Usage: DisplayEffect.fade_out(float fadetime) -Effect: Gradually fades out the screen to black for the next fadetime seconds. +Gradually fades out the screen to black for the next fadetime seconds. fade_in Usage: DisplayEffect.fade_in(float fadetime) -Effect: Gradually fades in the screen from black for the next fadetime seconds. +Gradually fades in the screen from black for the next fadetime seconds. set_black Usage: DisplayEffect.set_black(bool black) -Effect: Blackens or un-blackens the screen (depending on the value of black). +Blackens or un-blackens the screen (depending on the value of black). is_black Usage: DisplayEffect.is_black() Returns: bool -Effect: Returns true if the screen has been blackened by set_black. Calling fade_in or fade_out resets the return value to false. +Returns true if the screen has been blackened by set_black. Calling fade_in or fade_out resets the return value to false. + + +sixteen_to_nine +Usage: DisplayEffect.sixteen_to_nine() +Sets the display ratio to 16:9, effectively adding black bars at the top and bottom of the screen. Should be used before cutscenes. + + +four_to_three +Usage: DisplayEffect.four_to_three() +Sets the display ratio to 4:3, removing the black bars added by sixteen_to_nine(). Should be used after cutscenes. @@ -130,27 +189,33 @@ When this level loads, the screen fades out completely during two and a half sec Level -The Level class provides pretty basic controlling functions for the current level. +The Level class provides basic controlling functions for the current level. finish Usage: Level.finish() -Effect: Ends the current level and marks it as completed if launched from a worldmap. +Ends the current level and marks it as completed if launched from a worldmap. Tip: Very useful if you have created a frustrating level and want to, at some point, save the player from agony. spawn Usage: Level.spawn(string sectorname, string spawnpointname) -Effect: Respawns Tux in the sector sectorname at the spawnpointname spawnpoint. +Respawns Tux in the sector sectorname at the spawnpointname spawnpoint. Exceptions: If sectorname or spawnpointname are empty or the specified sector does not exist, the function will bail out first chance it gets. If the specified spawnpoint doesn't exist, Tux will be spawned at the spawnpoint named main. If this spawnpoint doesn't exist either, Tux will simply end up at the origin (top-left 0, 0). +flip_vertically +Usage: Level.flip_vertically() +Flips the level vertically (i.e. top is now bottom and vice versa). Call again to revert the effect. +Tip: Make sure the player can land on something after the level is flipped! + + ScriptedObject A ScriptedObject is basically a SuperTux object that can be scripted to move around and animate. This object will be used in the SuperTux cutscenes a whole lot. Usage notes -Since a ScriptedObject is a reference object and not an active object, you will have to build it into your level file, where a scriptedobject is a child of sector. This is an example definition: +Since a ScriptedObject is a reference object and not a statically declared object, you will have to build it into your level file, where a scriptedobject is a child of sector. This is an example definition: (scripted-object (name "WOOT") @@ -172,69 +237,69 @@ WOOT.set_animation("left"); set_animation Usage: <scriptedobject>.set_animation(string animation_name) -Effect: Activates the sprite's animation specified in animation_name. +Activates the sprite's animation specified in animation_name. get_animation Usage: <scriptedobject>.get_animation() Returns: string -Effect: Returns the name of the sprite's current animation. +Returns the name of the sprite's current animation. move Usage: <scriptedobject>.move(float x, float y) -Effect: Moves the object by x units to the right and y down relative to its current position. +Moves the object by x units to the right and y down relative to its current position. set_pos Usage: <scriptedobject>.set_pos(float x, float y) -Effect: Basically identical to move, except its relativity to the sector origin. +Basically identical to move, except its relativity to the sector origin. get_pos_x Usage: <scriptedobject>.get_pos_x() Returns: float -Effect: Returns the X coordinate of the object's position. +Returns the X coordinate of the object's position. get_pos_y Usage: <scriptedobject>.get_pos_y() Returns: float -Effect: Totally identical to get_pos_x except for its obvious choice of the other (Y) axis. +Totally identical to get_pos_x except for its obvious choice of the other (Y) axis. set_velocity Usage: <scriptedobject>.set_velocity(float x, float y) -Effect: Makes the object move in a certain direction (with a certain speed) given by the x and y coordinates. +Makes the object move in a certain direction (with a certain speed) given by the x and y coordinates. get_velocity_x Usage: <scriptedobject>.get_velocity_x() Returns: float -Effect: Returns the object's velocity in the direction of the X coordinate. +Returns the object's velocity in the direction of the X coordinate. get_velocity_y Usage: <scriptedobject>.get_velocity_y() Returns: float -Effect: The difference between this function and get_velocity_x is just the same like between get_pos_y and get_pos_x: same thing, different coordinates. +The difference between this function and get_velocity_x is just the same like between get_pos_y and get_pos_x: same thing, different coordinates. set_visible Usage: <scriptedobject>.set_visible(bool visible) -Effect: Shows or hides the object according to the value of visible. +Shows or hides the object according to the value of visible. is_visible Usage: <scriptedobject>.is_visible() Returns: bool -Effect: Returns true if the object is visible. (You've seen this coming, haven't you?) +Returns true if the object is visible. (You've seen this coming, haven't you?) get_name Usage: <scriptedobject>.get_name() Returns: string -Effect: Simply gives you the name of the scripted object (as if you didn't have it already...) +Simply gives you the name of the scripted object (as if you didn't have it already...) @@ -242,14 +307,14 @@ WOOT.set_animation("left"); Sound This class provides a very simple interface to the audio subsystem. -play_music (NYI) -Usage: Sound.play_music(string ???) -Warning: This function has not yet been implemented. +play_music +Usage: Sound.play_music(string track_name) +Plays the selected music track (automatically prepending the path to the music folder and appending the .ogg extension). play_sound Usage: Sound.play_sound(string sound_name) -Effect: Plays the sound specified in sound_name (that is identical to the filename of the sound without the .wav extension). +Plays the sound specified in sound_name (that is identical to the filename of the sound without the .wav extension). @@ -259,27 +324,59 @@ WOOT.set_animation("left"); set_text Usage: Text.set_text(string text) -Effect: Sets the text string to be displayed to text. +Sets the text string to be displayed to text. set_font Usage: Text.set_font(string font) -Effect: Sets the font of the text to be displayed to text. Currently valid values are gold, white, blue, gray, big and small. +Sets the font of the text to be displayed to text. Currently valid values are gold, white, blue, gray, big and small. fade_in Usage: Text.fade_in(float time) -Effect: Fades in the specified text for the next time seconds. +Fades in the specified text for the next time seconds. fade_out Usage: Text.fade_out(float time) -Effect: Just the opposite of fade_out. +Just the opposite of fade_out. set_visible Usage: Text.set_visible(bool visible) -Effect: Shows or hides the text abruptly (drastic counterpart to fade_in and fade_out). +Shows or hides the text abruptly (drastic counterpart to fade_in and fade_out). + + +set_centered +Usage: Text.set_centered(bool centered) +If centered is true, the text will be centered on the screen. Otherwise, it will be left-aligned. + + + + +Player +This module contains methods controlling the player. (No, SuperTux doesn't use mind control. Player refers to the player object.) + +make_invincible +Usage: Player.make_invincible() +Makes the player invincible for a predefined amount of time. +See also: TUX_INVINCIBLE_TIME in src/object/player.hpp for the amount of seconds that the player becomes invincible. + + +deactivate +Usage: Player.deactivate() +Stops the player and blocks the movement controls. +Tip: Don't call this in front of a horde of badguys. + + +activate +Usage: Player.activate() +Reactivates the player's movement controls. + + +walk +Usage: Player.walk(float velocity) +Makes the player move in a certain horizontal velocity (specified by velocity). A negative velocity moves the player to the left. diff --git a/mk/autoconf/pkg.m4 b/mk/autoconf/pkg.m4 index c80e0acfc..f2bfc2d49 100644 --- a/mk/autoconf/pkg.m4 +++ b/mk/autoconf/pkg.m4 @@ -2,7 +2,7 @@ dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page dnl also defines GSTUFF_PKG_ERRORS on error -AC_DEFUN(PKG_CHECK_MODULES, [ +AC_DEFUN([PKG_CHECK_MODULES], [ succeeded=no if test -z "$PKG_CONFIG"; then -- 2.11.0