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

Difference between revisions of "ScriptingPlatform"

From SuperTux
Jump to: navigation, search
(cat)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
  
= Summary =
+
== Summary ==
  
 
A [[Moving platform]] that was given a name can be controlled by scripts.
 
A [[Moving platform]] that was given a name can be controlled by scripts.
  
= Example =
+
== Instances ==
 +
An instance is created by being defined in a level. It may be accessed via its <tt>name</tt> from scripts and via <tt>sector.<i>name</i></tt> from the console.
 +
 
 +
=== Example ===
  
 
Example of a definition:
 
Example of a definition:
Line 33: Line 36:
 
  </pre>
 
  </pre>
  
= Methods =
+
From console:
 +
 
 +
<pre>
 +
  sector.PLATFORM1.goto_node(1);
 +
</pre>
 +
 
 +
== Methods ==
 
{| class="objectlist"
 
{| class="objectlist"
 
! class="method"| goto_node(int node_no)
 
! class="method"| goto_node(int node_no)
Line 45: Line 54:
 
|}
 
|}
  
= Constants =
+
== Constants ==
  
 
None
 
None
  
 
[[Category:Scripting Reference]]
 
[[Category:Scripting Reference]]

Revision as of 05:50, 25 June 2007


Summary

A Moving platform that was given a name can be controlled by scripts.

Instances

An instance is created by being defined in a level. It may be accessed via its name from scripts and via sector.name from the console.

Example

Example of a definition:

  (platform
    (name "PLATFORM1")
    (running #f)
    (sprite "images/objects/platforms/vertical-wood.sprite")
    (path
      (mode "circular")
      (node
        (x 832)
        (y 800)
      )
      (node
        (x 832)
        (y 704)
      )
    )
  ) 
 

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

  PLATFORM1.goto_node(0);
 

From console:

  sector.PLATFORM1.goto_node(1);

Methods

goto_node(int node_no) advance until at given node, then stop.
start_moving() start advancing automatically
stop_moving() stop advancing automatically

Constants

None