-
-
Notifications
You must be signed in to change notification settings - Fork 494
ScriptingPlayer
SuperTux Bot edited this page Jan 17, 2025
·
17 revisions
This file is auto-generated from the SuperTux source code, using the template ScriptingPage.md.
This module contains methods controlling the player. (No, SuperTux doesn't use mind control. Player
refers to the type of the player object.)
The first player can be accessed using Tux
, or sector.Tux
from the console. All following players (2nd, 3rd, etc...) can be accessed by Tux{index}
. For example, to access the 2nd player, use Tux1
(or sector.Tux1
from the console).
This class inherits functions and variables from the following base classes:
Method | Explanation |
---|---|
void use_scripting_controller(bool enable) |
Uses a scriptable controller for all user input (or restores controls). |
void do_scripting_controller(string control, bool pressed) |
Instructs the scriptable controller to press or release a button. control - Can be “left”, “right”, “up”, “down”, “jump”, “action”, “start”, “escape”, “menu-select”, “menu-select-space”, “menu-back”, “remove”, “cheat-menu”, “debug-menu”, “console”, “peek-left”, “peek-right”, “peek-up” or “peek-down”. |
void kill(bool completely) |
Hurts Tux. completely - If true, he will be killed even if he had "grow" or a superior bonus. |
bool add_bonus(string bonus) |
Gives Tux the specified bonus unless Tux’s current bonus is superior. bonus - Can be "grow", "fireflower", "iceflower", "airflower" or "earthflower" at the moment. |
bool set_bonus(string bonus) |
Gives Tux the specified bonus. bonus - Can be "grow", "fireflower", "iceflower", "airflower" or "earthflower" at the moment. |
string get_bonus() |
Returns Tux's current bonus. |
void add_coins(int count) |
Gives the player a number of coins. If count is a negative amount of coins, that number of coins will be taken from the player (until the number of coins the player has is 0, when it will stop changing). |
int get_coins() |
Returns the number of coins the player currently has. |
void kick() |
Start kick animation. |
string get_action() |
Gets the player's current action/animation. |
void do_cheer() |
Play cheer animation. This might need some space and behave in an unpredictable way. It's best to use this at level end. |
void do_duck() |
Makes Tux duck down, if possible. Won't last long, as long as input is enabled. |
void do_standup() |
Makes Tux stand back up, if possible. |
void do_standup() |
Makes Tux stand back up, if possible. |
void do_backflip() |
Makes Tux do a backflip, if possible. |
void do_jump(float yspeed) |
Makes Tux jump in the air, if possible. yspeed - Sensible values are negative - unless we want to jump into the ground of course. |
float get_velocity_x() |
Returns Tux’s velocity in X direction. |
float get_velocity_y() |
Returns Tux’s velocity in Y direction. |
void set_velocity(float x, float y) |
Sets the velocity of the player to a programmable/variable speed. x - The speed Tux will move on the x axis. y - The speed Tux will move on the y axis. |
void set_visible(bool visible) |
Set Tux visible or invisible. |
bool get_visible() |
Returns true if Tux is currently visible (has not been set invisible by the set_visible() method). |
void set_is_intentionally_safe(bool safe) |
Make tux invincible without the star effect. |
bool get_is_intentionally_safe() |
Returns true if Tux is currently intentionally safe. |
bool has_grabbed(string name) |
Returns whether the player is carrying a certain object. name - Name of the portable object to check for. |
void set_ghost_mode(bool enable) |
Switches ghost mode on/off. Lets Tux float around and through solid objects. |
bool get_ghost_mode() |
Returns whether ghost mode is currently enabled. |
void trigger_sequence(string sequence_name) |
Orders the current GameSession to start a sequence. sequence_name - One of “stoptux”, “endsequence” or “fireworks”. |
void activate() |
Give control back to user/scripting. |
void deactivate() |
Deactivate user/scripting input for Tux. Carried items like trampolines won't be dropped. |
bool get_input_pressed(string input) |
Gets whether the current input on the keyboard/controller/touchpad has been pressed. input - Can be “left”, “right”, “up”, “down”, “jump”, “action”, "item", “start”, “escape”, “menu-select”, “menu-select-space”, “menu-back”, “remove”, “cheat-menu”, “debug-menu”, “console”, “peek-left”, “peek-right”, “peek-up” or “peek-down”. |
bool get_input_held(string input) |
Gets whether the current input on the keyboard/controller/touchpad is being held. input - Valid values are listed above. |
bool get_input_released(string input) |
Gets whether the current input on the keyboard/controller/touchpad has been released. input - Valid values are listed above. |
void walk(float speed) |
Makes Tux walk. |
void set_dir(bool right) |
Face Tux in the proper direction. right - Set to true to make Tux face right, false to face left. |
void eject_item_pocket() |
Ejects the item in the player's Item Pocket. |
int get_item_pocket() |
Returns the item currently in the player's Item Pocket as a BONUS enum value. |
void set_item_pocket() |
Ejects the item in the player's Item Pocket. |
Variable | Explanation |
---|---|
bool is_intentionally_safe |
Determines whether Tux is invincible. |
bool visible |
Determines whether Tux is visible. |
None.
Home
Guidelines
Game Mechanics
Tools
Engine
- Cameras in other games
- Collision
- Configuration File
- Console
- Cutscenes
- Game_Engine
- Lighting
- Map_transformer
- Portables
- SceneGraph
- Scripting
Specifications
Milestones
- Milestone 1 Analysis
- Milestone 2 Design Document
- Milestone 2 Design Document Old
- Milestone 3 Design Document
Building (mostly outdated)
- INSTALL.md
- Building
- Building on macOS
- Building SuperTux
- Building on Windows
- Building with MXE (cross-compile)
Meetings