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

ScriptingScriptedObject

From SuperTux
Revision as of 07:10, 17 April 2006 by MatzeB (Talk | contribs)

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

Summary

A ScriptedObject is basically a SuperTux object that can be scripted to move around and animate. You can created ScriptedObjects by defining them in level files. Each scripted object will be exposed under its name to the scripting engine.

Example

Example of a definition:

  (scriptedobject
    (x 2291)
    (y 1275)
    (name "SUPERTUX")
    (sprite "images/creatures/tux_big/tux.sprite")
    (layer 100)
    (visible #t)
    (physic-enabled #t)
    (solid #t)
  ) 
 

The above object will be exposed under the name SUPERTUX in the scripting engine. Example usage:

  // This script will make tux look and walk left/right (this should make him appear
  //   "upset")
  SUPERTUX.set_action("stand-right");
  wait(2);
  SUPERTUX.set_velocity(200,0);
  wait(0.3);
  SUPERTUX.set_velocity(0,0);
  wait(0.4);
  SUPERTUX.set_action("stand-left");
  SUPERTUX.set_velocity(-200,0);
  wait(0.3);
 

Methods

Constants