This wiki has been moved to https://github.com/SuperTux/wiki into the mediawiki branch.

ScriptingLevel

From SuperTux
Revision as of 10:31, 9 December 2015 by Hume (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Summary

The Level class provides basic controlling functions for the current level.

Instances

An instance named Level is available from scripts and the console. (Note: class and eponymous instance might create potential conflicts – the name of one might be changed eventually)

Methods

finish(bool win) Ends the current level. If you set win to true, the level is marked 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(string sectorname, string spawnpointname) 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() 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!
toggle_pause() Toggle pause
Level_edit(bool editing) Change to/from edit mode

Constants

None

Example code

Teleportation

The following code teleports the player to spawnpoint "main" in sector "underground".

(scripttrigger
  (script "Level.spawn(\"underground\", \"main\");]]")
  (button #f)
  ...
)
Scripting reference
Ambient sound · Camera · Candle · Display effect · Floating image · Globals · Level · Level time · Path · Platform · Player · Scripted object · Sector · Sound · Text · Thunderstorm · Tilemap · Will-o-wisp · Wind