https://wiki.xmoto.tuxfamily.org/api.php?action=feedcontributions&user=Nadenislamarre&feedformat=atomX-Moto - User contributions [en]2024-03-28T20:03:36ZUser contributionsMediaWiki 1.28.2https://wiki.xmoto.tuxfamily.org/index.php?title=XMoto_tuxfamily_infrastructure&diff=6865XMoto tuxfamily infrastructure2014-10-11T07:02:06Z<p>Nadenislamarre: Created page with '=Web server= == Mysql Database== ===Actions=== No special actions to do. == Http Server== The web server is available with a tuxfamily account granted to xmoto. You can manage i…'</p>
<hr />
<div>=Web server=<br />
== Mysql Database==<br />
===Actions===<br />
No special actions to do.<br />
<br />
== Http Server==<br />
The web server is available with a tuxfamily account granted to xmoto.<br />
You can manage it from the tuxfamily.org website.<br />
It is decomposed in 2 parts :<br />
<br />
* the executables files (.php), and some residual files<br />
* the repository : static files (such as replays), are sent over a light http web server (for performances/cpu issues).<br />
<br />
===Actions===<br />
Occasionnaly, space must be done on the repository server.<br />
You can check the free space via the tuxfamily panel in the xmoto project (the value is not in real time, it is updated every X minutes).<br />
<br />
To make space :<br />
Remove unsed rooms (unused for 1 year)<br />
* go to this url : http://xmoto.tuxfamily.org/index.php?page=rooms_admin&action=clean<br />
<br />
Remove old highscores (kept by the website in case of mistake) :<br />
* go in Administration/Advanced/Technics/Purges and Administration/Advanced/Technics/Files and click on all links<br />
<br />
* Connect to ssh.tuxfamily.org and run the following commands to remove delete rooms physically :<br />
mkdir -p tmp<br />
ls -1 xmoto/xmoto-repository/www/replays | sort -n > tmp/roomList_dir.txt<br />
echo "select id from rooms order by id;" | mysql -h sql -u xmoto_website -p"password" xmoto_website > tmp/roomList_db.txt<br />
diff tmp/roomList_db.txt tmp/roomList_dir.txt | grep -E "^>" | sed -e s+"^> "+""+ > tmp/result.txt<br />
cat ~/tmp/result.txt | while read A; do rm -rf ~/xmoto/xmoto-repository/www/replays/"$A"; done<br />
<br />
<br />
<br />
<br />
<br />
==Repository Server==<br />
<br />
=Game Server=<br />
The game server (available from games.tuxfamily.org) is thym.tuxfamily.org.<br />
The xmoto game is installed and run with the -server option.<br />
It is restarted automatically every 3 days to include new levels, and in case of crash.<br />
<br />
===Actions===<br />
Sometimes, the host is upgraded. It is required to recompile xmoto and reinstall it.</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Main_Page&diff=6864Main Page2014-10-11T06:46:08Z<p>Nadenislamarre: /* Development */</p>
<hr />
<div>__NOTOC__<br />
<br />
[[de:Main_Page|Deutsch]] - [[ca:Main_Page|Català]] - [[es:Main_Page|Español]] - [[fr:Main_Page|Français]] - [[no:Main_Page|Norsk]] - [[pt:Main_Page|Portuguese]] -<br />
[[fi:Main_Page|Suomi]]<br />
<br />
== Information ==<br />
<br />
* [http://xmoto.tuxfamily.org/ X-Moto Home Page]<br />
* [[manual|X-Moto Manual]]<br />
* [[How to install X-Moto on your computer]]<br />
* [http://forum.xmoto.tuxfamily.org X-Moto Forum]<br />
* [[Server command line|X-Moto server command line]]<br />
* [[Screenshots]]<br />
* [[Faq|FAQ]]<br />
* [[Philip's_xmoto_guide|Philips X-Moto Guide]]<br />
* [[X-Moto on PSP]]<br />
* [[IRC tutorial]]<br />
* [[Public X-Moto servers]]<br />
* [[Wiki Contributors]]<br />
* [[Server rules (slave mode)]]<br />
* [[Network Rules]]<br />
<br />
<br />
'''Features'''<br />
* [[Use X-Moto on a USB-Key]]<br />
* [[Use private rooms in game (instead of World Highscores)]]<br />
* [[Joystick|Using a joystick to control the game]]<br />
* [[Wiimote|Using a wiimote to control the game]]<br />
* [[record_video|Recording Ingame Videos]]<br />
* [[Convert a replay to a video]]<br />
* [[Recording videos with an external program]]<br />
* [[how to capture, edit and create a movie]]<br />
<br />
== Level Creation ==<br />
<br />
*[[About good level design]]<br />
*[[Level Checklist (for Creators and Testers)]]<br />
*[[*Awesome~Style*'s Gfx Guide]]<br />
*[[Level FAQ]]<br />
*[[Notes on Checkpoints]]<br />
<br />
'''Inksmoto Level Editor'''<br />
* [[How to install Inksmoto into Inkscape]]<br />
* [[How to create smooth levels using Inkscape|How to create a smooth level with Inksmoto Level Editor]]<br />
* [[xmoto-edit|How to create a level with xmoto-edit (DEPRECATED)]]<br />
* [[Scripted levels|How to create a scripted level (please look scripting section below)]]<br />
* [[Others tips to make levels]]<br />
* [[Shortcuts for most used actions in the editor]]<br />
* [[Video tutorials]]<br />
* [[Known Issues when using Inksmoto]]<br />
'''Themes and Graphics'''<br />
* [[Make a theme|Make a theme/add a new sprite or texture]]<br />
* [[textures_creation|How to handle your own textures for level creation]]<br />
* [[How to create, test and upload an animated sprite]]<br />
* [[Background graphics pool|Background Graphics Pool]]<br />
* [[sprites_pool|Sprites Pool 4 Gimp]]<br />
* [[Svg Block Pool]]<br />
* [[Transparent Water|How to make transparent water]]<br />
'''Scripting'''<br />
* [[Basics of Scripting]]<br />
* [[How to include Scripts into a Level]]<br />
* [[LTS - Learn To Script Series]]<br />
* [[Funtions for Game Events| Funtions for Game Events (Zones, OnSomersaults, etc.)]]<br />
* [[Scripted levels| List of Scripting Functions]]<br />
* [[Level alteration Functions| Level alteration Functions (Blocks, Physics, etc.)]]<br />
* [[Player Functions| Player Functions (Win, Kill,Positioning, etc.) )]]<br />
* [[Camera Functions| Camera Functions (Zooming, Rotation, etc.)]]<br />
* [[Sound Functions]]<br />
'''Mods, Scripts and Helpers'''<br />
* [[Skate Park Mod]]<br />
* [[Camera Scripts]]<br />
* [[Helpers]]<br />
<br />
== Building XMoto ==<br />
* [[Build for Unix (like GNU/Linux)]]<br />
* [[Build for MacOSX]]<br />
* [[Build for Windows]]<br />
* [[Build from SVN]]<br />
* [[Build with CMake (experimental)]]<br />
<br />
== Administration ==<br />
* [[How to validate a highscore]]<br />
* [[How to validate a level]]<br />
* [[How to validate a sprite]]<br />
* [[Forum's administration changes]]<br />
* [[How to unvalidate a highscore]]<br />
* [[How to update po pictures]]<br />
* [[How to remove a validated level]]<br />
<br />
== Development ==<br />
* [[Code documentation]]<br />
* [[Contributions|How to contribute to X-Moto]]<br />
* [[Translate X-Moto and X-Moto Website into your language]]<br />
* [[File formats]]<br />
* [[Net protocol]]<br />
* [[Access to the website sources]]<br />
* [[SDL_gfx|SDL_gfx porting effort]]<br />
* [[Chipmunk integration]]<br />
* [[Level collection list]]<br />
* [[Multiplayer design]]<br />
* [[Deliver a X-Moto version MEMO]]<br />
* [[Rooms competition idea]]<br />
* [[How to make lan server]]<br />
* [[XMoto tuxfamily infrastructure]]</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Build_from_SVN&diff=6863Build from SVN2014-06-01T11:35:13Z<p>Nadenislamarre: /* Windows */</p>
<hr />
<div>[[Ca:Compilacio SVN|Català]] - [[Es:Compilacion SVN|Español]] - [[No:Kompilere_fra_SVN|Norsk]] - [[Fr:Compilation_depuis_SVN|Francais]]<br />
<br />
<br />
== Quick compilation ==<br />
=== Linux / Ubuntu ===<br />
* Install prerequisites<br />
sudo apt-get install subversion build-essential automake1.9 libsqlite3-dev libjpeg62-dev libbz2-dev libsdl-mixer1.2-dev<br />
sudo apt-get install libsdl-net1.2-dev liblua5.1-0-dev libode-dev zlib1g-dev libpng12-dev libglu1-mesa-dev libsdl-ttf2.0-dev<br />
sudo apt-get install libcurl3-openssl-dev libxdg-basedir-dev libxml2-dev gettext<br />
<br />
* Get X-Moto sources<br />
svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk xmoto_trunk<br />
<br />
* Compile sources<br />
cd xmoto_trunk<br />
./configure --prefix=$HOME/xmoto_install --with-unoptimized=1<br />
make<br />
make install<br />
<br />
* Run X-Moto<br />
./src/xmoto<br />
<br />
<br />
=== Windows ===<br />
X-Moto for windows (xmoto.exe) is built from a linux system.<br />
<br />
* Install VirtualBox or any virtualisation system<br />
* Install Linux/Ubuntu inside<br />
* Install prerequisites<br />
* Install mingw_lib.zip<br />
* Compile sources<br />
<br />
== SVN ? ==<br />
<br />
X-Moto uses SVN to develop the game. With SVN files, you have access to new features and... new bugs.<br />
Use svn files only if you know what you are doing. otherwise just go download the stable release from the main page http://xmoto.tuxfamily.org<br />
<br />
You must know that sources downloaded from SVN should not be compiled sometimes !<br />
<br />
[http://en.wikipedia.org/wiki/Subversion_%28software%29 http://en.wikipedia.org/wiki/Subversion_%28software%29]<br />
<br />
=== Download latest files with SVN ===<br />
<br />
The first time you download the svn version you will need to download all the files under "xmoto/" :<br />
<br />
svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk xmoto<br />
<br />
or if you are a developer<br />
<br />
svn co svn+ssh://$USER@svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk xmoto<br />
<br />
(you can upload you public ssh keys to the root of your ftp account on ftp://$USER@ftp.tuxfamily.org/ in a file called ssh_keys)<br />
<br />
Note that there are a lot of graphical clients to use svn if you're afraid of the command line.<br />
<br />
=== Update the files ===<br />
<br />
When you have already download from svn once, you can update the files with this command :<br />
<br />
# svn update<br />
<br />
=== Web access ===<br />
http://svn.tuxfamily.org/viewvc.cgi/?root=xmoto_xmoto<br />
<br />
=== Notification via rss ===<br />
http://svnweb.tuxfamily.org/rss.php?repname=xmoto+%28xmoto%29&path=%2F&rev=0&sc=0&isdir=1<br />
<br />
== Build ==<br />
<br />
=== Dependencies ===<br />
<br />
X-Moto must have the following to compile properly :<br />
<br />
* Latest gcc and g++<br />
* SDL development libraries and headers<br />
* OpenGL development libraries and headers<br />
* SDL_mixer with headers<br />
* SDL_net with headers<br />
* libjpeg with headers<br />
* libpng with headers<br />
* zlib with headers<br />
* libbzip2 with headers<br />
* liblua50 with headers<br />
* liblualib50 with headers<br />
* libode with headers<br />
* libcurl3 with headers<br />
* libxml2 development libraries<br />
* automake >= 1.9<br />
<br />
sudo apt-get install subversion build-essential automake1.9 libsqlite3-dev libjpeg62-dev libbz2-dev libsdl-mixer1.2-dev<br />
sudo apt-get install libsdl-net1.2-dev liblua5.1-0-dev libode-dev zlib1g-dev libpng12-dev libglu1-mesa-dev libsdl-ttf2.0-dev<br />
sudo apt-get install libcurl3-openssl-dev libxdg-basedir-dev libxml2-dev gettext<br />
<br />
To build windows version from linux, you'll need the following extra packages <br />
sudo apt-get install tofrodos nsis mingw32<br />
<br />
Use mingw32 3.4.5.20060117.1.dfsg-3 from gusty for ubuntu otherwise, .exe built are instables<br />
<br />
But with the new features, new dependencies can be asked.<br />
<br />
=== automatic builds ===<br />
sudo apt-get install devscripts libcurl4-gnutls-dev debhelper<br />
mkdir $HOME/xm/builds<br />
cd $HOME/xm/builds<br />
cp /path/to/svn/tools/tuxfamily_fullBuild.sh .<br />
cp /path/to/svn/tools/buildPackages.sh .<br />
svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk trunk<br />
mkdir sources<br />
mkdir windows<br />
# edit the 5 first lines of tuxfamily_fullBuild.sh to change the path and the username for the scp<br />
./tuxfamily_fullBuild.sh<br />
<br />
=== Ok, I can build it ! ===<br />
<br />
$ cd xmoto<br />
$ sh ./bootstrap<br />
$ ./configure<br />
$ make<br />
# make install<br />
<br />
Right now, you can start xmoto with "<code>src/xmoto</code>".<br />
<br />
If sh ./bootstrap failed, you have to edit the ./bootstrap file manually:<br />
aclocal -I config $ACLOCAL_FLAGS\<br />
&& automake --gnu --add-missing --copy \<br />
<br />
so it looks like that:<br />
aclocal-1.9 -I config $ACLOCAL_FLAGS\<br />
&& automake-1.9 --gnu --add-missing --copy \<br />
<br />
=== Doesn't work ? ===<br />
<br />
xmoto.bin not found !<br />
You probably reconfigure without making clean. Do:<br />
make clean<br />
./configure<br />
make<br />
sudo make install<br />
Problems with translations:<br />
make[1]: Entering directory `/home/yourusername/xmoto-dev-folder/po'<br />
rm -f fr_FR.gmo && : -c --statistics -o fr_FR.gmo fr_FR.po<br />
mv: cannot stat `t-fr_FR.gmo': No such file or directory<br />
make[1]: *** [fr_FR.gmo] Error 1<br />
make[1]: Leaving directory `/home/tuhoojabotti/xmoto-dev-folder/po'<br />
make: *** [update-po] Error 2<br />
<br />
SOLUTION (ought to work):<br />
sudo apt-get install gettext<br />
./configure<br />
cd po/<br />
make update-po<br />
cd ..<br />
make<br />
sudo make install<br />
<br />
=== Need help ? ===<br />
Join us on IRC, the channel is #xmoto on the freenode servers.<br />
irc://irc.freenode.net/xmoto</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Build_from_SVN&diff=6862Build from SVN2014-06-01T11:33:34Z<p>Nadenislamarre: /* SVN ? */</p>
<hr />
<div>[[Ca:Compilacio SVN|Català]] - [[Es:Compilacion SVN|Español]] - [[No:Kompilere_fra_SVN|Norsk]] - [[Fr:Compilation_depuis_SVN|Francais]]<br />
<br />
<br />
== Quick compilation ==<br />
=== Linux / Ubuntu ===<br />
* Install prerequisites<br />
sudo apt-get install subversion build-essential automake1.9 libsqlite3-dev libjpeg62-dev libbz2-dev libsdl-mixer1.2-dev<br />
sudo apt-get install libsdl-net1.2-dev liblua5.1-0-dev libode-dev zlib1g-dev libpng12-dev libglu1-mesa-dev libsdl-ttf2.0-dev<br />
sudo apt-get install libcurl3-openssl-dev libxdg-basedir-dev libxml2-dev gettext<br />
<br />
* Get X-Moto sources<br />
svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk xmoto_trunk<br />
<br />
* Compile sources<br />
cd xmoto_trunk<br />
./configure --prefix=$HOME/xmoto_install --with-unoptimized=1<br />
make<br />
make install<br />
<br />
* Run X-Moto<br />
./src/xmoto<br />
<br />
<br />
=== Windows ===<br />
* Install VirtualBox or any virtualisation system<br />
* Install Linux/Ubuntu inside<br />
* Install prerequisites<br />
* Install mingw_lib.zip<br />
* Compile sources<br />
<br />
<br />
<br />
== SVN ? ==<br />
<br />
X-Moto uses SVN to develop the game. With SVN files, you have access to new features and... new bugs.<br />
Use svn files only if you know what you are doing. otherwise just go download the stable release from the main page http://xmoto.tuxfamily.org<br />
<br />
You must know that sources downloaded from SVN should not be compiled sometimes !<br />
<br />
[http://en.wikipedia.org/wiki/Subversion_%28software%29 http://en.wikipedia.org/wiki/Subversion_%28software%29]<br />
<br />
=== Download latest files with SVN ===<br />
<br />
The first time you download the svn version you will need to download all the files under "xmoto/" :<br />
<br />
svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk xmoto<br />
<br />
or if you are a developer<br />
<br />
svn co svn+ssh://$USER@svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk xmoto<br />
<br />
(you can upload you public ssh keys to the root of your ftp account on ftp://$USER@ftp.tuxfamily.org/ in a file called ssh_keys)<br />
<br />
Note that there are a lot of graphical clients to use svn if you're afraid of the command line.<br />
<br />
=== Update the files ===<br />
<br />
When you have already download from svn once, you can update the files with this command :<br />
<br />
# svn update<br />
<br />
=== Web access ===<br />
http://svn.tuxfamily.org/viewvc.cgi/?root=xmoto_xmoto<br />
<br />
=== Notification via rss ===<br />
http://svnweb.tuxfamily.org/rss.php?repname=xmoto+%28xmoto%29&path=%2F&rev=0&sc=0&isdir=1<br />
<br />
== Build ==<br />
<br />
=== Dependencies ===<br />
<br />
X-Moto must have the following to compile properly :<br />
<br />
* Latest gcc and g++<br />
* SDL development libraries and headers<br />
* OpenGL development libraries and headers<br />
* SDL_mixer with headers<br />
* SDL_net with headers<br />
* libjpeg with headers<br />
* libpng with headers<br />
* zlib with headers<br />
* libbzip2 with headers<br />
* liblua50 with headers<br />
* liblualib50 with headers<br />
* libode with headers<br />
* libcurl3 with headers<br />
* libxml2 development libraries<br />
* automake >= 1.9<br />
<br />
sudo apt-get install subversion build-essential automake1.9 libsqlite3-dev libjpeg62-dev libbz2-dev libsdl-mixer1.2-dev<br />
sudo apt-get install libsdl-net1.2-dev liblua5.1-0-dev libode-dev zlib1g-dev libpng12-dev libglu1-mesa-dev libsdl-ttf2.0-dev<br />
sudo apt-get install libcurl3-openssl-dev libxdg-basedir-dev libxml2-dev gettext<br />
<br />
To build windows version from linux, you'll need the following extra packages <br />
sudo apt-get install tofrodos nsis mingw32<br />
<br />
Use mingw32 3.4.5.20060117.1.dfsg-3 from gusty for ubuntu otherwise, .exe built are instables<br />
<br />
But with the new features, new dependencies can be asked.<br />
<br />
=== automatic builds ===<br />
sudo apt-get install devscripts libcurl4-gnutls-dev debhelper<br />
mkdir $HOME/xm/builds<br />
cd $HOME/xm/builds<br />
cp /path/to/svn/tools/tuxfamily_fullBuild.sh .<br />
cp /path/to/svn/tools/buildPackages.sh .<br />
svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk trunk<br />
mkdir sources<br />
mkdir windows<br />
# edit the 5 first lines of tuxfamily_fullBuild.sh to change the path and the username for the scp<br />
./tuxfamily_fullBuild.sh<br />
<br />
=== Ok, I can build it ! ===<br />
<br />
$ cd xmoto<br />
$ sh ./bootstrap<br />
$ ./configure<br />
$ make<br />
# make install<br />
<br />
Right now, you can start xmoto with "<code>src/xmoto</code>".<br />
<br />
If sh ./bootstrap failed, you have to edit the ./bootstrap file manually:<br />
aclocal -I config $ACLOCAL_FLAGS\<br />
&& automake --gnu --add-missing --copy \<br />
<br />
so it looks like that:<br />
aclocal-1.9 -I config $ACLOCAL_FLAGS\<br />
&& automake-1.9 --gnu --add-missing --copy \<br />
<br />
=== Doesn't work ? ===<br />
<br />
xmoto.bin not found !<br />
You probably reconfigure without making clean. Do:<br />
make clean<br />
./configure<br />
make<br />
sudo make install<br />
Problems with translations:<br />
make[1]: Entering directory `/home/yourusername/xmoto-dev-folder/po'<br />
rm -f fr_FR.gmo && : -c --statistics -o fr_FR.gmo fr_FR.po<br />
mv: cannot stat `t-fr_FR.gmo': No such file or directory<br />
make[1]: *** [fr_FR.gmo] Error 1<br />
make[1]: Leaving directory `/home/tuhoojabotti/xmoto-dev-folder/po'<br />
make: *** [update-po] Error 2<br />
<br />
SOLUTION (ought to work):<br />
sudo apt-get install gettext<br />
./configure<br />
cd po/<br />
make update-po<br />
cd ..<br />
make<br />
sudo make install<br />
<br />
=== Need help ? ===<br />
Join us on IRC, the channel is #xmoto on the freenode servers.<br />
irc://irc.freenode.net/xmoto</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Scripted_levels&diff=6073Scripted levels2011-03-31T10:09:45Z<p>Nadenislamarre: /* Zone.OnLeaveBy() */</p>
<hr />
<div>[[Ca:Scripted levels|Català]] - [[Es:Scripted levels|Español]]<br />
<br />
= Introduction =<br />
Scripting allows a level to become dynamic. You can change physic settings, move objects, modify game logic, etc. A script is written in the Lua language and can be included in a level file.<br />
<br />
Documentation about Lua can be found here :<br />
http://www.lua.org/manual/5.1/<br />
<br />
To write a script, you must know a little about a level file. It is an xml file. It includes somes properties like the name of the level, description, author, date, etc. Moreover, it includes block and sprite definitions. A block is composed of vertices which link together to draw polygons.<br />
<br />
Since 0.3.0, xmoto supports multiplayers ; in the script, a player is defined by an index. The first player has the number 0, the second the number 1, ...<br />
<br />
The script examples on this page will use this basic level file:<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<level id="tutscript"><br />
<info><br />
<name>tutscript</name><br />
<description></description><br />
<author></author><br />
<date></date><br />
<sky>sky1</sky><br />
</info><br />
<script><br />
</script><br />
<limits left="0" right="50" top="30" bottom="0"/><br />
<block id="Block0"><br />
<position x="0" y="0"/><br />
<usetexture id="default"/><br />
<vertex x="5" y="5"/><br />
<vertex x="5" y="10"/><br />
<vertex x="10" y="10"/><br />
<vertex x="10" y="5"/><br />
</block><br />
<entity id="MyPlayerStart0" typeid="PlayerStart"><br />
<size r="0.4"/><br />
<position x="7.5" y="10"/><br />
</entity><br />
<entity id="Strawberry0" typeid="Strawberry"><br />
<size r="0.4"/><br />
<position x="20" y="0.5"/><br />
</entity><br />
<entity id="SnowMan0" typeid="Sprite"><br />
<param name="name" value="SnowMan"/><br />
<position x="19" y="0.2"/><br />
<param name="z" value="-1"/><br />
</entity><br />
<zone id="Zone0"><br />
<box left="40" right="50" top="5" bottom="0"/><br />
</zone><br />
</level><br />
<br />
This level can be made easily with the xmoto level editor. It includes a block called Block0 which is a square, a strawberry called Strawberry0 and a zone called Zone0. A zone is an invisible part of the level that can execute actions when the player is inside.<br />
<br />
Some functions require a minimum X-Moto version to work. If you use one of these functions, please put this information in the level. For example, to make your level require X-Moto version 0.2.0, add this line to your level:<br />
<br />
<level id="tutscript" rversion="0.2.0"><br />
<br />
[[Image:Scripted_level.jpg]]<br />
<br />
All the code of the script is written in Lua. You can find the syntax here. However, if you choose to include the script in an xml file, < and > symbol must be replaced by &amp;lt; and &amp;gt;. The code of the script can be included between <script> and </script> in the level file.<br />
<br />
= Timers =<br />
== StartTimer(Name,Delay=100,Loops=0) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
This function is used to create a timer, or start a stopped timer. Basically, if you don't give all parameters the timer uses default values, or if the timer already exists then it is resetted, or started if it is stopped with Game.StopTimer().<br />
<br />
'''Cases''': <br />
* if timer doesn't exist then creates<br />
* if timer exist and is stopped then restarts (unless you give attributes delay or loops then it is reseted)<br />
* if timer exist and is running then resets <br />
=== Script Example ===<br />
--------------------------<br />
--Delayed Message System--<br />
-----by tuhoojabotti------<br />
--------------------------<br />
--stuff for the msgs<br />
msgs={}<br />
msgt={}<br />
msga=0<br />
<br />
--other<br />
Zone0={}<br />
<br />
function OnLoad()<br />
StartMessages({"Hello and welcome!","This level uses timers to show these messages.","Press 'B' to pause and continue messages.","Go right and if you hit the Zone, the messages will end!","I have nothing else to say, good night!"},150)<br />
Game.SetKeyHook("B","stop")<br />
return true<br />
end<br />
<br />
function stop()<br />
ToggleMessages()<br />
end<br />
<br />
function Zone0.OnEnter()<br />
ClearMessages()<br />
end<br />
<br />
--functions for the message system<br />
function StartMessages(_msgs,_delay)<br />
msga=1; msgs=_msgs; Game.StartTimer("msgt",_delay,table.getn(msgs))<br />
end<br />
function ToggleMessages()<br />
if not(table.getn(msgs)==0) then --only if there are messages<br />
if msga==1 then --msgs are rolling<br />
msga=0; Game.StopTimer("msgt")<br />
else --no msgs rolling<br />
msga=1; Game.StartTimer("msgt")<br />
end<br />
end<br />
end<br />
function msgt.Tick(n)<br />
if table.getn(msgs)>=n then --there are messages<br />
Game.Message(msgs[n])<br />
if table.getn(msgs)==n then msga=0 end --shutdown on last msg<br />
end<br />
end<br />
function ClearMessages()<br />
if msga==1 then Game.StopTimer("msgt") end<br />
msgs={}; msga=0; msgd=0<br />
end<br />
<br />
== SetTimerDelay(Name,Delay) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
Sets the timer's delay, without resetting the amount of loops etc. (Allows you to speed it up or slow it down. ;-))<br />
=== Script Example ===<br />
timer={} --declare the timer<br />
entity1={}<br />
function OnLoad()<br />
Game.Message("You are going to die in 10 seconds!! buahahhahahaaa!")<br />
Game.StartTimer("timer",1000,1)<br />
return true<br />
end<br />
function timer.Tick()<br />
Game.KillPlayer()<br />
end<br />
function entity1.Touch()<br />
Game.Message("haha! you drank some poison, now you die faster!")<br />
Game.SetTimerDelay("timer",300)<br />
end<br />
== StopTimer(Name) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
Stops the timer, the Name.Tick won't be called anymore. Use Game.StartTimer(Name) to restart it.<br />
=== Script Example ===<br />
timer={} --declare the timer<br />
entity1={}<br />
function OnLoad()<br />
Game.Message("You are going to die in 10 seconds!! buahahhahahaaa!")<br />
Game.StartTimer("timer",1000,1)<br />
return true<br />
end<br />
function timer.Tick()<br />
Game.KillPlayer()<br />
end<br />
function entity1.Touch()<br />
Game.Message("No! you found antidote!")<br />
Game.StopTimer("timer")<br />
end<br />
<br />
= Functions called by XMoto =<br />
<br />
== OnLoad() ==<br />
=== Explanation ===<br />
This function is called one time when the level starts. You must return true if nothing bad happened.<br />
<br />
=== Script example ===<br />
The example displays a message at the start of the level.<br />
<br />
function OnLoad()<br />
Game.Message("This level is scripted")<br />
return true<br />
end<br />
<br />
== Tick() ==<br />
=== Explanation ===<br />
Function called 1 time every hundredth.<br />
You must return true if nothing bad happened.<br />
Be aware that if this function use is abusive, levels will not be validated :<br />
action function like setBlockPos, setPlayerPos, ...<br />
(contrary to request function getBlockPos, getTime, and lua code)<br />
require that the information is store into the replay. If you put a setBlockPos<br />
call into the Tick function, it will make big replays : around 20 bytes * 100 * 60 / minute<br />
=> several hundreads of KB / minute<br />
To limit this if you really want to call such functions into your level :<br />
- first, play your level and check that replay size is under 100 ko<br />
- reduce the number of time you call setBlockPos by adding a variable to make<br />
this function called not in all Tick() but 1/3 for example<br />
- add a zone so that the animation (tick) is called only when you're<br />
in this zone<br />
- use dynamicBlock or dynamicEntity functions<br />
<br />
=== Script example ===<br />
This example will initialize gravity to 0 ; then, it will increment it with the time. Because earth gravity is 9.81, the earth gravity will not be reached before the 9.81 seconds. Be aware that in xmoto, vertical gravity must be multiplied by -1 because of screen coords which are reversed.<br />
<br />
function Tick()<br />
if Game.GetTime() < 9.81<br />
then<br />
Game.SetGravity(0, Game.GetTime() * -1)<br />
end<br />
return true<br />
end<br />
<br />
function Load()<br />
Game.SetGravity(0, 0)<br />
return true<br />
end<br />
<br />
== Entity.Touch() ==<br />
=== Explanation ===<br />
This function is called when an entity (a strawberry for example) is touched. The entity must be declared in the script. Note that the <size r> parameter allows to choose the distance of the entity which must be considered so that it is touched.<br />
<br />
=== Script example ===<br />
The example displays a message when the strawberry is touched.<br />
<br />
Strawberry0 = {}<br />
<br />
function Strawberry0.Touch()<br />
Game.Message("Nice strawberry !")<br />
end<br />
<br />
== Entity.TouchBy(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when an entity (a strawberry for example) is touched. The entity must be declared in the script. Note that the <size r> parameter allows to choose the distance of the entity which must be considered so that it is touched.<br />
<br />
=== Script example ===<br />
The example displays a message when the strawberry is touched.<br />
<br />
Strawberry0 = {}<br />
<br />
function Strawberry0.TouchBy(player)<br />
Game.Message("Player "..player.." takes the strawberry")<br />
end<br />
<br />
== Zone.OnEnter() ==<br />
=== Explanation ===<br />
This function is called when a player enters in a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player enters into the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.Message("Entering in the zone")<br />
end<br />
<br />
== Zone.OnEnterBy(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when a player enters in a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player enters into the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnterBy(player)<br />
Game.Message("Player "..player.." enters the zone")<br />
end<br />
<br />
== Zone.OnLeave() ==<br />
=== Explanation ===<br />
This function is called when a player leaves a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player leaves the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnLeave()<br />
Game.Message("Leaving the zone")<br />
end<br />
<br />
== Zone.OnLeaveBy() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when a player leaves a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player leaves the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnLeaveBy(player)<br />
Game.Message("Player "..player.." leaves the zone")<br />
end<br />
<br />
== Checkpoint.OnUse() ==<br />
[require Xmoto >= 0.5.3]<br />
=== Explanation ===<br />
This function is called when a player go back to a checkpoint. This can be used to set some script values for example.<br />
<br />
=== Script example ===<br />
The example displays a message when a player uses the checkpoint Checkpoint0.<br />
<br />
Checkpoint0 = {}<br />
<br />
function Checkpoint0.OnUse()<br />
Game.Message("Checkpoints are usefull")<br />
end<br />
<br />
== OnSomersault(bClockWise) ==<br />
[require Xmoto >= 0.2.1]<br />
<br />
=== Explanation ===<br />
This function is called each time a player make a new somersault. bClockWise is 1 is the somersault is clockwise, 0 if counterclockwise.<br />
<br />
=== Script example ===<br />
The example displays a message when a player makes a somersault.<br />
<br />
function OnSomersault(bClockWise)<br />
if(bClockWise == 1) <br />
then<br />
Game.Message("ClockWise Somersault")<br />
else<br />
Game.Message("CounterClockWise Somersault")<br />
end<br />
end<br />
<br />
== OnSomersaultBy(bClockWise, player) ==<br />
[require Xmoto >= 0.3.0]<br />
<br />
=== Explanation ===<br />
This function is called each time a player make a new somersault. bClockWise is 1 is the somersault is clockwise, 0 if counterclockwise.<br />
<br />
=== Script example ===<br />
The example displays a message when a player makes a somersault.<br />
<br />
function OnSomersaultBy(bClockWise, player)<br />
Game.Message("Nice, player "..player" !)<br />
end<br />
<br />
== OnWheel1Touchs(status), OnWheel2Touchs(status) ==<br />
[require Xmoto >= 0.2.1]<br />
<br />
=== Explanation ===<br />
This function is called each time just the wheel 1 touchs the ground or stops to touch the ground. (status is 1 is the ground was not touching and is now touching, and 0 else)<br />
<br />
=== Script example ===<br />
The example displays the new max duration of a jump each time a new one is done.<br />
<br />
max_jump_time = 1.0 -- start at 1 to not count smaller jumps<br />
jump_begin = 0.0<br />
touch_1 = false<br />
touch_2 = false<br />
<br />
function OnWheel1Touchs(bStatus)<br />
if(bStatus == 1) <br />
then<br />
updateMax()<br />
touch_1 = true<br />
else<br />
touch_1 = false<br />
jump_begin = Game.GetTime()<br />
end<br />
end<br />
<br />
function OnWheel2Touchs(bStatus)<br />
if(bStatus == 1) <br />
then<br />
updateMax()<br />
touch_2 = true<br />
else<br />
touch_2 = false<br />
jump_begin = Game.GetTime()<br />
end<br />
end<br />
<br />
function updateMax()<br />
if(touch_1 == false and touch_2 == false)<br />
then<br />
if(Game.GetTime() - jump_begin > max_jump_time)<br />
then<br />
max_jump_time = Game.GetTime() - jump_begin<br />
Game.Message("New high jump: "..max_jump_time)<br />
end<br />
end<br />
end<br />
<br />
== OnWheel1TouchsBy(status, player), OnWheel2TouchsBy(status, player) ==<br />
[require Xmoto >= 0.3.0]<br />
<br />
=== Explanation ===<br />
This function is called each time just the wheel 1 touchs the ground or stops to touch the ground. (status is 1 is the ground was not touching and is now touching, and 0 else)<br />
<br />
=== Script example ===<br />
function OnWheel1TouchsBy(status, player)<br />
if(status == 1) <br />
then<br />
Game.Message("Player "..player.." touches with wheel 1")<br />
end<br />
end<br />
<br />
function OnWheel2TouchsBy(status, player)<br />
if(status == 1) <br />
then<br />
Game.Message("Player "..player.." touches with wheel 2")<br />
end<br />
end<br />
<br />
= Callable X-Moto functions =<br />
<br />
== GetTime() ==<br />
=== Explanation ===<br />
Return the time since the start of the level.<br />
<br />
=== Script example ===<br />
The example displays a message if the player takes more than 10 seconds to enter the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
if Game.GetTime() > 10.0<br />
then<br />
Game.Message("10 seconds to come there, that's a lot !")<br />
end<br />
end<br />
<br />
== Message(msgs) ==<br />
=== Explanation ===<br />
Display a message on the screen. The message is automatically remove after 5 seconds. You can call this function several times : the messages will be all displayed.<br />
<br />
=== Script example ===<br />
The example displays some messages at the start of the level.<br />
<br />
function OnLoad()<br />
Game.Message("This level is scripted")<br />
Game.Message("GO GO GO !!!")<br />
return true<br />
end<br />
<br />
== ClearMessages() ==<br />
=== Explanation ===<br />
Remove messages on the screen.<br />
<br />
=== Script example ===<br />
The example shows how to clear old messages and display a new one in some circumstances.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.ClearMessages()<br />
Game.Message("OnEnter")<br />
end<br />
<br />
function Zone0.OnLeave()<br />
Game.ClearMessages()<br />
Game.Message("OnLeave")<br />
end<br />
<br />
== SetGravity(x, y) ==<br />
=== Explanation ===<br />
Change the gravity (horizontal and vertical) in the game.<br />
<br />
=== Script example ===<br />
The example shows how to reverse gravity. Be aware that in X-Moto, vertical gravity must be multiplied by -1 because screen coordinates are reversed in the y direction.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0, 9.81)<br />
return true<br />
end<br />
<br />
== GetGravity() ==<br />
=== Explanation ===<br />
Return the pair(horizontal gravity, vertical gravity).<br />
<br />
=== Script example ===<br />
The example displays the wind and gravity at the start of the level.<br />
<br />
function OnLoad()<br />
x, y = Game.GetGravity()<br />
Game.Message("Wind : "..x)<br />
Game.Message("Gravity : "..(y*-1))<br />
return true<br />
end<br />
<br />
== IsPlayerInZone(zone) ==<br />
=== Explanation ===<br />
Return true if a player is in the specified zone.<br />
<br />
=== Script example ===<br />
This example is a bit more complicated. When the player enters the zone, gravity slowly decreases. Once the player leaves the zone, the gravity suddenly becomes 9.81.<br />
<br />
Zone0 = {}<br />
x = -9.81<br />
<br />
function Tick()<br />
if Game.IsPlayerInZone("Zone0")<br />
then<br />
Game.SetGravity(0, x)<br />
x = x + 0.1<br />
end<br />
<br />
return true<br />
end<br />
<br />
function Zone0.OnLeave()<br />
x = -9.81<br />
Game.SetGravity(0, x)<br />
end<br />
<br />
== IsAPlayerInZone(zone, player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return true if the player is in the specified zone.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
if Game.IsAPlayerInZone("Zone0", 0) == false<br />
then<br />
Game.Message("This player 0 is not in the zone")<br />
end<br />
return true<br />
end<br />
<br />
== SetPlayerPosition(x, y, bRight) ==<br />
=== Explanation ===<br />
Set the position and direction of the players in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example teleports the playerq each time one enters the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
== SetAPlayerPosition(x, y, bRight, player) ==<br />
=== Explanation ===<br />
Set the position and direction of the player in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example show how to teleport the player 0 at start of the level to the position (20, 5)<br />
<br />
function OnLoad()<br />
Game.SetAPlayerPosition(20, 5, 1, 0)<br />
return true<br />
end<br />
<br />
== GetPlayerPosition() ==<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of the player 0 in the game.<br />
<br />
=== Script example ===<br />
This example make the player unable to get the strawberry ;-)<br />
<br />
function Tick()<br />
x, y, bright = Game.GetPlayerPosition()<br />
if x > 18<br />
then<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== GetPlayerVelocity(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the velocity of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetPlayerSpeed(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the speed of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetPlayerAngle(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the angle of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetAPlayerPosition(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of a player in the game.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
x, y, bright = Game.GetAPlayerPosition(0)<br />
Game.Message("Player0 position is ("..x..","..y..")")<br />
return true<br />
end<br />
<br />
== SetEntityPos(entity, x, y) ==<br />
=== Explanation ===<br />
Set the position of the entity to coordinates (x, y) in the game.<br />
<br />
=== Script example ===<br />
The example changes the position of the strawberry every second.<br />
<br />
function Tick()<br />
i,f = math.mod(math.ceil(Game.GetTime()), 2)<br />
<br />
if i == 1<br />
then<br />
Game.SetEntityPos("Strawberry0", 10, 0.5)<br />
else<br />
Game.SetEntityPos("Strawberry0", 30, 0.5)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== GetEntityPos(entity) ==<br />
=== Explanation ===<br />
Return the position of the entity entity in the game.<br />
<br />
=== Script example ===<br />
This example shows another way to move a strawberry.<br />
<br />
last_update = 0<br />
<br />
function Tick()<br />
sec = math.ceil(Game.GetTime())<br />
<br />
if last_update < sec<br />
then<br />
x, y = Game.GetEntityPos("Strawberry0")<br />
<br />
if(x == 20)<br />
then<br />
x_new = 25<br />
else<br />
x_new = 20<br />
end<br />
<br />
if(y == 0.5)<br />
then<br />
y_new = 2<br />
else<br />
y_new = 0.5<br />
end<br />
<br />
Game.SetEntityPos("Strawberry0", x_new, y_new)<br />
last_update = sec<br />
end<br />
<br />
return true<br />
end<br />
<br />
== SetKeyHook(key, function) ==<br />
=== Explanation ===<br />
Whenever the player hits the "key" specified, a function will be called.<br />
You can use key like "a", "b", "c" or technical values returned by GetKeyByActionTech<br />
<br />
=== Script example ===<br />
The example shows how to change gravity just by pressing a key.<br />
<br />
g = -9.81<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("G", "GravityChange")<br />
return true<br />
end<br />
<br />
function GravityChange()<br />
g = g * -1<br />
Game.SetGravity(0, g)<br />
end<br />
<br />
== GetKeyByAction(function) ==<br />
=== Explanation ===<br />
Return the key associated to an action. Possible actions are Drive, Brake, PullBack, PushForward, ChangeDirection.<br />
<br />
=== Script example ===<br />
The example displays how to drive at level start.<br />
<br />
function OnLoad()<br />
Game.Message("To drive, press "..Game.GetKeyByAction("Drive"))<br />
return true<br />
end<br />
<br />
== GetKeyByActionTech(function) ==<br />
[require Xmoto >= 0.5.4] <br />
=== Explanation ===<br />
Return the key associated to an action. Possible actions are Drive, Brake, PullBack, PushForward, ChangeDirection.<br />
Note that GetKeyByAction returns a human readable string while GetKeyByActionTech returns a value which is usable by SetKeyHook and that can be a joystick, mouse or keyboard key.<br />
<br />
=== Script example ===<br />
The example show how to use the Drive key to do other things than driving.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook(Game.GetKeyByActionTech("Drive"), "BalloonA")<br />
return true<br />
end<br />
<br />
== Log(msgs) ==<br />
=== Explanation ===<br />
Log a message in the xmoto.log.<br />
<br />
=== Script example ===<br />
The example log the message "An error occured" when the level starts.<br />
<br />
function OnLoad()<br />
Game.Log("An error occured")<br />
return true<br />
end<br />
<br />
== MoveBlock(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function allows X-Moto to move a block in the level. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />). Be aware that moving a block can be dangerous: make sure that the player will not be inside the block once you have moved it.<br />
<br />
=== Script example ===<br />
In the example, when the player presses the key M, the block moves to the right.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "MoveTheBlock")<br />
return true<br />
end<br />
<br />
function MoveTheBlock()<br />
Game.MoveBlock("Block0", 1, 0)<br />
end<br />
<br />
== SetBlockCenter(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function gives the center of the block relative to the block position (then, to the level if block position is (0, 0)). The center is used by the function SetBlockPos(), GetBlockPos() and SetBlockRotation(). This function should generally used in the Load() function because the center should not logically be changed (however, you can change it).<br />
<br />
=== Script example ===<br />
In the example, the center of the block is set to the center of the square. Then, when the player press M, the block is placed just under the player.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
<br />
== SetBlockPos(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function allows X-Moto to change the position of a block according to its center. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />). Be aware that moving a block can be dangerous: make sure that the player will not be inside the block once you have moved it.<br />
<br />
=== Script example ===<br />
In the example, the center of the block is set to the center of the square. Then, when the player press M, the block is placed just under the player.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
<br />
== GetBlockPos(block) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function gives the position of a given block. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
The example shows how to use this function as a condition. Here, you can move the block under the bike only if you play on the right.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
bx, by = Game.GetBlockPos("Block0")<br />
if(x > bx)<br />
then<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
end<br />
<br />
== SetBlockRotation(block, angle) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function rotates a block. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
In the example, if the player keeps the key M pressed, the block will rotate.<br />
<br />
a = 0<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
a = a + math.pi / 256.0<br />
Game.SetBlockRotation("Block0", a)<br />
end<br />
<br />
== SetDynamicEntityRotation(entity, initAngle, radius, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function tells an entity to make circles for a given duration. The current position of the entity on the circle of radius radius is at position initAngle (in rad). The entity will make a circle in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negative arguments allow you to change the behavior of the animation. For example, a negative period will rotate the entity in the negative direction.<br />
<br />
=== Script example ===<br />
The example shows how to easily move the strawberry. InitAngle is set to -PI/2 because the strawberry is placed at the bottom where we want it moves.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityRotation("Strawberry0", -math.pi/2, 2, 500, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicEntitySelfRotation(entity, period, startTime, endTime) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function allows to tell an entity to rotate for a given duration. The entity will rotate in period hundreads. The animation will start in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense.<br />
<br />
=== Script example ===<br />
The example shows how to rotate easily a entity.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntitySelfRotation("Entity2", 1000, 0, 0);<br />
return true;<br />
end;<br />
<br />
== SetDynamicEntityTranslation(entity, fX, fY, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function allows to tell an entity to make translation for a given duration. The translation's length is fX on the X axis and fY on the Y axis. The entity will make the translation in period/2 hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation.<br />
<br />
=== Script example ===<br />
The example shows an example of composed animations.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityTranslation("Strawberry0", 10, 0, 500, 0, 0)<br />
Game.SetDynamicEntityTranslation("Strawberry0", 0, 1, 100, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicEntityNone(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function removed all the animations applicated on an entity.<br />
<br />
=== Script example ===<br />
The example first shows how to ask an entity to make a translation in a first time and then, to make rotations. If the user press the key S, the strawberry stops to move.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityTranslation("Strawberry0", -2, 0, 1000, 0, 500)<br />
Game.SetDynamicEntityRotation("Strawberry0", -math.pi/2, 2, 500, 500, 0)<br />
Game.SetKeyHook("S", "StopAnimation")<br />
return true<br />
end<br />
<br />
function StopAnimation()<br />
Game.SetDynamicEntityNone("Strawberry0")<br />
end<br />
<br />
== SetDynamicBlockRotation(block, initAngle, radius, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function allows to tell a block to make circles for a given duration. The current position of the block on the circle of radius radius is at position initAngle (in rad). The block will make a circle in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make move blocks to fast otherwise the bike could go throw the block.<br />
<br />
=== Script example ===<br />
The example shows how to make move easily a block.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockRotation("Block0", -math.pi/2, 2, 500, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicBlockSelfRotation(block, period, startTime, endTime) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function allows to tell a block to rotate for a given duration. The block will rotate in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make move blocks to fast otherwise the bike could go throw the block.<br />
<br />
=== Script example ===<br />
The example shows how to rotate easily a block.<br />
<br />
function OnLoad()<br />
Game.SetBlockCenter("Block2", -2.5, -19.0);<br />
Game.SetDynamicBlockSelfRotation("Block2", 1000, 0, 0);<br />
return true;<br />
end;<br />
<br />
== SetDynamicBlockTranslation(block, fX, fY, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
<p>This function tells a block to make a translation for a given duration. A translation is a looped movement from one point to another, and back. The translation's length is fX on the X axis and fY on the Y axis. The animation will start in startTime hundredths and will finish in endTime hundredths, so the duration is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make blocks move too fast otherwise the bike could go through the block.</p><br />
<br />
<p>block: Defines which Block should move<br><br />
fX: Defines where on the X-Axis the Block should move<br><br />
fY: Defines where on the Y-Axis the Block should move<br><br />
period: Defines how long it takes the Block to move back to the starting point<br><br />
startTime: Defines when the translation should start<br><br />
endTime: Defines when the translation should end</p><br />
<br />
In order to make replay files as small as possible, you should use Translation instead of the MoveBlock function. An example on how to convert a MoveBlock function into a Translation is given below.<br />
<br />
=== Script example ===<br />
In this example, the block makes an infinite movement: It moves from its originating point (0,0) to (10,1) within 750ms, and then back in another 750ms.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 10, 1, 1500, 0, 0)<br />
return true<br />
end<br />
<br />
Example on how to convert a MoveBlock function into a Translation (see above):<br />
<br />
function Tick()<br />
Game.MoveBlock("Block0", 0.5,0)<br />
return true<br />
end<br />
<br />
Block0 moves forever to the right: 0.5px every 1/100s<br />
So it moves at a speed of 300m/60s<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 300, 0, 12000, 0, 6000)<br />
return true<br />
end<br />
<br />
This is the MoveBlock function in the translation-version. <br />
It moves 300m to the right and 300m back to the left in 12000ms. endTime is set to 12000/2=6000, so that the translation stops as soon as Block0 reaches (300,0)<br />
<br />
== SetDynamicBlockNone(block) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function stops all the animation applied on the block. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
In the example, the block will move until the player presses the key S.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 10, 1, 1500, 0, 0)<br />
Game.SetKeyHook("S", "StopAnimation")<br />
return true<br />
end<br />
<br />
function StopAnimation()<br />
Game.SetDynamicBlockNone("Block0")<br />
end<br />
<br />
== CameraZoom(z) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
In some levels, you may want that the camera is a bit more far from the player. Use this function to change the camera zoom.<br />
<br />
=== Script example ===<br />
The example shows how a different zoom can be used to play a level.<br />
<br />
function OnLoad()<br />
Game.CameraZoom(-0.05)<br />
return true<br />
end<br />
<br />
== CameraMove(x, y) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
For some particular levels, you may want the camera to be moved. Use this function to do that.<br />
<br />
=== Script example ===<br />
The example shows how you can focus a level on the part above the player.<br />
<br />
function OnLoad()<br />
Game.CameraMove(0, 3)<br />
return true<br />
end<br />
<br />
== CameraRotate(angle) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera be rotated. Use this function to do that.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.CameraRotate(math.pi / 4.0);<br />
return true<br />
end<br />
<br />
== CameraAdaptToGravity() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera be rotated. Use this function to do that in function of the gravity.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0.0, 9.81)<br />
Game.CameraAdaptToGravity()<br />
return true<br />
end<br />
<br />
== SetCameraRotationSpeed(z) ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera beeing rotated does that at a certain speed. With this function you can make it rotate either very slow ( z = 0.1 ) or extremely fast ( z = 7.2 ). The values are given in RAD, so they can reach from 0 to 2 * PI.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0.0, 9.81)<br />
Game.SetCameraRotationSpeed(0.2)<br />
Game.CameraAdaptToGravity()<br />
return true<br />
end<br />
<br />
== GetEntityRadius(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
Return the radius of an entity. This radius is used for collision. You can use this function for your own collision or anything else.<br />
<br />
=== Script example ===<br />
The example shows you the radius of the strawberry.<br />
<br />
function OnLoad()<br />
Game.Message("Radius of the strawberry : "..Game.GetEntityRadius("Strawberry0"))<br />
return true<br />
end<br />
<br />
== IsEntityTouched(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
There is a function called when you touch an entity. But sometimes you want to know when you don't touch an entity. Use this function.<br />
<br />
=== Script example ===<br />
The example shows how to make an action when the player is not touching an entity.<br />
<br />
g = -9.81<br />
<br />
function OnLoad()<br />
Game.Message("Gravity is increasing while you are not touching the snowman")<br />
return true<br />
end<br />
<br />
function Tick()<br />
if(Game.IsEntityTouched("SnowMan0") == 0)<br />
then<br />
g = g - 0.03<br />
Game.SetGravity(0, g);<br />
end<br />
return true<br />
end<br />
<br />
==Game.AddPenaltyTime(time) ==<br />
[require Xmoto >= 0.5.0]<br />
=== Explanation ===<br />
Increment the value of the time counter to make a penalty.<br />
<br />
=== Script example ===<br />
In the following example, the time will be increased of 5 seconds if the player enters in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.AddPenaltyTime(5.0)<br />
end<br />
<br />
== KillPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the players die. It's interesting if you want the players be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
In the following example, the player will die when he will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillPlayer()<br />
end<br />
<br />
== KillAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player dies. It's interesting if you want the player be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.KillAPlayer(0)<br />
return true<br />
end<br />
<br />
== KillEntity(entityID) ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the entity entityID will be deleted. The entity can be a strawberry or any sprite.<br />
<br />
=== Script example ===<br />
In the following example, the strawberry will be deleted when the player will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillEntity("Strawberry0")<br />
end<br />
<br />
== WinPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, all players win the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
In the following example, the player win on entering in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.WinPlayer()<br />
end<br />
<br />
== WinAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player wins the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.WinAPlayer(0)<br />
return true<br />
end<br />
<br />
== RemainingStrawberries() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
This function returns the number of strawberries remaining in the level.<br />
<br />
=== Script example ===<br />
In the following example, when the player will enter in the zone Zone0, the number of remaining strawberries is displayed.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.Message(Game.RemainingStrawberries())<br />
end<br />
<br />
== NumberOfPlayers() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function returns the number of players (dead or in live) in the level<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.Message(Game.NumberOfPlayers().." players")<br />
return true<br />
end<br />
<br />
== AddForceToPlayer(forceX, forceY, startTime, endTime, player) ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
This function apply an external force on the player player. The force will apply from startTime to endTime or will be infinite if endTime is 0. startTime and endTime are expressed in hundreaths and are relativ to the call function time. The force applied will be of (forceX, forceY). Application point is the center of the biker. In the example, a force will be applied to all players from time 5 to 10 seconds. Force is expressed in newton, mg/s-2 (meter * gramm / (seconds * seconds)).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
for i=0,Game.NumberOfPlayers()-1 do<br />
Game.Message("Kicking player "..(i+1))<br />
Game.AddForceToPlayer(0, 1000, 500, 1000, i)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== PlayAudio("NameOfSound") ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
Using this function you can play a sound effect (or a music). The parameter is the name of the sound, which is defined in the actually used theme file.<br />
In the following example, there must be a zone named "Zone0", As soon as you enter the zone, the sound effect is played:<br />
<br />
=== Script example ===<br />
Zone0 = {}<br />
function Zone0.OnEnter()<br />
Game.PlaySound("ring");<br />
end<br />
<br />
<br />
<br />
== SetPhysicsBlockSelfRotation (block, torque, startTime, endTime) ==<br />
[require Xmoto >= 0.5.0]<br />
=== Explanation ===<br />
This function allows to tell a block to rotate for a given duration. The rotation will be performed by applying forces (torque) on the block (if possible). The block will rotate in period hundreads. The forces application will start in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite application. Note that negativ arguments allow to change the behavior of the forces, for example, a negativ torque will tell to turn in the other sense. <br />
<br />
=== Script example ===</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_rules_(slave_mode)&diff=6072Server rules (slave mode)2011-03-31T09:58:38Z<p>Nadenislamarre: /* Rules */</p>
<hr />
<div>=Rules=<br />
# if you play alone or all players are dead except yourself, you cannot get points<br />
# the bank has 10.000 points. This is the maximum number of points you can get.<br />
# you start with 0 points<br />
# when you die, you give your points to the bank back<br />
# when a level starts, each player give 10% of his points to the pot (or 1 point if you have between 1 and 9 points). The bank does the same. It means that for each round, approximatively 1.000 points can be won (but 10% of yours are included into them).<br />
# when you take a strawberry, you take a number of points (the pot / the number of the strawberries at the start of the level +1)<br />
# when you finish the level, you get the remaining points of the pot<br />
# when you do a somersault, you get 1 point<br />
# when nobody wins, the pot is distributed back to the players and the bank depending on their contribution<br />
<br />
==Example==<br />
* Player A and B join the game.<br />
* Level 1 starts, the level has 9 strawberries<br />
* The pot is 1000 (10% of the bank points. Players have no points)<br />
* Player A takes a strawberry. He receives 100 points (1000 / (9+1))<br />
* Players dies. The 900 points remaining go back to the bank (the bank contributed at 100%).<br />
* Level 2 starts, the level has no strawberry<br />
* The pot is 1000 (990 from the bank, 10 from player A)<br />
* Players dies. 990 points go back to the bank. 10 points go back to player A.<br />
<br />
=Modify the rules=<br />
<br />
Rules are technically defined in a lua file here :<br />
http://svn.tuxfamily.org/viewvc.cgi/xmoto_xmoto/trunk/bin/Rules/classical.rules?view=markup</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_rules_(slave_mode)&diff=6063Server rules (slave mode)2011-03-26T20:36:48Z<p>Nadenislamarre: Created page with '=Rules= # if you play alone or all players are dead, you cannot get points # the bank has 10.000 points. This is the maximum number of points you can get. # you start with 0 poin…'</p>
<hr />
<div>=Rules=<br />
# if you play alone or all players are dead, you cannot get points<br />
# the bank has 10.000 points. This is the maximum number of points you can get.<br />
# you start with 0 points<br />
# when you die, you give your points to the bank back<br />
# when a level starts, each player give 10% of his points to the pot (or 1 point if you have between 1 and 9 points). The bank does the same<br />
# when you take a strawberry, you take a number of points (the pot / the number of the strawberries at the start of the level +1)<br />
# when you finish the level, you get the remaining points in the pot<br />
# when you do a somersault, you get 1 point<br />
# when nobody wins, the pot is distributed back to the players and the bank depending on their contribution<br />
<br />
==Example==<br />
* Player A and B join the game.<br />
* Level 1 starts, the level has 9 strawberries<br />
* The pot is 1000 (10% of the bank points. Players have no points)<br />
* Player A takes a strawberry. He receives 100 points (1000 / (9+1))<br />
* Players dies. The 900 points remaining go back to the bank (the bank contributed at 100%).<br />
* Level 2 starts, the level has no strawberry<br />
* The pot is 1000 (990 from the bank, 10 from player A)<br />
* Players dies. 990 points go back to the bank. 10 points go back to player A.<br />
<br />
=Modify the rules=<br />
<br />
Rules are technically defined in a lua file here :<br />
http://svn.tuxfamily.org/viewvc.cgi/xmoto_xmoto/trunk/bin/Rules/classical.rules?view=markup</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Main_Page&diff=6062Main Page2011-03-26T20:23:57Z<p>Nadenislamarre: /* Information */</p>
<hr />
<div>__NOTOC__<br />
<br />
[[de:Main_Page|Deutsch]] - [[ca:Main_Page|Català]] - [[es:Main_Page|Español]] - [[fr:Main_Page|Français]] - [[no:Main_Page|Norsk]] - [[pt:Main_Page|Portuguese]] -<br />
[[fi:Main_Page|Suomi]]<br />
<br />
== Information ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Return to Home Page]<br />
* [[manual|X-Moto Manual]]<br />
* [[Server command line|X-Moto server command line]]<br />
* [[Screenshots]]<br />
* [[Faq|FAQ]]<br />
* [[Philip's_xmoto_guide|Philips X-Moto Guide]]<br />
* [[X-Moto on PSP]]<br />
* [[IRC tutorial]]<br />
* [[Public X-Moto servers]]<br />
* [[Wiki Contributors]]<br />
* [[Server rules (slave mode)]]<br />
* [[Network Rules]]<br />
<br />
'''Features'''<br />
* [[Use X-Moto on a USB-Key]]<br />
* [[Use private rooms in game (instead of World Highscores)]]<br />
* [[Joystick|Using a joystick to control the game]]<br />
* [[Wiimote|Using a wiimote to control the game]]<br />
* [[record_video|Recording Ingame Videos]]<br />
* [[Convert a replay to a video]]<br />
* [[Recording videos with an external program]]<br />
* [[how to capture, edit and create a movie]]<br />
<br />
== Level Creation ==<br />
<br />
*[[About good level design]]<br />
*[[Level Checklist (for Creators and Testers)]]<br />
*[[Level FAQ]]<br />
*[[Notes on Checkpoints]]<br />
<br />
'''Editor'''<br />
* [[How to create smooth levels using Inkscape|How to create a smooth level with Inksmoto Level Editor]]<br />
* [[xmoto-edit|How to create a level with xmoto-edit (DEPRECATED)]]<br />
* [[Scripted levels|How to create a scripted level (please look scripting section below)]]<br />
* [[Others tips to make levels]]<br />
* [[Shortcuts for most used actions in the editor]]<br />
* [[Video tutorials]]<br />
'''Themes and Graphics'''<br />
* [[Make a theme|Make a theme/add a new sprite or texture]]<br />
* [[textures_creation|How to handle your own textures for level creation]]<br />
* [[How to create, test and upload an animated sprite]]<br />
* [[Background graphics pool|Background Graphics Pool]]<br />
* [[sprites_pool|Sprites Pool 4 Gimp]]<br />
* [[Svg Block Pool]]<br />
* [[Transparent Water|How to make transparent water]]<br />
'''Scripting'''<br />
* [[Basics of Scripting]]<br />
* [[How to include Scripts into a Level]]<br />
* [[LTS - Learn To Script Series]]<br />
* [[Funtions for Game Events| Funtions for Game Events (Zones, OnSomersaults, etc.)]]<br />
* [[Scripted levels| List of Scripting Functions]]<br />
* [[Level alteration Functions| Level alteration Functions (Blocks, Physics, etc.)]]<br />
* [[Player Functions| Player Functions (Win, Kill,Positioning, etc.) )]]<br />
* [[Camera Functions| Camera Functions (Zooming, Rotation, etc.)]]<br />
* [[Sound Functions]]<br />
'''Mods, Scripts and Helpers'''<br />
* [[Skate Park Mod]]<br />
* [[Camera Scripts]]<br />
* [[Helpers]]<br />
'''Developing'''<br />
* [[Getting svn of inksmoto (svg2lvl) for windows using Tortoise SVN]]<br />
<br />
== Building XMoto ==<br />
* [[Build for Unix (like GNU/Linux)]]<br />
* [[Build for MacOSX]]<br />
* [[Build for Windows]]<br />
* [[Build from SVN]]<br />
* [[Build with CMake (experimental)]]<br />
<br />
== Administration ==<br />
* [[How to validate a highscore]]<br />
* [[How to validate a level]]<br />
* [[How to validate a sprite]]<br />
* [[Forum's administration changes]]<br />
* [[How to unvalidate a highscore]]<br />
* [[How to update po pictures]]<br />
* [[How to remove a validated level]]<br />
<br />
== Development ==<br />
* [[Code documentation]]<br />
* [[Contributions|How to contribute to X-Moto]]<br />
* [[Translate X-Moto and X-Moto Website into your language]]<br />
* [[File formats]]<br />
* [http://www.pacquiaomosleyfight.com Pacquiao vs Mosley]<br />
* [[Net protocol]]<br />
* [[Access to the website sources]]<br />
* [http://pacquiao-vs-mosley-fights.blogspot.com Pacquiao vs Mosley]<br />
* [[SDL_gfx|SDL_gfx porting effort]]<br />
* [[Chipmunk integration]]<br />
* [[Level collection list]]<br />
* [[Multiplayer design]]<br />
* [[Deliver a X-Moto version MEMO]]<br />
* [[Rooms competition idea]]</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Use_X-Moto_on_a_USB-Key&diff=5882Use X-Moto on a USB-Key2011-02-02T14:27:57Z<p>Nadenislamarre: </p>
<hr />
<div>When you run xmoto, it creates a directory into ~/.xmoto, then, if you put xmoto on a usb key and change of computer, you don't find your data back.<br />
By the way, xmoto has an option "--configpath" to change the directory where data are saved.<br />
<br />
==Windows==<br />
# Copy xmoto and files (get the .zip package for example) on a usb key<br />
# Copy the following [[#Media:xmoto_local.bat|this section]] next xmoto.exe and run the .bat<br />
<br />
The .bat runs xmoto with the configpath option set to myConfig<br />
<br />
<br />
===Media:xmoto_local.bat===<br />
This file contains only one line:<br />
start xmoto --configpath "%cd%\myConfig" --noDBDirsCheck<br />
<br />
--noDBDirsCheck appears with X-Moto 0.4.3</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Deliver_a_X-Moto_version_MEMO&diff=5881Deliver a X-Moto version MEMO2011-01-21T19:39:27Z<p>Nadenislamarre: /* Update ChangeLog on the website */</p>
<hr />
<div>To make a new release, do the following in same order:<br />
<br />
===Modify src/XMBuild_info.h :===<br />
* remove the BUILD_EXTRAINFO, <br />
* check the version<br />
===Modify configure.in :===<br />
* AM_INIT_AUTOMAKE(xmoto,x.y.z)<br />
===Modify the README===<br />
* check the version, the date, authors<br />
===Modify the ChangeLog===<br />
* date, <br />
* get Changelog data from svn:<br>svn log -r $revision_of_last_release:HEAD<br />
===Update bin/default/*.xml:===<br />
* get highscores.xml and levels.xml from website, and put them into the svn (it will set infos like children / quality / difficulty at startup for new install)<br><br>http://xmoto.tuxfamily.org/highscores.xml<br>http://xmoto.tuxfamily.org/levels.xml<br />
===Build packages and put them on the ftp===<br />
* be sure you've the svn trunk up to date, and no modification:<br>svn -q status<br />
* '''Linux build:'''<br>make dist-gzip => it will build the tar.gz for sources or xmoto in your trunk<br />
* '''Windows build:'''<br>set build destination to mingw32:<br>sh configure_mingw_from_linux.sh<br>sh make_windows_package.sh<br><br />
* rename the files as desired and create a directory on the server so that it appears here:<br>http://download.tuxfamily.org/xmoto/xmoto/<br>with other versions<br />
===Create the svn tag===<br />
* svn cp svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk<br>svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/tags/V_x_y_z<br />
* after that, you're no more allowed to do any commit for recent version<br />
===Update todo.tuxfamily.org===<br />
* update todo.tuxfamily.org:<br>add a new version, set past version<br />
===Update ChangeLog on the website===<br />
* copy Changelog from trunk to website-repo<br />
scp ChangeLog aspegic500@ssh.tuxfamily.org:/home/xmoto/xmoto.tuxfamily.org-web/htdocs/dev<br />
<br />
===Send News mailing list a mail===<br />
* use past mails to get the adresses<br />
===Update News page on the website===<br />
* access server using ftp, xmoto-website/htdocs/pages/news.php (or something like that)<br />
===Add the new version in the 'versions' website database's table===<br />
* (used by inksmoto)<br />
* use phpMyAdmin, access database, search the required field</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Use_X-Moto_on_a_USB-Key&diff=5880Use X-Moto on a USB-Key2011-01-21T13:07:56Z<p>Nadenislamarre: /* Media:xmoto_local.bat */</p>
<hr />
<div>When you run xmoto, it creates a directory into ~/.xmoto, then, if you put xmoto on a usb key and change of computer, you don't find your data back.<br />
By the way, xmoto has an option "--configpath" to change the directory where data are saved.<br />
<br />
==Windows==<br />
# Copy xmoto and files (get the .zip package for example) on a usb key<br />
# Copy the following [[#Media:xmoto_local.bat|this section]] next xmoto.exe and run the .bat<br />
<br />
The .bat runs xmoto with the configpath option set to myConfig<br />
<br />
<br />
===Media:xmoto_local.bat===<br />
This file contains only one line:<br />
@xmoto --configpath %cd%/myConfig --noDBDirsCheck<br />
<br />
--noDBDirsCheck appears with X-Moto 0.4.3</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Player_Functions&diff=5854Player Functions2011-01-05T22:06:19Z<p>Nadenislamarre: /* GetPlayerProfileName() */</p>
<hr />
<div>= Script Player Functions =<br />
<br />
<br />
== GetPlayerProfileName() ==<br />
[*deprecated* -- cannot be used anymore]<br />
=== Explanation ===<br />
This function returns a string with the players profile name.<br />
<br />
=== Script Example ===<br />
This example prints the players profile name on level start.<br />
<br />
function OnLoad()<br />
name = Game.GetPlayerProfileName()<br />
Game.Message(name)<br />
return true<br />
end<br />
<br />
== SetPlayerPosition(x, y, bRight) ==<br />
=== Explanation ===<br />
Set the position and direction of the players in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example teleports the playerq each time one enters the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
<br />
== SetAPlayerPosition(x, y, bRight, player) ==<br />
=== Explanation ===<br />
Set the position and direction of the player in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example show how to teleport the player 0 at start of the level to the position (20, 5)<br />
<br />
function OnLoad()<br />
Game.SetAPlayerPosition(20, 5, 1, 0)<br />
return true<br />
end<br />
<br />
<br />
== GetPlayerPosition() ==<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of the player 0 in the game.<br />
<br />
=== Script example ===<br />
This example make the player unable to get the strawberry ;-)<br />
<br />
function Tick()<br />
x, y, bright = Game.GetPlayerPosition()<br />
if x > 18<br />
then<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
return true<br />
end<br />
<br />
<br />
== GetPlayerVelocity(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the velocity of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
<br />
== GetPlayerSpeed(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the speed of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
<br />
== GetPlayerAngle(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the angle of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
<br />
== GetAPlayerPosition(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of a player in the game.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
x, y, bright = Game.GetAPlayerPosition(0)<br />
Game.Message("Player0 position is ("..x..","..y..")")<br />
return true<br />
end<br />
<br />
<br />
== KillPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the players die. It's interesting if you want the players be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
In the following example, the player will die when he will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillPlayer()<br />
end<br />
<br />
<br />
== KillAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player dies. It's interesting if you want the player be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.KillAPlayer(0)<br />
return true<br />
end<br />
<br />
<br />
== WinPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, all players win the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
In the following example, the player win on entering in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.WinPlayer()<br />
end<br />
<br />
<br />
== WinAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player wins the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.WinAPlayer(0)<br />
return true<br />
end</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Scripted_levels&diff=5456Scripted levels2010-11-20T19:50:32Z<p>Nadenislamarre: /* Explanation */</p>
<hr />
<div>[[Ca:Scripted levels|Català]] - [[Es:Scripted levels|Español]]<br />
<br />
= Introduction =<br />
Scripting allows a level to become dynamic. You can change physic settings, move objects, modify game logic, etc. A script is written in the Lua language and can be included in a level file.<br />
<br />
Documentation about Lua can be found here :<br />
http://www.lua.org/manual/5.1/<br />
<br />
To write a script, you must know a little about a level file. It is an xml file. It includes somes properties like the name of the level, description, author, date, etc. Moreover, it includes block and sprite definitions. A block is composed of vertices which link together to draw polygons.<br />
<br />
Since 0.3.0, xmoto supports multiplayers ; in the script, a player is defined by an index. The first player has the number 0, the second the number 1, ...<br />
<br />
The script examples on this page will use this basic level file:<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<level id="tutscript"><br />
<info><br />
<name>tutscript</name><br />
<description></description><br />
<author></author><br />
<date></date><br />
<sky>sky1</sky><br />
</info><br />
<script><br />
</script><br />
<limits left="0" right="50" top="30" bottom="0"/><br />
<block id="Block0"><br />
<position x="0" y="0"/><br />
<usetexture id="default"/><br />
<vertex x="5" y="5"/><br />
<vertex x="5" y="10"/><br />
<vertex x="10" y="10"/><br />
<vertex x="10" y="5"/><br />
</block><br />
<entity id="MyPlayerStart0" typeid="PlayerStart"><br />
<size r="0.4"/><br />
<position x="7.5" y="10"/><br />
</entity><br />
<entity id="Strawberry0" typeid="Strawberry"><br />
<size r="0.4"/><br />
<position x="20" y="0.5"/><br />
</entity><br />
<entity id="SnowMan0" typeid="Sprite"><br />
<param name="name" value="SnowMan"/><br />
<position x="19" y="0.2"/><br />
<param name="z" value="-1"/><br />
</entity><br />
<zone id="Zone0"><br />
<box left="40" right="50" top="5" bottom="0"/><br />
</zone><br />
</level><br />
<br />
This level can be made easily with the xmoto level editor. It includes a block called Block0 which is a square, a strawberry called Strawberry0 and a zone called Zone0. A zone is an invisible part of the level that can execute actions when the player is inside.<br />
<br />
Some functions require a minimum X-Moto version to work. If you use one of these functions, please put this information in the level. For example, to make your level require X-Moto version 0.2.0, add this line to your level:<br />
<br />
<level id="tutscript" rversion="0.2.0"><br />
<br />
[[Image:Scripted_level.jpg]]<br />
<br />
All the code of the script is written in Lua. You can find the syntax here. However, if you choose to include the script in an xml file, < and > symbol must be replaced by &amp;lt; and &amp;gt;. The code of the script can be included between <script> and </script> in the level file.<br />
<br />
= Timers =<br />
== StartTimer(Name,Delay=100,Loops=0) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
This function is used to create a timer, or start a stopped timer. Basically, if you don't give all parameters the timer uses default values, or if the timer already exists then it is resetted, or started if it is stopped with Game.StopTimer().<br />
<br />
'''Cases''': <br />
* if timer doesn't exist then creates<br />
* if timer exist and is stopped then restarts (unless you give attributes delay or loops then it is reseted)<br />
* if timer exist and is running then resets <br />
=== Script Example ===<br />
--------------------------<br />
--Delayed Message System--<br />
-----by tuhoojabotti------<br />
--------------------------<br />
--stuff for the msgs<br />
msgs={}<br />
msgt={}<br />
msga=0<br />
<br />
--other<br />
Zone0={}<br />
<br />
function OnLoad()<br />
StartMessages({"Hello and welcome!","This level uses timers to show these messages.","Press 'B' to pause and continue messages.","Go right and if you hit the Zone, the messages will end!","I have nothing else to say, good night!"},150)<br />
Game.SetKeyHook("B","stop")<br />
return true<br />
end<br />
<br />
function stop()<br />
ToggleMessages()<br />
end<br />
<br />
function Zone0.OnEnter()<br />
ClearMessages()<br />
end<br />
<br />
--functions for the message system<br />
function StartMessages(_msgs,_delay)<br />
msga=1; msgs=_msgs; Game.StartTimer("msgt",_delay,table.getn(msgs))<br />
end<br />
function ToggleMessages()<br />
if not(table.getn(msgs)==0) then --only if there are messages<br />
if msga==1 then --msgs are rolling<br />
msga=0; Game.StopTimer("msgt")<br />
else --no msgs rolling<br />
msga=1; Game.StartTimer("msgt")<br />
end<br />
end<br />
end<br />
function msgt.Tick(n)<br />
if table.getn(msgs)>=n then --there are messages<br />
Game.Message(msgs[n])<br />
if table.getn(msgs)==n then msga=0 end --shutdown on last msg<br />
end<br />
end<br />
function ClearMessages()<br />
if msga==1 then Game.StopTimer("msgt") end<br />
msgs={}; msga=0; msgd=0<br />
end<br />
<br />
== SetTimerDelay(Name,Delay) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
Sets the timer's delay, without resetting the amount of loops etc. (Allows you to speed it up or slow it down. ;-))<br />
=== Script Example ===<br />
timer={} --declare the timer<br />
entity1={}<br />
function OnLoad()<br />
Game.Message("You are going to die in 10 seconds!! buahahhahahaaa!")<br />
Game.StartTimer("timer",1000,1)<br />
return true<br />
end<br />
function timer.Tick()<br />
Game.KillPlayer()<br />
end<br />
function entity1.Touch()<br />
Game.Message("haha! you drank some poison, now you die faster!")<br />
Game.SetTimerDelay("timer",300)<br />
end<br />
== StopTimer(Name) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
Stops the timer, the Name.Tick won't be called anymore. Use Game.StartTimer(Name) to restart it.<br />
=== Script Example ===<br />
timer={} --declare the timer<br />
entity1={}<br />
function OnLoad()<br />
Game.Message("You are going to die in 10 seconds!! buahahhahahaaa!")<br />
Game.StartTimer("timer",1000,1)<br />
return true<br />
end<br />
function timer.Tick()<br />
Game.KillPlayer()<br />
end<br />
function entity1.Touch()<br />
Game.Message("No! you found antidote!")<br />
Game.StopTimer("timer")<br />
end<br />
<br />
= Functions called by XMoto =<br />
<br />
== OnLoad() ==<br />
=== Explanation ===<br />
This function is called one time when the level starts. You must return true if nothing bad happened.<br />
<br />
=== Script example ===<br />
The example displays a message at the start of the level.<br />
<br />
function OnLoad()<br />
Game.Message("This level is scripted")<br />
return true<br />
end<br />
<br />
== Tick() ==<br />
=== Explanation ===<br />
Function called 1 time every hundredth.<br />
You must return true if nothing bad happened.<br />
Be aware that if this function use is abusive, levels will not be validated :<br />
action function like setBlockPos, setPlayerPos, ...<br />
(contrary to request function getBlockPos, getTime, and lua code)<br />
require that the information is store into the replay. If you put a setBlockPos<br />
call into the Tick function, it will make big replays : around 20 bytes * 100 * 60 / minute<br />
=> several hundreads of KB / minute<br />
To limit this if you really want to call such functions into your level :<br />
- first, play your level and check that replay size is under 100 ko<br />
- reduce the number of time you call setBlockPos by adding a variable to make<br />
this function called not in all Tick() but 1/3 for example<br />
- add a zone so that the animation (tick) is called only when you're<br />
in this zone<br />
- use dynamicBlock or dynamicEntity functions<br />
<br />
=== Script example ===<br />
This example will initialize gravity to 0 ; then, it will increment it with the time. Because earth gravity is 9.81, the earth gravity will not be reached before the 9.81 seconds. Be aware that in xmoto, vertical gravity must be multiplied by -1 because of screen coords which are reversed.<br />
<br />
function Tick()<br />
if Game.GetTime() < 9.81<br />
then<br />
Game.SetGravity(0, Game.GetTime() * -1)<br />
end<br />
return true<br />
end<br />
<br />
function Load()<br />
Game.SetGravity(0, 0)<br />
return true<br />
end<br />
<br />
== Entity.Touch() ==<br />
=== Explanation ===<br />
This function is called when an entity (a strawberry for example) is touched. The entity must be declared in the script. Note that the <size r> parameter allows to choose the distance of the entity which must be considered so that it is touched.<br />
<br />
=== Script example ===<br />
The example displays a message when the strawberry is touched.<br />
<br />
Strawberry0 = {}<br />
<br />
function Strawberry0.Touch()<br />
Game.Message("Nice strawberry !")<br />
end<br />
<br />
== Entity.TouchBy(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when an entity (a strawberry for example) is touched. The entity must be declared in the script. Note that the <size r> parameter allows to choose the distance of the entity which must be considered so that it is touched.<br />
<br />
=== Script example ===<br />
The example displays a message when the strawberry is touched.<br />
<br />
Strawberry0 = {}<br />
<br />
function Strawberry0.TouchBy(player)<br />
Game.Message("Player "..player.." takes the strawberry")<br />
end<br />
<br />
== Zone.OnEnter() ==<br />
=== Explanation ===<br />
This function is called when a player enters in a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player enters into the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.Message("Entering in the zone")<br />
end<br />
<br />
== Zone.OnEnterBy(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when a player enters in a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player enters into the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnterBy(player)<br />
Game.Message("Player "..player.." enters the zone")<br />
end<br />
<br />
== Zone.OnLeave() ==<br />
=== Explanation ===<br />
This function is called when a player leaves a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player leaves the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnLeave()<br />
Game.Message("Leaving the zone")<br />
end<br />
<br />
== Zone.OnLeaveBy() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when a player leaves a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player leaves the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnLeaveBy(player)<br />
Game.Message("Player "..player.." leaves the zone")<br />
end<br />
<br />
== OnSomersault(bClockWise) ==<br />
[require Xmoto >= 0.2.1]<br />
<br />
=== Explanation ===<br />
This function is called each time a player make a new somersault. bClockWise is 1 is the somersault is clockwise, 0 if counterclockwise.<br />
<br />
=== Script example ===<br />
The example displays a message when a player makes a somersault.<br />
<br />
function OnSomersault(bClockWise)<br />
if(bClockWise == 1) <br />
then<br />
Game.Message("ClockWise Somersault")<br />
else<br />
Game.Message("CounterClockWise Somersault")<br />
end<br />
end<br />
<br />
== OnSomersaultBy(bClockWise, player) ==<br />
[require Xmoto >= 0.3.0]<br />
<br />
=== Explanation ===<br />
This function is called each time a player make a new somersault. bClockWise is 1 is the somersault is clockwise, 0 if counterclockwise.<br />
<br />
=== Script example ===<br />
The example displays a message when a player makes a somersault.<br />
<br />
function OnSomersaultBy(bClockWise, player)<br />
Game.Message("Nice, player "..player" !)<br />
end<br />
<br />
== OnWheel1Touchs(status), OnWheel2Touchs(status) ==<br />
[require Xmoto >= 0.2.1]<br />
<br />
=== Explanation ===<br />
This function is called each time just the wheel 1 touchs the ground or stops to touch the ground. (status is 1 is the ground was not touching and is now touching, and 0 else)<br />
<br />
=== Script example ===<br />
The example displays the new max duration of a jump each time a new one is done.<br />
<br />
max_jump_time = 1.0 -- start at 1 to not count smaller jumps<br />
jump_begin = 0.0<br />
touch_1 = false<br />
touch_2 = false<br />
<br />
function OnWheel1Touchs(bStatus)<br />
if(bStatus == 1) <br />
then<br />
updateMax()<br />
touch_1 = true<br />
else<br />
touch_1 = false<br />
jump_begin = Game.GetTime()<br />
end<br />
end<br />
<br />
function OnWheel2Touchs(bStatus)<br />
if(bStatus == 1) <br />
then<br />
updateMax()<br />
touch_2 = true<br />
else<br />
touch_2 = false<br />
jump_begin = Game.GetTime()<br />
end<br />
end<br />
<br />
function updateMax()<br />
if(touch_1 == false and touch_2 == false)<br />
then<br />
if(Game.GetTime() - jump_begin > max_jump_time)<br />
then<br />
max_jump_time = Game.GetTime() - jump_begin<br />
Game.Message("New high jump: "..max_jump_time)<br />
end<br />
end<br />
end<br />
<br />
== OnWheel1TouchsBy(status, player), OnWheel2TouchsBy(status, player) ==<br />
[require Xmoto >= 0.3.0]<br />
<br />
=== Explanation ===<br />
This function is called each time just the wheel 1 touchs the ground or stops to touch the ground. (status is 1 is the ground was not touching and is now touching, and 0 else)<br />
<br />
=== Script example ===<br />
function OnWheel1TouchsBy(status, player)<br />
if(status == 1) <br />
then<br />
Game.Message("Player "..player.." touches with wheel 1")<br />
end<br />
end<br />
<br />
function OnWheel2TouchsBy(status, player)<br />
if(status == 1) <br />
then<br />
Game.Message("Player "..player.." touches with wheel 2")<br />
end<br />
end<br />
<br />
= Callable X-Moto functions =<br />
<br />
== GetTime() ==<br />
=== Explanation ===<br />
Return the time since the start of the level.<br />
<br />
=== Script example ===<br />
The example displays a message if the player takes more than 10 seconds to enter the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
if Game.GetTime() > 10.0<br />
then<br />
Game.Message("10 seconds to come there, that's a lot !")<br />
end<br />
end<br />
<br />
== Message(msgs) ==<br />
=== Explanation ===<br />
Display a message on the screen. The message is automatically remove after 5 seconds. You can call this function several times : the messages will be all displayed.<br />
<br />
=== Script example ===<br />
The example displays some messages at the start of the level.<br />
<br />
function OnLoad()<br />
Game.Message("This level is scripted")<br />
Game.Message("GO GO GO !!!")<br />
return true<br />
end<br />
<br />
== ClearMessages() ==<br />
=== Explanation ===<br />
Remove messages on the screen.<br />
<br />
=== Script example ===<br />
The example shows how to clear old messages and display a new one in some circumstances.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.ClearMessages()<br />
Game.Message("OnEnter")<br />
end<br />
<br />
function Zone0.OnLeave()<br />
Game.ClearMessages()<br />
Game.Message("OnLeave")<br />
end<br />
<br />
== SetGravity(x, y) ==<br />
=== Explanation ===<br />
Change the gravity (horizontal and vertical) in the game.<br />
<br />
=== Script example ===<br />
The example shows how to reverse gravity. Be aware that in X-Moto, vertical gravity must be multiplied by -1 because screen coordinates are reversed in the y direction.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0, 9.81)<br />
return true<br />
end<br />
<br />
== GetGravity() ==<br />
=== Explanation ===<br />
Return the pair(horizontal gravity, vertical gravity).<br />
<br />
=== Script example ===<br />
The example displays the wind and gravity at the start of the level.<br />
<br />
function OnLoad()<br />
x, y = Game.GetGravity()<br />
Game.Message("Wind : "..x)<br />
Game.Message("Gravity : "..(y*-1))<br />
return true<br />
end<br />
<br />
== IsPlayerInZone(zone) ==<br />
=== Explanation ===<br />
Return true if a player is in the specified zone.<br />
<br />
=== Script example ===<br />
This example is a bit more complicated. When the player enters the zone, gravity slowly decreases. Once the player leaves the zone, the gravity suddenly becomes 9.81.<br />
<br />
Zone0 = {}<br />
x = -9.81<br />
<br />
function Tick()<br />
if Game.IsPlayerInZone("Zone0")<br />
then<br />
Game.SetGravity(0, x)<br />
x = x + 0.1<br />
end<br />
<br />
return true<br />
end<br />
<br />
function Zone0.OnLeave()<br />
x = -9.81<br />
Game.SetGravity(0, x)<br />
end<br />
<br />
== IsAPlayerInZone(zone, player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return true if the player is in the specified zone.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
if Game.IsAPlayerInZone("Zone0", 0) == false<br />
then<br />
Game.Message("This player 0 is not in the zone")<br />
end<br />
return true<br />
end<br />
<br />
== SetPlayerPosition(x, y, bRight) ==<br />
=== Explanation ===<br />
Set the position and direction of the players in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example teleports the playerq each time one enters the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
== SetAPlayerPosition(x, y, bRight, player) ==<br />
=== Explanation ===<br />
Set the position and direction of the player in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example show how to teleport the player 0 at start of the level to the position (20, 5)<br />
<br />
function OnLoad()<br />
Game.SetAPlayerPosition(20, 5, 1, 0)<br />
return true<br />
end<br />
<br />
== GetPlayerPosition() ==<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of the player 0 in the game.<br />
<br />
=== Script example ===<br />
This example make the player unable to get the strawberry ;-)<br />
<br />
function Tick()<br />
x, y, bright = Game.GetPlayerPosition()<br />
if x > 18<br />
then<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== GetPlayerVelocity(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the velocity of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetPlayerSpeed(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the speed of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetPlayerAngle(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the angle of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetAPlayerPosition(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of a player in the game.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
x, y, bright = Game.GetAPlayerPosition(0)<br />
Game.Message("Player0 position is ("..x..","..y..")")<br />
return true<br />
end<br />
<br />
== SetEntityPos(entity, x, y) ==<br />
=== Explanation ===<br />
Set the position of the entity to coordinates (x, y) in the game.<br />
<br />
=== Script example ===<br />
The example changes the position of the strawberry every second.<br />
<br />
function Tick()<br />
i,f = math.mod(math.ceil(Game.GetTime()), 2)<br />
<br />
if i == 1<br />
then<br />
Game.SetEntityPos("Strawberry0", 10, 0.5)<br />
else<br />
Game.SetEntityPos("Strawberry0", 30, 0.5)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== GetEntityPos(entity) ==<br />
=== Explanation ===<br />
Return the position of the entity entity in the game.<br />
<br />
=== Script example ===<br />
This example shows another way to move a strawberry.<br />
<br />
last_update = 0<br />
<br />
function Tick()<br />
sec = math.ceil(Game.GetTime())<br />
<br />
if last_update < sec<br />
then<br />
x, y = Game.GetEntityPos("Strawberry0")<br />
<br />
if(x == 20)<br />
then<br />
x_new = 25<br />
else<br />
x_new = 20<br />
end<br />
<br />
if(y == 0.5)<br />
then<br />
y_new = 2<br />
else<br />
y_new = 0.5<br />
end<br />
<br />
Game.SetEntityPos("Strawberry0", x_new, y_new)<br />
last_update = sec<br />
end<br />
<br />
return true<br />
end<br />
<br />
== SetKeyHook(key, function) ==<br />
=== Explanation ===<br />
Whenever the player hits the "key" specified, a function will be called.<br />
You can use key like "a", "b", "c" or technical values returned by GetKeyByActionTech<br />
<br />
=== Script example ===<br />
The example shows how to change gravity just by pressing a key.<br />
<br />
g = -9.81<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("G", "GravityChange")<br />
return true<br />
end<br />
<br />
function GravityChange()<br />
g = g * -1<br />
Game.SetGravity(0, g)<br />
end<br />
<br />
== GetKeyByAction(function) ==<br />
=== Explanation ===<br />
Return the key associated to an action. Possible actions are Drive, Brake, PullBack, PushForward, ChangeDirection.<br />
<br />
=== Script example ===<br />
The example displays how to drive at level start.<br />
<br />
function OnLoad()<br />
Game.Message("To drive, press "..Game.GetKeyByAction("Drive"))<br />
return true<br />
end<br />
<br />
== GetKeyByActionTech(function) ==<br />
[require Xmoto >= 0.5.4] <br />
=== Explanation ===<br />
Return the key associated to an action. Possible actions are Drive, Brake, PullBack, PushForward, ChangeDirection.<br />
Note that GetKeyByAction returns a human readable string while GetKeyByActionTech returns a value which is usable by SetKeyHook and that can be a joystick, mouse or keyboard key.<br />
<br />
=== Script example ===<br />
The example show how to use the Drive key to do other things than driving.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook(Game.GetKeyByActionTech("Drive"), "BalloonA")<br />
return true<br />
end<br />
<br />
== Log(msgs) ==<br />
=== Explanation ===<br />
Log a message in the xmoto.log.<br />
<br />
=== Script example ===<br />
The example log the message "An error occured" when the level starts.<br />
<br />
function OnLoad()<br />
Game.Log("An error occured")<br />
return true<br />
end<br />
<br />
== MoveBlock(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function allows X-Moto to move a block in the level. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />). Be aware that moving a block can be dangerous: make sure that the player will not be inside the block once you have moved it.<br />
<br />
=== Script example ===<br />
In the example, when the player presses the key M, the block moves to the right.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "MoveTheBlock")<br />
return true<br />
end<br />
<br />
function MoveTheBlock()<br />
Game.MoveBlock("Block0", 1, 0)<br />
end<br />
<br />
== SetBlockCenter(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function gives the center of the block relative to the block position (then, to the level if block position is (0, 0)). The center is used by the function SetBlockPos(), GetBlockPos() and SetBlockRotation(). This function should generally used in the Load() function because the center should not logically be changed (however, you can change it).<br />
<br />
=== Script example ===<br />
In the example, the center of the block is set to the center of the square. Then, when the player press M, the block is placed just under the player.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
<br />
== SetBlockPos(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function allows X-Moto to change the position of a block according to its center. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />). Be aware that moving a block can be dangerous: make sure that the player will not be inside the block once you have moved it.<br />
<br />
=== Script example ===<br />
In the example, the center of the block is set to the center of the square. Then, when the player press M, the block is placed just under the player.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
<br />
== GetBlockPos(block) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function gives the position of a given block. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
The example shows how to use this function as a condition. Here, you can move the block under the bike only if you play on the right.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
bx, by = Game.GetBlockPos("Block0")<br />
if(x > bx)<br />
then<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
end<br />
<br />
== SetBlockRotation(block, angle) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function rotates a block. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
In the example, if the player keeps the key M pressed, the block will rotate.<br />
<br />
a = 0<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
a = a + math.pi / 256.0<br />
Game.SetBlockRotation("Block0", a)<br />
end<br />
<br />
== SetDynamicEntityRotation(entity, initAngle, radius, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function tells an entity to make circles for a given duration. The current position of the entity on the circle of radius radius is at position initAngle (in rad). The entity will make a circle in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negative arguments allow you to change the behavior of the animation. For example, a negative period will rotate the entity in the negative direction.<br />
<br />
=== Script example ===<br />
The example shows how to easily move the strawberry. InitAngle is set to -PI/2 because the strawberry is placed at the bottom where we want it moves.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityRotation("Strawberry0", -math.pi/2, 2, 500, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicEntitySelfRotation(entity, period, startTime, endTime) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function allows to tell an entity to rotate for a given duration. The entity will rotate in period hundreads. The animation will start in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense.<br />
<br />
=== Script example ===<br />
The example shows how to rotate easily a entity.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntitySelfRotation("Entity2", 1000, 0, 0);<br />
return true;<br />
end;<br />
<br />
== SetDynamicEntityTranslation(entity, fX, fY, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function allows to tell an entity to make translation for a given duration. The translation's length is fX on the X axis and fY on the Y axis. The entity will make the translation in period/2 hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation.<br />
<br />
=== Script example ===<br />
The example shows an example of composed animations.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityTranslation("Strawberry0", 10, 0, 500, 0, 0)<br />
Game.SetDynamicEntityTranslation("Strawberry0", 0, 1, 100, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicEntityNone(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function removed all the animations applicated on an entity.<br />
<br />
=== Script example ===<br />
The example first shows how to ask an entity to make a translation in a first time and then, to make rotations. If the user press the key S, the strawberry stops to move.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityTranslation("Strawberry0", -2, 0, 1000, 0, 500)<br />
Game.SetDynamicEntityRotation("Strawberry0", -math.pi/2, 2, 500, 500, 0)<br />
Game.SetKeyHook("S", "StopAnimation")<br />
return true<br />
end<br />
<br />
function StopAnimation()<br />
Game.SetDynamicEntityNone("Strawberry0")<br />
end<br />
<br />
== SetDynamicBlockRotation(block, initAngle, radius, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function allows to tell a block to make circles for a given duration. The current position of the block on the circle of radius radius is at position initAngle (in rad). The block will make a circle in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make move blocks to fast otherwise the bike could go throw the block.<br />
<br />
=== Script example ===<br />
The example shows how to make move easily a block.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockRotation("Block0", -math.pi/2, 2, 500, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicBlockSelfRotation(block, period, startTime, endTime) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function allows to tell a block to rotate for a given duration. The block will rotate in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make move blocks to fast otherwise the bike could go throw the block.<br />
<br />
=== Script example ===<br />
The example shows how to rotate easily a block.<br />
<br />
function OnLoad()<br />
Game.SetBlockCenter("Block2", -2.5, -19.0);<br />
Game.SetDynamicBlockSelfRotation("Block2", 1000, 0, 0);<br />
return true;<br />
end;<br />
<br />
== SetDynamicBlockTranslation(block, fX, fY, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
<p>This function tells a block to make a translation for a given duration. A translation is a looped movement from one point to another, and back. The translation's length is fX on the X axis and fY on the Y axis. The animation will start in startTime hundredths and will finish in endTime hundredths, so the duration is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make blocks move too fast otherwise the bike could go through the block.</p><br />
<br />
<p>block: Defines which Block should move<br><br />
fX: Defines where on the X-Axis the Block should move<br><br />
fY: Defines where on the Y-Axis the Block should move<br><br />
period: Defines how long it takes the Block to move back to the starting point<br><br />
startTime: Defines when the translation should start<br><br />
endTime: Defines when the translation should end</p><br />
<br />
In order to make replay files as small as possible, you should use Translation instead of the MoveBlock function. An example on how to convert a MoveBlock function into a Translation is given below.<br />
<br />
=== Script example ===<br />
In this example, the block makes an infinite movement: It moves from its originating point (0,0) to (10,1) within 750ms, and then back in another 750ms.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 10, 1, 1500, 0, 0)<br />
return true<br />
end<br />
<br />
Example on how to convert a MoveBlock function into a Translation (see above):<br />
<br />
function Tick()<br />
Game.MoveBlock("Block0", 0.5,0)<br />
return true<br />
end<br />
<br />
Block0 moves forever to the right: 0.5px every 1/100s<br />
So it moves at a speed of 300m/60s<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 300, 0, 12000, 0, 6000)<br />
return true<br />
end<br />
<br />
This is the MoveBlock function in the translation-version. <br />
It moves 300m to the right and 300m back to the left in 12000ms. endTime is set to 12000/2=6000, so that the translation stops as soon as Block0 reaches (300,0)<br />
<br />
== SetDynamicBlockNone(block) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function stops all the animation applied on the block. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
In the example, the block will move until the player presses the key S.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 10, 1, 1500, 0, 0)<br />
Game.SetKeyHook("S", "StopAnimation")<br />
return true<br />
end<br />
<br />
function StopAnimation()<br />
Game.SetDynamicBlockNone("Block0")<br />
end<br />
<br />
== CameraZoom(z) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
In some levels, you may want that the camera is a bit more far from the player. Use this function to change the camera zoom.<br />
<br />
=== Script example ===<br />
The example shows how a different zoom can be used to play a level.<br />
<br />
function OnLoad()<br />
Game.CameraZoom(-0.05)<br />
return true<br />
end<br />
<br />
== CameraMove(x, y) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
For some particular levels, you may want the camera to be moved. Use this function to do that.<br />
<br />
=== Script example ===<br />
The example shows how you can focus a level on the part above the player.<br />
<br />
function OnLoad()<br />
Game.CameraMove(0, 3)<br />
return true<br />
end<br />
<br />
== CameraRotate(angle) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera be rotated. Use this function to do that.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.CameraRotate(math.pi / 4.0);<br />
return true<br />
end<br />
<br />
== CameraAdaptToGravity() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera be rotated. Use this function to do that in function of the gravity.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0.0, 9.81)<br />
Game.CameraAdaptToGravity()<br />
return true<br />
end<br />
<br />
== SetCameraRotationSpeed(z) ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera beeing rotated does that at a certain speed. With this function you can make it rotate either very slow ( z = 0.1 ) or extremely fast ( z = 7.2 ). The values are given in RAD, so they can reach from 0 to 2 * PI.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0.0, 9.81)<br />
Game.SetCameraRotationSpeed(0.2)<br />
Game.CameraAdaptToGravity()<br />
return true<br />
end<br />
<br />
== GetEntityRadius(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
Return the radius of an entity. This radius is used for collision. You can use this function for your own collision or anything else.<br />
<br />
=== Script example ===<br />
The example shows you the radius of the strawberry.<br />
<br />
function OnLoad()<br />
Game.Message("Radius of the strawberry : "..Game.GetEntityRadius("Strawberry0"))<br />
return true<br />
end<br />
<br />
== IsEntityTouched(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
There is a function called when you touch an entity. But sometimes you want to know when you don't touch an entity. Use this function.<br />
<br />
=== Script example ===<br />
The example shows how to make an action when the player is not touching an entity.<br />
<br />
g = -9.81<br />
<br />
function OnLoad()<br />
Game.Message("Gravity is increasing while you are not touching the snowman")<br />
return true<br />
end<br />
<br />
function Tick()<br />
if(Game.IsEntityTouched("SnowMan0") == 0)<br />
then<br />
g = g - 0.03<br />
Game.SetGravity(0, g);<br />
end<br />
return true<br />
end<br />
<br />
==Game.AddPenaltyTime(time) ==<br />
[require Xmoto >= 0.5.0]<br />
=== Explanation ===<br />
Increment the value of the time counter to make a penalty.<br />
<br />
=== Script example ===<br />
In the following example, the time will be increased of 5 seconds if the player enters in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.AddPenaltyTime(5.0)<br />
end<br />
<br />
== KillPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the players die. It's interesting if you want the players be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
In the following example, the player will die when he will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillPlayer()<br />
end<br />
<br />
== KillAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player dies. It's interesting if you want the player be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.KillAPlayer(0)<br />
return true<br />
end<br />
<br />
== KillEntity(entityID) ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the entity entityID will be deleted. The entity can be a strawberry or any sprite.<br />
<br />
=== Script example ===<br />
In the following example, the strawberry will be deleted when the player will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillEntity("Strawberry0")<br />
end<br />
<br />
== WinPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, all players win the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
In the following example, the player win on entering in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.WinPlayer()<br />
end<br />
<br />
== WinAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player wins the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.WinAPlayer(0)<br />
return true<br />
end<br />
<br />
== RemainingStrawberries() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
This function returns the number of strawberries remaining in the level.<br />
<br />
=== Script example ===<br />
In the following example, when the player will enter in the zone Zone0, the number of remaining strawberries is displayed.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.Message(Game.RemainingStrawberries())<br />
end<br />
<br />
== NumberOfPlayers() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function returns the number of players (dead or in live) in the level<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.Message(Game.NumberOfPlayers().." players")<br />
return true<br />
end<br />
<br />
== AddForceToPlayer(forceX, forceY, startTime, endTime, player) ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
This function apply an external force on the player player. The force will apply from startTime to endTime or will be infinite if endTime is 0. startTime and endTime are expressed in hundreaths and are relativ to the call function time. The force applied will be of (forceX, forceY). Application point is the center of the biker. In the example, a force will be applied to all players from time 5 to 10 seconds. Force is expressed in newton, mg/s-2 (meter * gramm / (seconds * seconds)).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
for i=0,Game.NumberOfPlayers()-1 do<br />
Game.Message("Kicking player "..(i+1))<br />
Game.AddForceToPlayer(0, 1000, 500, 1000, i)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== PlayAudio("NameOfSound") ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
Using this function you can play a sound effect (or a music). The parameter is the name of the sound, which is defined in the actually used theme file.<br />
In the following example, there must be a zone named "Zone0", As soon as you enter the zone, the sound effect is played:<br />
<br />
=== Script example ===<br />
Zone0 = {}<br />
function Zone0.OnEnter()<br />
Game.PlaySound("ring");<br />
end<br />
<br />
<br />
<br />
== SetPhysicsBlockSelfRotation (block, torque, startTime, endTime) ==<br />
[require Xmoto >= 0.5.0]<br />
=== Explanation ===<br />
This function allows to tell a block to rotate for a given duration. The rotation will be performed by applying forces (torque) on the block (if possible). The block will rotate in period hundreads. The forces application will start in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite application. Note that negativ arguments allow to change the behavior of the forces, for example, a negativ torque will tell to turn in the other sense. <br />
<br />
=== Script example ===</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Scripted_levels&diff=5455Scripted levels2010-11-20T19:48:58Z<p>Nadenislamarre: /* GetKeyByActionTech(function) */</p>
<hr />
<div>[[Ca:Scripted levels|Català]] - [[Es:Scripted levels|Español]]<br />
<br />
= Introduction =<br />
Scripting allows a level to become dynamic. You can change physic settings, move objects, modify game logic, etc. A script is written in the Lua language and can be included in a level file.<br />
<br />
Documentation about Lua can be found here :<br />
http://www.lua.org/manual/5.1/<br />
<br />
To write a script, you must know a little about a level file. It is an xml file. It includes somes properties like the name of the level, description, author, date, etc. Moreover, it includes block and sprite definitions. A block is composed of vertices which link together to draw polygons.<br />
<br />
Since 0.3.0, xmoto supports multiplayers ; in the script, a player is defined by an index. The first player has the number 0, the second the number 1, ...<br />
<br />
The script examples on this page will use this basic level file:<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<level id="tutscript"><br />
<info><br />
<name>tutscript</name><br />
<description></description><br />
<author></author><br />
<date></date><br />
<sky>sky1</sky><br />
</info><br />
<script><br />
</script><br />
<limits left="0" right="50" top="30" bottom="0"/><br />
<block id="Block0"><br />
<position x="0" y="0"/><br />
<usetexture id="default"/><br />
<vertex x="5" y="5"/><br />
<vertex x="5" y="10"/><br />
<vertex x="10" y="10"/><br />
<vertex x="10" y="5"/><br />
</block><br />
<entity id="MyPlayerStart0" typeid="PlayerStart"><br />
<size r="0.4"/><br />
<position x="7.5" y="10"/><br />
</entity><br />
<entity id="Strawberry0" typeid="Strawberry"><br />
<size r="0.4"/><br />
<position x="20" y="0.5"/><br />
</entity><br />
<entity id="SnowMan0" typeid="Sprite"><br />
<param name="name" value="SnowMan"/><br />
<position x="19" y="0.2"/><br />
<param name="z" value="-1"/><br />
</entity><br />
<zone id="Zone0"><br />
<box left="40" right="50" top="5" bottom="0"/><br />
</zone><br />
</level><br />
<br />
This level can be made easily with the xmoto level editor. It includes a block called Block0 which is a square, a strawberry called Strawberry0 and a zone called Zone0. A zone is an invisible part of the level that can execute actions when the player is inside.<br />
<br />
Some functions require a minimum X-Moto version to work. If you use one of these functions, please put this information in the level. For example, to make your level require X-Moto version 0.2.0, add this line to your level:<br />
<br />
<level id="tutscript" rversion="0.2.0"><br />
<br />
[[Image:Scripted_level.jpg]]<br />
<br />
All the code of the script is written in Lua. You can find the syntax here. However, if you choose to include the script in an xml file, < and > symbol must be replaced by &amp;lt; and &amp;gt;. The code of the script can be included between <script> and </script> in the level file.<br />
<br />
= Timers =<br />
== StartTimer(Name,Delay=100,Loops=0) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
This function is used to create a timer, or start a stopped timer. Basically, if you don't give all parameters the timer uses default values, or if the timer already exists then it is resetted, or started if it is stopped with Game.StopTimer().<br />
<br />
'''Cases''': <br />
* if timer doesn't exist then creates<br />
* if timer exist and is stopped then restarts (unless you give attributes delay or loops then it is reseted)<br />
* if timer exist and is running then resets <br />
=== Script Example ===<br />
--------------------------<br />
--Delayed Message System--<br />
-----by tuhoojabotti------<br />
--------------------------<br />
--stuff for the msgs<br />
msgs={}<br />
msgt={}<br />
msga=0<br />
<br />
--other<br />
Zone0={}<br />
<br />
function OnLoad()<br />
StartMessages({"Hello and welcome!","This level uses timers to show these messages.","Press 'B' to pause and continue messages.","Go right and if you hit the Zone, the messages will end!","I have nothing else to say, good night!"},150)<br />
Game.SetKeyHook("B","stop")<br />
return true<br />
end<br />
<br />
function stop()<br />
ToggleMessages()<br />
end<br />
<br />
function Zone0.OnEnter()<br />
ClearMessages()<br />
end<br />
<br />
--functions for the message system<br />
function StartMessages(_msgs,_delay)<br />
msga=1; msgs=_msgs; Game.StartTimer("msgt",_delay,table.getn(msgs))<br />
end<br />
function ToggleMessages()<br />
if not(table.getn(msgs)==0) then --only if there are messages<br />
if msga==1 then --msgs are rolling<br />
msga=0; Game.StopTimer("msgt")<br />
else --no msgs rolling<br />
msga=1; Game.StartTimer("msgt")<br />
end<br />
end<br />
end<br />
function msgt.Tick(n)<br />
if table.getn(msgs)>=n then --there are messages<br />
Game.Message(msgs[n])<br />
if table.getn(msgs)==n then msga=0 end --shutdown on last msg<br />
end<br />
end<br />
function ClearMessages()<br />
if msga==1 then Game.StopTimer("msgt") end<br />
msgs={}; msga=0; msgd=0<br />
end<br />
<br />
== SetTimerDelay(Name,Delay) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
Sets the timer's delay, without resetting the amount of loops etc. (Allows you to speed it up or slow it down. ;-))<br />
=== Script Example ===<br />
timer={} --declare the timer<br />
entity1={}<br />
function OnLoad()<br />
Game.Message("You are going to die in 10 seconds!! buahahhahahaaa!")<br />
Game.StartTimer("timer",1000,1)<br />
return true<br />
end<br />
function timer.Tick()<br />
Game.KillPlayer()<br />
end<br />
function entity1.Touch()<br />
Game.Message("haha! you drank some poison, now you die faster!")<br />
Game.SetTimerDelay("timer",300)<br />
end<br />
== StopTimer(Name) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
Stops the timer, the Name.Tick won't be called anymore. Use Game.StartTimer(Name) to restart it.<br />
=== Script Example ===<br />
timer={} --declare the timer<br />
entity1={}<br />
function OnLoad()<br />
Game.Message("You are going to die in 10 seconds!! buahahhahahaaa!")<br />
Game.StartTimer("timer",1000,1)<br />
return true<br />
end<br />
function timer.Tick()<br />
Game.KillPlayer()<br />
end<br />
function entity1.Touch()<br />
Game.Message("No! you found antidote!")<br />
Game.StopTimer("timer")<br />
end<br />
<br />
= Functions called by XMoto =<br />
<br />
== OnLoad() ==<br />
=== Explanation ===<br />
This function is called one time when the level starts. You must return true if nothing bad happened.<br />
<br />
=== Script example ===<br />
The example displays a message at the start of the level.<br />
<br />
function OnLoad()<br />
Game.Message("This level is scripted")<br />
return true<br />
end<br />
<br />
== Tick() ==<br />
=== Explanation ===<br />
Function called 1 time every hundredth.<br />
You must return true if nothing bad happened.<br />
Be aware that if this function use is abusive, levels will not be validated :<br />
action function like setBlockPos, setPlayerPos, ...<br />
(contrary to request function getBlockPos, getTime, and lua code)<br />
require that the information is store into the replay. If you put a setBlockPos<br />
call into the Tick function, it will make big replays : around 20 bytes * 100 * 60 / minute<br />
=> several hundreads of KB / minute<br />
To limit this if you really want to call such functions into your level :<br />
- first, play your level and check that replay size is under 100 ko<br />
- reduce the number of time you call setBlockPos by adding a variable to make<br />
this function called not in all Tick() but 1/3 for example<br />
- add a zone so that the animation (tick) is called only when you're<br />
in this zone<br />
- use dynamicBlock or dynamicEntity functions<br />
<br />
=== Script example ===<br />
This example will initialize gravity to 0 ; then, it will increment it with the time. Because earth gravity is 9.81, the earth gravity will not be reached before the 9.81 seconds. Be aware that in xmoto, vertical gravity must be multiplied by -1 because of screen coords which are reversed.<br />
<br />
function Tick()<br />
if Game.GetTime() < 9.81<br />
then<br />
Game.SetGravity(0, Game.GetTime() * -1)<br />
end<br />
return true<br />
end<br />
<br />
function Load()<br />
Game.SetGravity(0, 0)<br />
return true<br />
end<br />
<br />
== Entity.Touch() ==<br />
=== Explanation ===<br />
This function is called when an entity (a strawberry for example) is touched. The entity must be declared in the script. Note that the <size r> parameter allows to choose the distance of the entity which must be considered so that it is touched.<br />
<br />
=== Script example ===<br />
The example displays a message when the strawberry is touched.<br />
<br />
Strawberry0 = {}<br />
<br />
function Strawberry0.Touch()<br />
Game.Message("Nice strawberry !")<br />
end<br />
<br />
== Entity.TouchBy(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when an entity (a strawberry for example) is touched. The entity must be declared in the script. Note that the <size r> parameter allows to choose the distance of the entity which must be considered so that it is touched.<br />
<br />
=== Script example ===<br />
The example displays a message when the strawberry is touched.<br />
<br />
Strawberry0 = {}<br />
<br />
function Strawberry0.TouchBy(player)<br />
Game.Message("Player "..player.." takes the strawberry")<br />
end<br />
<br />
== Zone.OnEnter() ==<br />
=== Explanation ===<br />
This function is called when a player enters in a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player enters into the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.Message("Entering in the zone")<br />
end<br />
<br />
== Zone.OnEnterBy(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when a player enters in a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player enters into the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnterBy(player)<br />
Game.Message("Player "..player.." enters the zone")<br />
end<br />
<br />
== Zone.OnLeave() ==<br />
=== Explanation ===<br />
This function is called when a player leaves a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player leaves the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnLeave()<br />
Game.Message("Leaving the zone")<br />
end<br />
<br />
== Zone.OnLeaveBy() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when a player leaves a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player leaves the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnLeaveBy(player)<br />
Game.Message("Player "..player.." leaves the zone")<br />
end<br />
<br />
== OnSomersault(bClockWise) ==<br />
[require Xmoto >= 0.2.1]<br />
<br />
=== Explanation ===<br />
This function is called each time a player make a new somersault. bClockWise is 1 is the somersault is clockwise, 0 if counterclockwise.<br />
<br />
=== Script example ===<br />
The example displays a message when a player makes a somersault.<br />
<br />
function OnSomersault(bClockWise)<br />
if(bClockWise == 1) <br />
then<br />
Game.Message("ClockWise Somersault")<br />
else<br />
Game.Message("CounterClockWise Somersault")<br />
end<br />
end<br />
<br />
== OnSomersaultBy(bClockWise, player) ==<br />
[require Xmoto >= 0.3.0]<br />
<br />
=== Explanation ===<br />
This function is called each time a player make a new somersault. bClockWise is 1 is the somersault is clockwise, 0 if counterclockwise.<br />
<br />
=== Script example ===<br />
The example displays a message when a player makes a somersault.<br />
<br />
function OnSomersaultBy(bClockWise, player)<br />
Game.Message("Nice, player "..player" !)<br />
end<br />
<br />
== OnWheel1Touchs(status), OnWheel2Touchs(status) ==<br />
[require Xmoto >= 0.2.1]<br />
<br />
=== Explanation ===<br />
This function is called each time just the wheel 1 touchs the ground or stops to touch the ground. (status is 1 is the ground was not touching and is now touching, and 0 else)<br />
<br />
=== Script example ===<br />
The example displays the new max duration of a jump each time a new one is done.<br />
<br />
max_jump_time = 1.0 -- start at 1 to not count smaller jumps<br />
jump_begin = 0.0<br />
touch_1 = false<br />
touch_2 = false<br />
<br />
function OnWheel1Touchs(bStatus)<br />
if(bStatus == 1) <br />
then<br />
updateMax()<br />
touch_1 = true<br />
else<br />
touch_1 = false<br />
jump_begin = Game.GetTime()<br />
end<br />
end<br />
<br />
function OnWheel2Touchs(bStatus)<br />
if(bStatus == 1) <br />
then<br />
updateMax()<br />
touch_2 = true<br />
else<br />
touch_2 = false<br />
jump_begin = Game.GetTime()<br />
end<br />
end<br />
<br />
function updateMax()<br />
if(touch_1 == false and touch_2 == false)<br />
then<br />
if(Game.GetTime() - jump_begin > max_jump_time)<br />
then<br />
max_jump_time = Game.GetTime() - jump_begin<br />
Game.Message("New high jump: "..max_jump_time)<br />
end<br />
end<br />
end<br />
<br />
== OnWheel1TouchsBy(status, player), OnWheel2TouchsBy(status, player) ==<br />
[require Xmoto >= 0.3.0]<br />
<br />
=== Explanation ===<br />
This function is called each time just the wheel 1 touchs the ground or stops to touch the ground. (status is 1 is the ground was not touching and is now touching, and 0 else)<br />
<br />
=== Script example ===<br />
function OnWheel1TouchsBy(status, player)<br />
if(status == 1) <br />
then<br />
Game.Message("Player "..player.." touches with wheel 1")<br />
end<br />
end<br />
<br />
function OnWheel2TouchsBy(status, player)<br />
if(status == 1) <br />
then<br />
Game.Message("Player "..player.." touches with wheel 2")<br />
end<br />
end<br />
<br />
= Callable X-Moto functions =<br />
<br />
== GetTime() ==<br />
=== Explanation ===<br />
Return the time since the start of the level.<br />
<br />
=== Script example ===<br />
The example displays a message if the player takes more than 10 seconds to enter the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
if Game.GetTime() > 10.0<br />
then<br />
Game.Message("10 seconds to come there, that's a lot !")<br />
end<br />
end<br />
<br />
== Message(msgs) ==<br />
=== Explanation ===<br />
Display a message on the screen. The message is automatically remove after 5 seconds. You can call this function several times : the messages will be all displayed.<br />
<br />
=== Script example ===<br />
The example displays some messages at the start of the level.<br />
<br />
function OnLoad()<br />
Game.Message("This level is scripted")<br />
Game.Message("GO GO GO !!!")<br />
return true<br />
end<br />
<br />
== ClearMessages() ==<br />
=== Explanation ===<br />
Remove messages on the screen.<br />
<br />
=== Script example ===<br />
The example shows how to clear old messages and display a new one in some circumstances.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.ClearMessages()<br />
Game.Message("OnEnter")<br />
end<br />
<br />
function Zone0.OnLeave()<br />
Game.ClearMessages()<br />
Game.Message("OnLeave")<br />
end<br />
<br />
== SetGravity(x, y) ==<br />
=== Explanation ===<br />
Change the gravity (horizontal and vertical) in the game.<br />
<br />
=== Script example ===<br />
The example shows how to reverse gravity. Be aware that in X-Moto, vertical gravity must be multiplied by -1 because screen coordinates are reversed in the y direction.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0, 9.81)<br />
return true<br />
end<br />
<br />
== GetGravity() ==<br />
=== Explanation ===<br />
Return the pair(horizontal gravity, vertical gravity).<br />
<br />
=== Script example ===<br />
The example displays the wind and gravity at the start of the level.<br />
<br />
function OnLoad()<br />
x, y = Game.GetGravity()<br />
Game.Message("Wind : "..x)<br />
Game.Message("Gravity : "..(y*-1))<br />
return true<br />
end<br />
<br />
== IsPlayerInZone(zone) ==<br />
=== Explanation ===<br />
Return true if a player is in the specified zone.<br />
<br />
=== Script example ===<br />
This example is a bit more complicated. When the player enters the zone, gravity slowly decreases. Once the player leaves the zone, the gravity suddenly becomes 9.81.<br />
<br />
Zone0 = {}<br />
x = -9.81<br />
<br />
function Tick()<br />
if Game.IsPlayerInZone("Zone0")<br />
then<br />
Game.SetGravity(0, x)<br />
x = x + 0.1<br />
end<br />
<br />
return true<br />
end<br />
<br />
function Zone0.OnLeave()<br />
x = -9.81<br />
Game.SetGravity(0, x)<br />
end<br />
<br />
== IsAPlayerInZone(zone, player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return true if the player is in the specified zone.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
if Game.IsAPlayerInZone("Zone0", 0) == false<br />
then<br />
Game.Message("This player 0 is not in the zone")<br />
end<br />
return true<br />
end<br />
<br />
== SetPlayerPosition(x, y, bRight) ==<br />
=== Explanation ===<br />
Set the position and direction of the players in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example teleports the playerq each time one enters the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
== SetAPlayerPosition(x, y, bRight, player) ==<br />
=== Explanation ===<br />
Set the position and direction of the player in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example show how to teleport the player 0 at start of the level to the position (20, 5)<br />
<br />
function OnLoad()<br />
Game.SetAPlayerPosition(20, 5, 1, 0)<br />
return true<br />
end<br />
<br />
== GetPlayerPosition() ==<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of the player 0 in the game.<br />
<br />
=== Script example ===<br />
This example make the player unable to get the strawberry ;-)<br />
<br />
function Tick()<br />
x, y, bright = Game.GetPlayerPosition()<br />
if x > 18<br />
then<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== GetPlayerVelocity(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the velocity of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetPlayerSpeed(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the speed of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetPlayerAngle(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the angle of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetAPlayerPosition(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of a player in the game.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
x, y, bright = Game.GetAPlayerPosition(0)<br />
Game.Message("Player0 position is ("..x..","..y..")")<br />
return true<br />
end<br />
<br />
== SetEntityPos(entity, x, y) ==<br />
=== Explanation ===<br />
Set the position of the entity to coordinates (x, y) in the game.<br />
<br />
=== Script example ===<br />
The example changes the position of the strawberry every second.<br />
<br />
function Tick()<br />
i,f = math.mod(math.ceil(Game.GetTime()), 2)<br />
<br />
if i == 1<br />
then<br />
Game.SetEntityPos("Strawberry0", 10, 0.5)<br />
else<br />
Game.SetEntityPos("Strawberry0", 30, 0.5)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== GetEntityPos(entity) ==<br />
=== Explanation ===<br />
Return the position of the entity entity in the game.<br />
<br />
=== Script example ===<br />
This example shows another way to move a strawberry.<br />
<br />
last_update = 0<br />
<br />
function Tick()<br />
sec = math.ceil(Game.GetTime())<br />
<br />
if last_update < sec<br />
then<br />
x, y = Game.GetEntityPos("Strawberry0")<br />
<br />
if(x == 20)<br />
then<br />
x_new = 25<br />
else<br />
x_new = 20<br />
end<br />
<br />
if(y == 0.5)<br />
then<br />
y_new = 2<br />
else<br />
y_new = 0.5<br />
end<br />
<br />
Game.SetEntityPos("Strawberry0", x_new, y_new)<br />
last_update = sec<br />
end<br />
<br />
return true<br />
end<br />
<br />
== SetKeyHook(key, function) ==<br />
=== Explanation ===<br />
Whenever the player hits the "key" specified, a function will be called.<br />
<br />
=== Script example ===<br />
The example shows how to change gravity just by pressing a key.<br />
<br />
g = -9.81<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("G", "GravityChange")<br />
return true<br />
end<br />
<br />
function GravityChange()<br />
g = g * -1<br />
Game.SetGravity(0, g)<br />
end<br />
<br />
== GetKeyByAction(function) ==<br />
=== Explanation ===<br />
Return the key associated to an action. Possible actions are Drive, Brake, PullBack, PushForward, ChangeDirection.<br />
<br />
=== Script example ===<br />
The example displays how to drive at level start.<br />
<br />
function OnLoad()<br />
Game.Message("To drive, press "..Game.GetKeyByAction("Drive"))<br />
return true<br />
end<br />
<br />
== GetKeyByActionTech(function) ==<br />
[require Xmoto >= 0.5.4] <br />
=== Explanation ===<br />
Return the key associated to an action. Possible actions are Drive, Brake, PullBack, PushForward, ChangeDirection.<br />
Note that GetKeyByAction returns a human readable string while GetKeyByActionTech returns a value which is usable by SetKeyHook and that can be a joystick, mouse or keyboard key.<br />
<br />
=== Script example ===<br />
The example show how to use the Drive key to do other things than driving.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook(Game.GetKeyByActionTech("Drive"), "BalloonA")<br />
return true<br />
end<br />
<br />
== Log(msgs) ==<br />
=== Explanation ===<br />
Log a message in the xmoto.log.<br />
<br />
=== Script example ===<br />
The example log the message "An error occured" when the level starts.<br />
<br />
function OnLoad()<br />
Game.Log("An error occured")<br />
return true<br />
end<br />
<br />
== MoveBlock(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function allows X-Moto to move a block in the level. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />). Be aware that moving a block can be dangerous: make sure that the player will not be inside the block once you have moved it.<br />
<br />
=== Script example ===<br />
In the example, when the player presses the key M, the block moves to the right.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "MoveTheBlock")<br />
return true<br />
end<br />
<br />
function MoveTheBlock()<br />
Game.MoveBlock("Block0", 1, 0)<br />
end<br />
<br />
== SetBlockCenter(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function gives the center of the block relative to the block position (then, to the level if block position is (0, 0)). The center is used by the function SetBlockPos(), GetBlockPos() and SetBlockRotation(). This function should generally used in the Load() function because the center should not logically be changed (however, you can change it).<br />
<br />
=== Script example ===<br />
In the example, the center of the block is set to the center of the square. Then, when the player press M, the block is placed just under the player.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
<br />
== SetBlockPos(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function allows X-Moto to change the position of a block according to its center. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />). Be aware that moving a block can be dangerous: make sure that the player will not be inside the block once you have moved it.<br />
<br />
=== Script example ===<br />
In the example, the center of the block is set to the center of the square. Then, when the player press M, the block is placed just under the player.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
<br />
== GetBlockPos(block) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function gives the position of a given block. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
The example shows how to use this function as a condition. Here, you can move the block under the bike only if you play on the right.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
bx, by = Game.GetBlockPos("Block0")<br />
if(x > bx)<br />
then<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
end<br />
<br />
== SetBlockRotation(block, angle) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function rotates a block. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
In the example, if the player keeps the key M pressed, the block will rotate.<br />
<br />
a = 0<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
a = a + math.pi / 256.0<br />
Game.SetBlockRotation("Block0", a)<br />
end<br />
<br />
== SetDynamicEntityRotation(entity, initAngle, radius, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function tells an entity to make circles for a given duration. The current position of the entity on the circle of radius radius is at position initAngle (in rad). The entity will make a circle in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negative arguments allow you to change the behavior of the animation. For example, a negative period will rotate the entity in the negative direction.<br />
<br />
=== Script example ===<br />
The example shows how to easily move the strawberry. InitAngle is set to -PI/2 because the strawberry is placed at the bottom where we want it moves.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityRotation("Strawberry0", -math.pi/2, 2, 500, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicEntitySelfRotation(entity, period, startTime, endTime) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function allows to tell an entity to rotate for a given duration. The entity will rotate in period hundreads. The animation will start in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense.<br />
<br />
=== Script example ===<br />
The example shows how to rotate easily a entity.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntitySelfRotation("Entity2", 1000, 0, 0);<br />
return true;<br />
end;<br />
<br />
== SetDynamicEntityTranslation(entity, fX, fY, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function allows to tell an entity to make translation for a given duration. The translation's length is fX on the X axis and fY on the Y axis. The entity will make the translation in period/2 hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation.<br />
<br />
=== Script example ===<br />
The example shows an example of composed animations.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityTranslation("Strawberry0", 10, 0, 500, 0, 0)<br />
Game.SetDynamicEntityTranslation("Strawberry0", 0, 1, 100, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicEntityNone(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function removed all the animations applicated on an entity.<br />
<br />
=== Script example ===<br />
The example first shows how to ask an entity to make a translation in a first time and then, to make rotations. If the user press the key S, the strawberry stops to move.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityTranslation("Strawberry0", -2, 0, 1000, 0, 500)<br />
Game.SetDynamicEntityRotation("Strawberry0", -math.pi/2, 2, 500, 500, 0)<br />
Game.SetKeyHook("S", "StopAnimation")<br />
return true<br />
end<br />
<br />
function StopAnimation()<br />
Game.SetDynamicEntityNone("Strawberry0")<br />
end<br />
<br />
== SetDynamicBlockRotation(block, initAngle, radius, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function allows to tell a block to make circles for a given duration. The current position of the block on the circle of radius radius is at position initAngle (in rad). The block will make a circle in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make move blocks to fast otherwise the bike could go throw the block.<br />
<br />
=== Script example ===<br />
The example shows how to make move easily a block.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockRotation("Block0", -math.pi/2, 2, 500, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicBlockSelfRotation(block, period, startTime, endTime) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function allows to tell a block to rotate for a given duration. The block will rotate in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make move blocks to fast otherwise the bike could go throw the block.<br />
<br />
=== Script example ===<br />
The example shows how to rotate easily a block.<br />
<br />
function OnLoad()<br />
Game.SetBlockCenter("Block2", -2.5, -19.0);<br />
Game.SetDynamicBlockSelfRotation("Block2", 1000, 0, 0);<br />
return true;<br />
end;<br />
<br />
== SetDynamicBlockTranslation(block, fX, fY, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
<p>This function tells a block to make a translation for a given duration. A translation is a looped movement from one point to another, and back. The translation's length is fX on the X axis and fY on the Y axis. The animation will start in startTime hundredths and will finish in endTime hundredths, so the duration is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make blocks move too fast otherwise the bike could go through the block.</p><br />
<br />
<p>block: Defines which Block should move<br><br />
fX: Defines where on the X-Axis the Block should move<br><br />
fY: Defines where on the Y-Axis the Block should move<br><br />
period: Defines how long it takes the Block to move back to the starting point<br><br />
startTime: Defines when the translation should start<br><br />
endTime: Defines when the translation should end</p><br />
<br />
In order to make replay files as small as possible, you should use Translation instead of the MoveBlock function. An example on how to convert a MoveBlock function into a Translation is given below.<br />
<br />
=== Script example ===<br />
In this example, the block makes an infinite movement: It moves from its originating point (0,0) to (10,1) within 750ms, and then back in another 750ms.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 10, 1, 1500, 0, 0)<br />
return true<br />
end<br />
<br />
Example on how to convert a MoveBlock function into a Translation (see above):<br />
<br />
function Tick()<br />
Game.MoveBlock("Block0", 0.5,0)<br />
return true<br />
end<br />
<br />
Block0 moves forever to the right: 0.5px every 1/100s<br />
So it moves at a speed of 300m/60s<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 300, 0, 12000, 0, 6000)<br />
return true<br />
end<br />
<br />
This is the MoveBlock function in the translation-version. <br />
It moves 300m to the right and 300m back to the left in 12000ms. endTime is set to 12000/2=6000, so that the translation stops as soon as Block0 reaches (300,0)<br />
<br />
== SetDynamicBlockNone(block) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function stops all the animation applied on the block. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
In the example, the block will move until the player presses the key S.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 10, 1, 1500, 0, 0)<br />
Game.SetKeyHook("S", "StopAnimation")<br />
return true<br />
end<br />
<br />
function StopAnimation()<br />
Game.SetDynamicBlockNone("Block0")<br />
end<br />
<br />
== CameraZoom(z) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
In some levels, you may want that the camera is a bit more far from the player. Use this function to change the camera zoom.<br />
<br />
=== Script example ===<br />
The example shows how a different zoom can be used to play a level.<br />
<br />
function OnLoad()<br />
Game.CameraZoom(-0.05)<br />
return true<br />
end<br />
<br />
== CameraMove(x, y) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
For some particular levels, you may want the camera to be moved. Use this function to do that.<br />
<br />
=== Script example ===<br />
The example shows how you can focus a level on the part above the player.<br />
<br />
function OnLoad()<br />
Game.CameraMove(0, 3)<br />
return true<br />
end<br />
<br />
== CameraRotate(angle) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera be rotated. Use this function to do that.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.CameraRotate(math.pi / 4.0);<br />
return true<br />
end<br />
<br />
== CameraAdaptToGravity() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera be rotated. Use this function to do that in function of the gravity.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0.0, 9.81)<br />
Game.CameraAdaptToGravity()<br />
return true<br />
end<br />
<br />
== SetCameraRotationSpeed(z) ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera beeing rotated does that at a certain speed. With this function you can make it rotate either very slow ( z = 0.1 ) or extremely fast ( z = 7.2 ). The values are given in RAD, so they can reach from 0 to 2 * PI.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0.0, 9.81)<br />
Game.SetCameraRotationSpeed(0.2)<br />
Game.CameraAdaptToGravity()<br />
return true<br />
end<br />
<br />
== GetEntityRadius(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
Return the radius of an entity. This radius is used for collision. You can use this function for your own collision or anything else.<br />
<br />
=== Script example ===<br />
The example shows you the radius of the strawberry.<br />
<br />
function OnLoad()<br />
Game.Message("Radius of the strawberry : "..Game.GetEntityRadius("Strawberry0"))<br />
return true<br />
end<br />
<br />
== IsEntityTouched(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
There is a function called when you touch an entity. But sometimes you want to know when you don't touch an entity. Use this function.<br />
<br />
=== Script example ===<br />
The example shows how to make an action when the player is not touching an entity.<br />
<br />
g = -9.81<br />
<br />
function OnLoad()<br />
Game.Message("Gravity is increasing while you are not touching the snowman")<br />
return true<br />
end<br />
<br />
function Tick()<br />
if(Game.IsEntityTouched("SnowMan0") == 0)<br />
then<br />
g = g - 0.03<br />
Game.SetGravity(0, g);<br />
end<br />
return true<br />
end<br />
<br />
==Game.AddPenaltyTime(time) ==<br />
[require Xmoto >= 0.5.0]<br />
=== Explanation ===<br />
Increment the value of the time counter to make a penalty.<br />
<br />
=== Script example ===<br />
In the following example, the time will be increased of 5 seconds if the player enters in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.AddPenaltyTime(5.0)<br />
end<br />
<br />
== KillPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the players die. It's interesting if you want the players be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
In the following example, the player will die when he will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillPlayer()<br />
end<br />
<br />
== KillAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player dies. It's interesting if you want the player be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.KillAPlayer(0)<br />
return true<br />
end<br />
<br />
== KillEntity(entityID) ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the entity entityID will be deleted. The entity can be a strawberry or any sprite.<br />
<br />
=== Script example ===<br />
In the following example, the strawberry will be deleted when the player will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillEntity("Strawberry0")<br />
end<br />
<br />
== WinPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, all players win the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
In the following example, the player win on entering in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.WinPlayer()<br />
end<br />
<br />
== WinAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player wins the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.WinAPlayer(0)<br />
return true<br />
end<br />
<br />
== RemainingStrawberries() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
This function returns the number of strawberries remaining in the level.<br />
<br />
=== Script example ===<br />
In the following example, when the player will enter in the zone Zone0, the number of remaining strawberries is displayed.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.Message(Game.RemainingStrawberries())<br />
end<br />
<br />
== NumberOfPlayers() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function returns the number of players (dead or in live) in the level<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.Message(Game.NumberOfPlayers().." players")<br />
return true<br />
end<br />
<br />
== AddForceToPlayer(forceX, forceY, startTime, endTime, player) ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
This function apply an external force on the player player. The force will apply from startTime to endTime or will be infinite if endTime is 0. startTime and endTime are expressed in hundreaths and are relativ to the call function time. The force applied will be of (forceX, forceY). Application point is the center of the biker. In the example, a force will be applied to all players from time 5 to 10 seconds. Force is expressed in newton, mg/s-2 (meter * gramm / (seconds * seconds)).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
for i=0,Game.NumberOfPlayers()-1 do<br />
Game.Message("Kicking player "..(i+1))<br />
Game.AddForceToPlayer(0, 1000, 500, 1000, i)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== PlayAudio("NameOfSound") ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
Using this function you can play a sound effect (or a music). The parameter is the name of the sound, which is defined in the actually used theme file.<br />
In the following example, there must be a zone named "Zone0", As soon as you enter the zone, the sound effect is played:<br />
<br />
=== Script example ===<br />
Zone0 = {}<br />
function Zone0.OnEnter()<br />
Game.PlaySound("ring");<br />
end<br />
<br />
<br />
<br />
== SetPhysicsBlockSelfRotation (block, torque, startTime, endTime) ==<br />
[require Xmoto >= 0.5.0]<br />
=== Explanation ===<br />
This function allows to tell a block to rotate for a given duration. The rotation will be performed by applying forces (torque) on the block (if possible). The block will rotate in period hundreads. The forces application will start in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite application. Note that negativ arguments allow to change the behavior of the forces, for example, a negativ torque will tell to turn in the other sense. <br />
<br />
=== Script example ===</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Scripted_levels&diff=5454Scripted levels2010-11-20T19:48:19Z<p>Nadenislamarre: /* GetKeyByAction(function) */</p>
<hr />
<div>[[Ca:Scripted levels|Català]] - [[Es:Scripted levels|Español]]<br />
<br />
= Introduction =<br />
Scripting allows a level to become dynamic. You can change physic settings, move objects, modify game logic, etc. A script is written in the Lua language and can be included in a level file.<br />
<br />
Documentation about Lua can be found here :<br />
http://www.lua.org/manual/5.1/<br />
<br />
To write a script, you must know a little about a level file. It is an xml file. It includes somes properties like the name of the level, description, author, date, etc. Moreover, it includes block and sprite definitions. A block is composed of vertices which link together to draw polygons.<br />
<br />
Since 0.3.0, xmoto supports multiplayers ; in the script, a player is defined by an index. The first player has the number 0, the second the number 1, ...<br />
<br />
The script examples on this page will use this basic level file:<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<level id="tutscript"><br />
<info><br />
<name>tutscript</name><br />
<description></description><br />
<author></author><br />
<date></date><br />
<sky>sky1</sky><br />
</info><br />
<script><br />
</script><br />
<limits left="0" right="50" top="30" bottom="0"/><br />
<block id="Block0"><br />
<position x="0" y="0"/><br />
<usetexture id="default"/><br />
<vertex x="5" y="5"/><br />
<vertex x="5" y="10"/><br />
<vertex x="10" y="10"/><br />
<vertex x="10" y="5"/><br />
</block><br />
<entity id="MyPlayerStart0" typeid="PlayerStart"><br />
<size r="0.4"/><br />
<position x="7.5" y="10"/><br />
</entity><br />
<entity id="Strawberry0" typeid="Strawberry"><br />
<size r="0.4"/><br />
<position x="20" y="0.5"/><br />
</entity><br />
<entity id="SnowMan0" typeid="Sprite"><br />
<param name="name" value="SnowMan"/><br />
<position x="19" y="0.2"/><br />
<param name="z" value="-1"/><br />
</entity><br />
<zone id="Zone0"><br />
<box left="40" right="50" top="5" bottom="0"/><br />
</zone><br />
</level><br />
<br />
This level can be made easily with the xmoto level editor. It includes a block called Block0 which is a square, a strawberry called Strawberry0 and a zone called Zone0. A zone is an invisible part of the level that can execute actions when the player is inside.<br />
<br />
Some functions require a minimum X-Moto version to work. If you use one of these functions, please put this information in the level. For example, to make your level require X-Moto version 0.2.0, add this line to your level:<br />
<br />
<level id="tutscript" rversion="0.2.0"><br />
<br />
[[Image:Scripted_level.jpg]]<br />
<br />
All the code of the script is written in Lua. You can find the syntax here. However, if you choose to include the script in an xml file, < and > symbol must be replaced by &amp;lt; and &amp;gt;. The code of the script can be included between <script> and </script> in the level file.<br />
<br />
= Timers =<br />
== StartTimer(Name,Delay=100,Loops=0) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
This function is used to create a timer, or start a stopped timer. Basically, if you don't give all parameters the timer uses default values, or if the timer already exists then it is resetted, or started if it is stopped with Game.StopTimer().<br />
<br />
'''Cases''': <br />
* if timer doesn't exist then creates<br />
* if timer exist and is stopped then restarts (unless you give attributes delay or loops then it is reseted)<br />
* if timer exist and is running then resets <br />
=== Script Example ===<br />
--------------------------<br />
--Delayed Message System--<br />
-----by tuhoojabotti------<br />
--------------------------<br />
--stuff for the msgs<br />
msgs={}<br />
msgt={}<br />
msga=0<br />
<br />
--other<br />
Zone0={}<br />
<br />
function OnLoad()<br />
StartMessages({"Hello and welcome!","This level uses timers to show these messages.","Press 'B' to pause and continue messages.","Go right and if you hit the Zone, the messages will end!","I have nothing else to say, good night!"},150)<br />
Game.SetKeyHook("B","stop")<br />
return true<br />
end<br />
<br />
function stop()<br />
ToggleMessages()<br />
end<br />
<br />
function Zone0.OnEnter()<br />
ClearMessages()<br />
end<br />
<br />
--functions for the message system<br />
function StartMessages(_msgs,_delay)<br />
msga=1; msgs=_msgs; Game.StartTimer("msgt",_delay,table.getn(msgs))<br />
end<br />
function ToggleMessages()<br />
if not(table.getn(msgs)==0) then --only if there are messages<br />
if msga==1 then --msgs are rolling<br />
msga=0; Game.StopTimer("msgt")<br />
else --no msgs rolling<br />
msga=1; Game.StartTimer("msgt")<br />
end<br />
end<br />
end<br />
function msgt.Tick(n)<br />
if table.getn(msgs)>=n then --there are messages<br />
Game.Message(msgs[n])<br />
if table.getn(msgs)==n then msga=0 end --shutdown on last msg<br />
end<br />
end<br />
function ClearMessages()<br />
if msga==1 then Game.StopTimer("msgt") end<br />
msgs={}; msga=0; msgd=0<br />
end<br />
<br />
== SetTimerDelay(Name,Delay) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
Sets the timer's delay, without resetting the amount of loops etc. (Allows you to speed it up or slow it down. ;-))<br />
=== Script Example ===<br />
timer={} --declare the timer<br />
entity1={}<br />
function OnLoad()<br />
Game.Message("You are going to die in 10 seconds!! buahahhahahaaa!")<br />
Game.StartTimer("timer",1000,1)<br />
return true<br />
end<br />
function timer.Tick()<br />
Game.KillPlayer()<br />
end<br />
function entity1.Touch()<br />
Game.Message("haha! you drank some poison, now you die faster!")<br />
Game.SetTimerDelay("timer",300)<br />
end<br />
== StopTimer(Name) ==<br />
[require Xmoto >= 0.5.2] <br />
=== Explanation ===<br />
Stops the timer, the Name.Tick won't be called anymore. Use Game.StartTimer(Name) to restart it.<br />
=== Script Example ===<br />
timer={} --declare the timer<br />
entity1={}<br />
function OnLoad()<br />
Game.Message("You are going to die in 10 seconds!! buahahhahahaaa!")<br />
Game.StartTimer("timer",1000,1)<br />
return true<br />
end<br />
function timer.Tick()<br />
Game.KillPlayer()<br />
end<br />
function entity1.Touch()<br />
Game.Message("No! you found antidote!")<br />
Game.StopTimer("timer")<br />
end<br />
<br />
= Functions called by XMoto =<br />
<br />
== OnLoad() ==<br />
=== Explanation ===<br />
This function is called one time when the level starts. You must return true if nothing bad happened.<br />
<br />
=== Script example ===<br />
The example displays a message at the start of the level.<br />
<br />
function OnLoad()<br />
Game.Message("This level is scripted")<br />
return true<br />
end<br />
<br />
== Tick() ==<br />
=== Explanation ===<br />
Function called 1 time every hundredth.<br />
You must return true if nothing bad happened.<br />
Be aware that if this function use is abusive, levels will not be validated :<br />
action function like setBlockPos, setPlayerPos, ...<br />
(contrary to request function getBlockPos, getTime, and lua code)<br />
require that the information is store into the replay. If you put a setBlockPos<br />
call into the Tick function, it will make big replays : around 20 bytes * 100 * 60 / minute<br />
=> several hundreads of KB / minute<br />
To limit this if you really want to call such functions into your level :<br />
- first, play your level and check that replay size is under 100 ko<br />
- reduce the number of time you call setBlockPos by adding a variable to make<br />
this function called not in all Tick() but 1/3 for example<br />
- add a zone so that the animation (tick) is called only when you're<br />
in this zone<br />
- use dynamicBlock or dynamicEntity functions<br />
<br />
=== Script example ===<br />
This example will initialize gravity to 0 ; then, it will increment it with the time. Because earth gravity is 9.81, the earth gravity will not be reached before the 9.81 seconds. Be aware that in xmoto, vertical gravity must be multiplied by -1 because of screen coords which are reversed.<br />
<br />
function Tick()<br />
if Game.GetTime() < 9.81<br />
then<br />
Game.SetGravity(0, Game.GetTime() * -1)<br />
end<br />
return true<br />
end<br />
<br />
function Load()<br />
Game.SetGravity(0, 0)<br />
return true<br />
end<br />
<br />
== Entity.Touch() ==<br />
=== Explanation ===<br />
This function is called when an entity (a strawberry for example) is touched. The entity must be declared in the script. Note that the <size r> parameter allows to choose the distance of the entity which must be considered so that it is touched.<br />
<br />
=== Script example ===<br />
The example displays a message when the strawberry is touched.<br />
<br />
Strawberry0 = {}<br />
<br />
function Strawberry0.Touch()<br />
Game.Message("Nice strawberry !")<br />
end<br />
<br />
== Entity.TouchBy(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when an entity (a strawberry for example) is touched. The entity must be declared in the script. Note that the <size r> parameter allows to choose the distance of the entity which must be considered so that it is touched.<br />
<br />
=== Script example ===<br />
The example displays a message when the strawberry is touched.<br />
<br />
Strawberry0 = {}<br />
<br />
function Strawberry0.TouchBy(player)<br />
Game.Message("Player "..player.." takes the strawberry")<br />
end<br />
<br />
== Zone.OnEnter() ==<br />
=== Explanation ===<br />
This function is called when a player enters in a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player enters into the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.Message("Entering in the zone")<br />
end<br />
<br />
== Zone.OnEnterBy(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when a player enters in a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player enters into the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnterBy(player)<br />
Game.Message("Player "..player.." enters the zone")<br />
end<br />
<br />
== Zone.OnLeave() ==<br />
=== Explanation ===<br />
This function is called when a player leaves a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player leaves the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnLeave()<br />
Game.Message("Leaving the zone")<br />
end<br />
<br />
== Zone.OnLeaveBy() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when a player leaves a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player leaves the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnLeaveBy(player)<br />
Game.Message("Player "..player.." leaves the zone")<br />
end<br />
<br />
== OnSomersault(bClockWise) ==<br />
[require Xmoto >= 0.2.1]<br />
<br />
=== Explanation ===<br />
This function is called each time a player make a new somersault. bClockWise is 1 is the somersault is clockwise, 0 if counterclockwise.<br />
<br />
=== Script example ===<br />
The example displays a message when a player makes a somersault.<br />
<br />
function OnSomersault(bClockWise)<br />
if(bClockWise == 1) <br />
then<br />
Game.Message("ClockWise Somersault")<br />
else<br />
Game.Message("CounterClockWise Somersault")<br />
end<br />
end<br />
<br />
== OnSomersaultBy(bClockWise, player) ==<br />
[require Xmoto >= 0.3.0]<br />
<br />
=== Explanation ===<br />
This function is called each time a player make a new somersault. bClockWise is 1 is the somersault is clockwise, 0 if counterclockwise.<br />
<br />
=== Script example ===<br />
The example displays a message when a player makes a somersault.<br />
<br />
function OnSomersaultBy(bClockWise, player)<br />
Game.Message("Nice, player "..player" !)<br />
end<br />
<br />
== OnWheel1Touchs(status), OnWheel2Touchs(status) ==<br />
[require Xmoto >= 0.2.1]<br />
<br />
=== Explanation ===<br />
This function is called each time just the wheel 1 touchs the ground or stops to touch the ground. (status is 1 is the ground was not touching and is now touching, and 0 else)<br />
<br />
=== Script example ===<br />
The example displays the new max duration of a jump each time a new one is done.<br />
<br />
max_jump_time = 1.0 -- start at 1 to not count smaller jumps<br />
jump_begin = 0.0<br />
touch_1 = false<br />
touch_2 = false<br />
<br />
function OnWheel1Touchs(bStatus)<br />
if(bStatus == 1) <br />
then<br />
updateMax()<br />
touch_1 = true<br />
else<br />
touch_1 = false<br />
jump_begin = Game.GetTime()<br />
end<br />
end<br />
<br />
function OnWheel2Touchs(bStatus)<br />
if(bStatus == 1) <br />
then<br />
updateMax()<br />
touch_2 = true<br />
else<br />
touch_2 = false<br />
jump_begin = Game.GetTime()<br />
end<br />
end<br />
<br />
function updateMax()<br />
if(touch_1 == false and touch_2 == false)<br />
then<br />
if(Game.GetTime() - jump_begin > max_jump_time)<br />
then<br />
max_jump_time = Game.GetTime() - jump_begin<br />
Game.Message("New high jump: "..max_jump_time)<br />
end<br />
end<br />
end<br />
<br />
== OnWheel1TouchsBy(status, player), OnWheel2TouchsBy(status, player) ==<br />
[require Xmoto >= 0.3.0]<br />
<br />
=== Explanation ===<br />
This function is called each time just the wheel 1 touchs the ground or stops to touch the ground. (status is 1 is the ground was not touching and is now touching, and 0 else)<br />
<br />
=== Script example ===<br />
function OnWheel1TouchsBy(status, player)<br />
if(status == 1) <br />
then<br />
Game.Message("Player "..player.." touches with wheel 1")<br />
end<br />
end<br />
<br />
function OnWheel2TouchsBy(status, player)<br />
if(status == 1) <br />
then<br />
Game.Message("Player "..player.." touches with wheel 2")<br />
end<br />
end<br />
<br />
= Callable X-Moto functions =<br />
<br />
== GetTime() ==<br />
=== Explanation ===<br />
Return the time since the start of the level.<br />
<br />
=== Script example ===<br />
The example displays a message if the player takes more than 10 seconds to enter the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
if Game.GetTime() > 10.0<br />
then<br />
Game.Message("10 seconds to come there, that's a lot !")<br />
end<br />
end<br />
<br />
== Message(msgs) ==<br />
=== Explanation ===<br />
Display a message on the screen. The message is automatically remove after 5 seconds. You can call this function several times : the messages will be all displayed.<br />
<br />
=== Script example ===<br />
The example displays some messages at the start of the level.<br />
<br />
function OnLoad()<br />
Game.Message("This level is scripted")<br />
Game.Message("GO GO GO !!!")<br />
return true<br />
end<br />
<br />
== ClearMessages() ==<br />
=== Explanation ===<br />
Remove messages on the screen.<br />
<br />
=== Script example ===<br />
The example shows how to clear old messages and display a new one in some circumstances.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.ClearMessages()<br />
Game.Message("OnEnter")<br />
end<br />
<br />
function Zone0.OnLeave()<br />
Game.ClearMessages()<br />
Game.Message("OnLeave")<br />
end<br />
<br />
== SetGravity(x, y) ==<br />
=== Explanation ===<br />
Change the gravity (horizontal and vertical) in the game.<br />
<br />
=== Script example ===<br />
The example shows how to reverse gravity. Be aware that in X-Moto, vertical gravity must be multiplied by -1 because screen coordinates are reversed in the y direction.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0, 9.81)<br />
return true<br />
end<br />
<br />
== GetGravity() ==<br />
=== Explanation ===<br />
Return the pair(horizontal gravity, vertical gravity).<br />
<br />
=== Script example ===<br />
The example displays the wind and gravity at the start of the level.<br />
<br />
function OnLoad()<br />
x, y = Game.GetGravity()<br />
Game.Message("Wind : "..x)<br />
Game.Message("Gravity : "..(y*-1))<br />
return true<br />
end<br />
<br />
== IsPlayerInZone(zone) ==<br />
=== Explanation ===<br />
Return true if a player is in the specified zone.<br />
<br />
=== Script example ===<br />
This example is a bit more complicated. When the player enters the zone, gravity slowly decreases. Once the player leaves the zone, the gravity suddenly becomes 9.81.<br />
<br />
Zone0 = {}<br />
x = -9.81<br />
<br />
function Tick()<br />
if Game.IsPlayerInZone("Zone0")<br />
then<br />
Game.SetGravity(0, x)<br />
x = x + 0.1<br />
end<br />
<br />
return true<br />
end<br />
<br />
function Zone0.OnLeave()<br />
x = -9.81<br />
Game.SetGravity(0, x)<br />
end<br />
<br />
== IsAPlayerInZone(zone, player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return true if the player is in the specified zone.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
if Game.IsAPlayerInZone("Zone0", 0) == false<br />
then<br />
Game.Message("This player 0 is not in the zone")<br />
end<br />
return true<br />
end<br />
<br />
== SetPlayerPosition(x, y, bRight) ==<br />
=== Explanation ===<br />
Set the position and direction of the players in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example teleports the playerq each time one enters the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
== SetAPlayerPosition(x, y, bRight, player) ==<br />
=== Explanation ===<br />
Set the position and direction of the player in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example show how to teleport the player 0 at start of the level to the position (20, 5)<br />
<br />
function OnLoad()<br />
Game.SetAPlayerPosition(20, 5, 1, 0)<br />
return true<br />
end<br />
<br />
== GetPlayerPosition() ==<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of the player 0 in the game.<br />
<br />
=== Script example ===<br />
This example make the player unable to get the strawberry ;-)<br />
<br />
function Tick()<br />
x, y, bright = Game.GetPlayerPosition()<br />
if x > 18<br />
then<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== GetPlayerVelocity(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the velocity of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetPlayerSpeed(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the speed of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetPlayerAngle(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the angle of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetAPlayerPosition(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of a player in the game.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
x, y, bright = Game.GetAPlayerPosition(0)<br />
Game.Message("Player0 position is ("..x..","..y..")")<br />
return true<br />
end<br />
<br />
== SetEntityPos(entity, x, y) ==<br />
=== Explanation ===<br />
Set the position of the entity to coordinates (x, y) in the game.<br />
<br />
=== Script example ===<br />
The example changes the position of the strawberry every second.<br />
<br />
function Tick()<br />
i,f = math.mod(math.ceil(Game.GetTime()), 2)<br />
<br />
if i == 1<br />
then<br />
Game.SetEntityPos("Strawberry0", 10, 0.5)<br />
else<br />
Game.SetEntityPos("Strawberry0", 30, 0.5)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== GetEntityPos(entity) ==<br />
=== Explanation ===<br />
Return the position of the entity entity in the game.<br />
<br />
=== Script example ===<br />
This example shows another way to move a strawberry.<br />
<br />
last_update = 0<br />
<br />
function Tick()<br />
sec = math.ceil(Game.GetTime())<br />
<br />
if last_update < sec<br />
then<br />
x, y = Game.GetEntityPos("Strawberry0")<br />
<br />
if(x == 20)<br />
then<br />
x_new = 25<br />
else<br />
x_new = 20<br />
end<br />
<br />
if(y == 0.5)<br />
then<br />
y_new = 2<br />
else<br />
y_new = 0.5<br />
end<br />
<br />
Game.SetEntityPos("Strawberry0", x_new, y_new)<br />
last_update = sec<br />
end<br />
<br />
return true<br />
end<br />
<br />
== SetKeyHook(key, function) ==<br />
=== Explanation ===<br />
Whenever the player hits the "key" specified, a function will be called.<br />
<br />
=== Script example ===<br />
The example shows how to change gravity just by pressing a key.<br />
<br />
g = -9.81<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("G", "GravityChange")<br />
return true<br />
end<br />
<br />
function GravityChange()<br />
g = g * -1<br />
Game.SetGravity(0, g)<br />
end<br />
<br />
== GetKeyByAction(function) ==<br />
=== Explanation ===<br />
Return the key associated to an action. Possible actions are Drive, Brake, PullBack, PushForward, ChangeDirection.<br />
<br />
=== Script example ===<br />
The example displays how to drive at level start.<br />
<br />
function OnLoad()<br />
Game.Message("To drive, press "..Game.GetKeyByAction("Drive"))<br />
return true<br />
end<br />
<br />
== GetKeyByActionTech(function) ==<br />
=== Explanation ===<br />
Return the key associated to an action. Possible actions are Drive, Brake, PullBack, PushForward, ChangeDirection.<br />
Note that GetKeyByAction returns a human readable string while GetKeyByActionTech returns a value which is usable by SetKeyHook and that can be a joystick, mouse or keyboard key.<br />
<br />
=== Script example ===<br />
The example show how to use the Drive key to do other things than driving.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook(Game.GetKeyByActionTech("Drive"), "BalloonA")<br />
return true<br />
end<br />
<br />
== Log(msgs) ==<br />
=== Explanation ===<br />
Log a message in the xmoto.log.<br />
<br />
=== Script example ===<br />
The example log the message "An error occured" when the level starts.<br />
<br />
function OnLoad()<br />
Game.Log("An error occured")<br />
return true<br />
end<br />
<br />
== MoveBlock(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function allows X-Moto to move a block in the level. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />). Be aware that moving a block can be dangerous: make sure that the player will not be inside the block once you have moved it.<br />
<br />
=== Script example ===<br />
In the example, when the player presses the key M, the block moves to the right.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "MoveTheBlock")<br />
return true<br />
end<br />
<br />
function MoveTheBlock()<br />
Game.MoveBlock("Block0", 1, 0)<br />
end<br />
<br />
== SetBlockCenter(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function gives the center of the block relative to the block position (then, to the level if block position is (0, 0)). The center is used by the function SetBlockPos(), GetBlockPos() and SetBlockRotation(). This function should generally used in the Load() function because the center should not logically be changed (however, you can change it).<br />
<br />
=== Script example ===<br />
In the example, the center of the block is set to the center of the square. Then, when the player press M, the block is placed just under the player.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
<br />
== SetBlockPos(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function allows X-Moto to change the position of a block according to its center. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />). Be aware that moving a block can be dangerous: make sure that the player will not be inside the block once you have moved it.<br />
<br />
=== Script example ===<br />
In the example, the center of the block is set to the center of the square. Then, when the player press M, the block is placed just under the player.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
<br />
== GetBlockPos(block) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function gives the position of a given block. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
The example shows how to use this function as a condition. Here, you can move the block under the bike only if you play on the right.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
bx, by = Game.GetBlockPos("Block0")<br />
if(x > bx)<br />
then<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
end<br />
<br />
== SetBlockRotation(block, angle) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function rotates a block. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
In the example, if the player keeps the key M pressed, the block will rotate.<br />
<br />
a = 0<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
a = a + math.pi / 256.0<br />
Game.SetBlockRotation("Block0", a)<br />
end<br />
<br />
== SetDynamicEntityRotation(entity, initAngle, radius, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function tells an entity to make circles for a given duration. The current position of the entity on the circle of radius radius is at position initAngle (in rad). The entity will make a circle in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negative arguments allow you to change the behavior of the animation. For example, a negative period will rotate the entity in the negative direction.<br />
<br />
=== Script example ===<br />
The example shows how to easily move the strawberry. InitAngle is set to -PI/2 because the strawberry is placed at the bottom where we want it moves.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityRotation("Strawberry0", -math.pi/2, 2, 500, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicEntitySelfRotation(entity, period, startTime, endTime) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function allows to tell an entity to rotate for a given duration. The entity will rotate in period hundreads. The animation will start in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense.<br />
<br />
=== Script example ===<br />
The example shows how to rotate easily a entity.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntitySelfRotation("Entity2", 1000, 0, 0);<br />
return true;<br />
end;<br />
<br />
== SetDynamicEntityTranslation(entity, fX, fY, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function allows to tell an entity to make translation for a given duration. The translation's length is fX on the X axis and fY on the Y axis. The entity will make the translation in period/2 hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation.<br />
<br />
=== Script example ===<br />
The example shows an example of composed animations.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityTranslation("Strawberry0", 10, 0, 500, 0, 0)<br />
Game.SetDynamicEntityTranslation("Strawberry0", 0, 1, 100, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicEntityNone(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function removed all the animations applicated on an entity.<br />
<br />
=== Script example ===<br />
The example first shows how to ask an entity to make a translation in a first time and then, to make rotations. If the user press the key S, the strawberry stops to move.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityTranslation("Strawberry0", -2, 0, 1000, 0, 500)<br />
Game.SetDynamicEntityRotation("Strawberry0", -math.pi/2, 2, 500, 500, 0)<br />
Game.SetKeyHook("S", "StopAnimation")<br />
return true<br />
end<br />
<br />
function StopAnimation()<br />
Game.SetDynamicEntityNone("Strawberry0")<br />
end<br />
<br />
== SetDynamicBlockRotation(block, initAngle, radius, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function allows to tell a block to make circles for a given duration. The current position of the block on the circle of radius radius is at position initAngle (in rad). The block will make a circle in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make move blocks to fast otherwise the bike could go throw the block.<br />
<br />
=== Script example ===<br />
The example shows how to make move easily a block.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockRotation("Block0", -math.pi/2, 2, 500, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicBlockSelfRotation(block, period, startTime, endTime) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function allows to tell a block to rotate for a given duration. The block will rotate in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make move blocks to fast otherwise the bike could go throw the block.<br />
<br />
=== Script example ===<br />
The example shows how to rotate easily a block.<br />
<br />
function OnLoad()<br />
Game.SetBlockCenter("Block2", -2.5, -19.0);<br />
Game.SetDynamicBlockSelfRotation("Block2", 1000, 0, 0);<br />
return true;<br />
end;<br />
<br />
== SetDynamicBlockTranslation(block, fX, fY, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
<p>This function tells a block to make a translation for a given duration. A translation is a looped movement from one point to another, and back. The translation's length is fX on the X axis and fY on the Y axis. The animation will start in startTime hundredths and will finish in endTime hundredths, so the duration is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make blocks move too fast otherwise the bike could go through the block.</p><br />
<br />
<p>block: Defines which Block should move<br><br />
fX: Defines where on the X-Axis the Block should move<br><br />
fY: Defines where on the Y-Axis the Block should move<br><br />
period: Defines how long it takes the Block to move back to the starting point<br><br />
startTime: Defines when the translation should start<br><br />
endTime: Defines when the translation should end</p><br />
<br />
In order to make replay files as small as possible, you should use Translation instead of the MoveBlock function. An example on how to convert a MoveBlock function into a Translation is given below.<br />
<br />
=== Script example ===<br />
In this example, the block makes an infinite movement: It moves from its originating point (0,0) to (10,1) within 750ms, and then back in another 750ms.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 10, 1, 1500, 0, 0)<br />
return true<br />
end<br />
<br />
Example on how to convert a MoveBlock function into a Translation (see above):<br />
<br />
function Tick()<br />
Game.MoveBlock("Block0", 0.5,0)<br />
return true<br />
end<br />
<br />
Block0 moves forever to the right: 0.5px every 1/100s<br />
So it moves at a speed of 300m/60s<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 300, 0, 12000, 0, 6000)<br />
return true<br />
end<br />
<br />
This is the MoveBlock function in the translation-version. <br />
It moves 300m to the right and 300m back to the left in 12000ms. endTime is set to 12000/2=6000, so that the translation stops as soon as Block0 reaches (300,0)<br />
<br />
== SetDynamicBlockNone(block) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function stops all the animation applied on the block. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
In the example, the block will move until the player presses the key S.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 10, 1, 1500, 0, 0)<br />
Game.SetKeyHook("S", "StopAnimation")<br />
return true<br />
end<br />
<br />
function StopAnimation()<br />
Game.SetDynamicBlockNone("Block0")<br />
end<br />
<br />
== CameraZoom(z) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
In some levels, you may want that the camera is a bit more far from the player. Use this function to change the camera zoom.<br />
<br />
=== Script example ===<br />
The example shows how a different zoom can be used to play a level.<br />
<br />
function OnLoad()<br />
Game.CameraZoom(-0.05)<br />
return true<br />
end<br />
<br />
== CameraMove(x, y) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
For some particular levels, you may want the camera to be moved. Use this function to do that.<br />
<br />
=== Script example ===<br />
The example shows how you can focus a level on the part above the player.<br />
<br />
function OnLoad()<br />
Game.CameraMove(0, 3)<br />
return true<br />
end<br />
<br />
== CameraRotate(angle) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera be rotated. Use this function to do that.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.CameraRotate(math.pi / 4.0);<br />
return true<br />
end<br />
<br />
== CameraAdaptToGravity() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera be rotated. Use this function to do that in function of the gravity.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0.0, 9.81)<br />
Game.CameraAdaptToGravity()<br />
return true<br />
end<br />
<br />
== SetCameraRotationSpeed(z) ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera beeing rotated does that at a certain speed. With this function you can make it rotate either very slow ( z = 0.1 ) or extremely fast ( z = 7.2 ). The values are given in RAD, so they can reach from 0 to 2 * PI.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0.0, 9.81)<br />
Game.SetCameraRotationSpeed(0.2)<br />
Game.CameraAdaptToGravity()<br />
return true<br />
end<br />
<br />
== GetEntityRadius(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
Return the radius of an entity. This radius is used for collision. You can use this function for your own collision or anything else.<br />
<br />
=== Script example ===<br />
The example shows you the radius of the strawberry.<br />
<br />
function OnLoad()<br />
Game.Message("Radius of the strawberry : "..Game.GetEntityRadius("Strawberry0"))<br />
return true<br />
end<br />
<br />
== IsEntityTouched(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
There is a function called when you touch an entity. But sometimes you want to know when you don't touch an entity. Use this function.<br />
<br />
=== Script example ===<br />
The example shows how to make an action when the player is not touching an entity.<br />
<br />
g = -9.81<br />
<br />
function OnLoad()<br />
Game.Message("Gravity is increasing while you are not touching the snowman")<br />
return true<br />
end<br />
<br />
function Tick()<br />
if(Game.IsEntityTouched("SnowMan0") == 0)<br />
then<br />
g = g - 0.03<br />
Game.SetGravity(0, g);<br />
end<br />
return true<br />
end<br />
<br />
==Game.AddPenaltyTime(time) ==<br />
[require Xmoto >= 0.5.0]<br />
=== Explanation ===<br />
Increment the value of the time counter to make a penalty.<br />
<br />
=== Script example ===<br />
In the following example, the time will be increased of 5 seconds if the player enters in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.AddPenaltyTime(5.0)<br />
end<br />
<br />
== KillPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the players die. It's interesting if you want the players be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
In the following example, the player will die when he will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillPlayer()<br />
end<br />
<br />
== KillAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player dies. It's interesting if you want the player be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.KillAPlayer(0)<br />
return true<br />
end<br />
<br />
== KillEntity(entityID) ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the entity entityID will be deleted. The entity can be a strawberry or any sprite.<br />
<br />
=== Script example ===<br />
In the following example, the strawberry will be deleted when the player will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillEntity("Strawberry0")<br />
end<br />
<br />
== WinPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, all players win the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
In the following example, the player win on entering in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.WinPlayer()<br />
end<br />
<br />
== WinAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player wins the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.WinAPlayer(0)<br />
return true<br />
end<br />
<br />
== RemainingStrawberries() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
This function returns the number of strawberries remaining in the level.<br />
<br />
=== Script example ===<br />
In the following example, when the player will enter in the zone Zone0, the number of remaining strawberries is displayed.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.Message(Game.RemainingStrawberries())<br />
end<br />
<br />
== NumberOfPlayers() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function returns the number of players (dead or in live) in the level<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.Message(Game.NumberOfPlayers().." players")<br />
return true<br />
end<br />
<br />
== AddForceToPlayer(forceX, forceY, startTime, endTime, player) ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
This function apply an external force on the player player. The force will apply from startTime to endTime or will be infinite if endTime is 0. startTime and endTime are expressed in hundreaths and are relativ to the call function time. The force applied will be of (forceX, forceY). Application point is the center of the biker. In the example, a force will be applied to all players from time 5 to 10 seconds. Force is expressed in newton, mg/s-2 (meter * gramm / (seconds * seconds)).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
for i=0,Game.NumberOfPlayers()-1 do<br />
Game.Message("Kicking player "..(i+1))<br />
Game.AddForceToPlayer(0, 1000, 500, 1000, i)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== PlayAudio("NameOfSound") ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
Using this function you can play a sound effect (or a music). The parameter is the name of the sound, which is defined in the actually used theme file.<br />
In the following example, there must be a zone named "Zone0", As soon as you enter the zone, the sound effect is played:<br />
<br />
=== Script example ===<br />
Zone0 = {}<br />
function Zone0.OnEnter()<br />
Game.PlaySound("ring");<br />
end<br />
<br />
<br />
<br />
== SetPhysicsBlockSelfRotation (block, torque, startTime, endTime) ==<br />
[require Xmoto >= 0.5.0]<br />
=== Explanation ===<br />
This function allows to tell a block to rotate for a given duration. The rotation will be performed by applying forces (torque) on the block (if possible). The block will rotate in period hundreads. The forces application will start in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite application. Note that negativ arguments allow to change the behavior of the forces, for example, a negativ torque will tell to turn in the other sense. <br />
<br />
=== Script example ===</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Build_from_SVN&diff=5448Build from SVN2010-10-05T18:45:41Z<p>Nadenislamarre: /* Build */</p>
<hr />
<div>[[Ca:Compilacio SVN|Català]] - [[Es:Compilacion SVN|Español]] - [[No:Kompilere_fra_SVN|Norsk]] - [[Fr:Compilation_depuis_SVN|Francais]]<br />
<br />
<br />
== SVN ? ==<br />
<br />
X-Moto uses SVN to develop the game. With SVN files, you have access to new features and... new bugs.<br />
Use svn files only if you know what you are doing. otherwise just go download the stable release from the main page http://xmoto.tuxfamily.org<br />
<br />
You must know that sources downloaded from SVN should not be compiled sometimes !<br />
<br />
[http://en.wikipedia.org/wiki/Subversion_%28software%29 http://en.wikipedia.org/wiki/Subversion_%28software%29]<br />
<br />
=== Download latest files with SVN ===<br />
<br />
The first time you download the svn version you will need to download all the files under "xmoto/" :<br />
<br />
svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk xmoto<br />
<br />
or if you are a developer<br />
<br />
svn co svn+ssh://$USER@svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk xmoto<br />
<br />
(you can upload you public ssh keys to the root of your ftp account on ftp://$USER@ftp.tuxfamily.org/ in a file called ssh_keys)<br />
<br />
Note that there are a lot of graphical clients to use svn if you're afraid of the command line.<br />
<br />
=== Update the files ===<br />
<br />
When you have already download from svn once, you can update the files with this command :<br />
<br />
# svn update<br />
<br />
=== Web access ===<br />
http://svn.tuxfamily.org/viewvc.cgi/?root=xmoto_xmoto<br />
<br />
=== Notification via rss ===<br />
http://svnweb.tuxfamily.org/rss.php?repname=xmoto+%28xmoto%29&path=%2F&rev=0&sc=0&isdir=1<br />
<br />
== Build ==<br />
<br />
=== Dependencies ===<br />
<br />
X-Moto must have the following to compile properly :<br />
<br />
* Latest gcc and g++<br />
* SDL development libraries and headers<br />
* OpenGL development libraries and headers<br />
* SDL_mixer with headers<br />
* SDL_net with headers<br />
* libjpeg with headers<br />
* libpng with headers<br />
* zlib with headers<br />
* libbzip2 with headers<br />
* liblua50 with headers<br />
* liblualib50 with headers<br />
* libode with headers<br />
* libcurl3 with headers<br />
* automake >= 1.9<br />
<br />
sudo aptitude install subversion build-essential automake1.9 libsqlite3-dev libjpeg62-dev libbz2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev liblua5.1-0-dev libode-dev zlib1g-dev libpng12-dev libglu1-mesa-dev libsdl-ttf2.0-dev libcurl3-openssl-dev libxdg-basedir-dev<br />
<br />
To build windows version from linux, you'll need the following extra packages <br />
sudo aptitude install tofrodos nsis mingw32<br />
<br />
Use mingw32 3.4.5.20060117.1.dfsg-3 from gusty for ubuntu otherwise, .exe built are instables<br />
<br />
But with the new features, new dependencies can be asked.<br />
<br />
=== Ok, I can build it ! ===<br />
<br />
$ cd xmoto<br />
$ sh ./bootstrap<br />
$ ./configure<br />
$ make<br />
# make install<br />
<br />
Right now, you can start xmoto with "<code>src/xmoto</code>".<br />
<br />
If sh ./bootstrap failed, you have to edit the ./bootstrap file manually:<br />
aclocal -I config $ACLOCAL_FLAGS\<br />
&& automake --gnu --add-missing --copy \<br />
<br />
so it looks like that:<br />
aclocal-1.9 -I config $ACLOCAL_FLAGS\<br />
&& automake-1.9 --gnu --add-missing --copy \<br />
<br />
=== Doesn't work ? ===<br />
<br />
xmoto.bin not found !<br />
You probably reconfigure without making clean.<br />
Do:<br />
make clean<br />
./configure<br />
make<br />
make install<br />
<br />
=== Need help ? ===<br />
Join us on IRC, the channel is #xmoto on the freenode servers.<br />
irc://irc.freenode.net/xmoto</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Build_from_SVN&diff=5447Build from SVN2010-10-05T18:41:09Z<p>Nadenislamarre: /* Dependencies */</p>
<hr />
<div>[[Ca:Compilacio SVN|Català]] - [[Es:Compilacion SVN|Español]] - [[No:Kompilere_fra_SVN|Norsk]] - [[Fr:Compilation_depuis_SVN|Francais]]<br />
<br />
<br />
== SVN ? ==<br />
<br />
X-Moto uses SVN to develop the game. With SVN files, you have access to new features and... new bugs.<br />
Use svn files only if you know what you are doing. otherwise just go download the stable release from the main page http://xmoto.tuxfamily.org<br />
<br />
You must know that sources downloaded from SVN should not be compiled sometimes !<br />
<br />
[http://en.wikipedia.org/wiki/Subversion_%28software%29 http://en.wikipedia.org/wiki/Subversion_%28software%29]<br />
<br />
=== Download latest files with SVN ===<br />
<br />
The first time you download the svn version you will need to download all the files under "xmoto/" :<br />
<br />
svn co svn://svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk xmoto<br />
<br />
or if you are a developer<br />
<br />
svn co svn+ssh://$USER@svn.tuxfamily.org/svnroot/xmoto/xmoto/trunk xmoto<br />
<br />
(you can upload you public ssh keys to the root of your ftp account on ftp://$USER@ftp.tuxfamily.org/ in a file called ssh_keys)<br />
<br />
Note that there are a lot of graphical clients to use svn if you're afraid of the command line.<br />
<br />
=== Update the files ===<br />
<br />
When you have already download from svn once, you can update the files with this command :<br />
<br />
# svn update<br />
<br />
=== Web access ===<br />
http://svn.tuxfamily.org/viewvc.cgi/?root=xmoto_xmoto<br />
<br />
=== Notification via rss ===<br />
http://svnweb.tuxfamily.org/rss.php?repname=xmoto+%28xmoto%29&path=%2F&rev=0&sc=0&isdir=1<br />
<br />
== Build ==<br />
<br />
=== Dependencies ===<br />
<br />
X-Moto must have the following to compile properly :<br />
<br />
* Latest gcc and g++<br />
* SDL development libraries and headers<br />
* OpenGL development libraries and headers<br />
* SDL_mixer with headers<br />
* SDL_net with headers<br />
* libjpeg with headers<br />
* libpng with headers<br />
* zlib with headers<br />
* libbzip2 with headers<br />
* liblua50 with headers<br />
* liblualib50 with headers<br />
* libode0 with headers<br />
* libcurl3 with headers<br />
* automake >= 1.9<br />
<br />
sudo aptitude install subversion build-essential automake1.9 libsqlite3-dev libjpeg62-dev libbz2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev liblua5.1-0-dev libode0-dev zlib1g-dev libpng12-dev libglu1-mesa-dev libsdl-ttf2.0-dev libcurl3-openssl-dev libxdg-basedir-dev<br />
<br />
To build windows version from linux, you'll need the following extra packages <br />
sudo aptitude install tofrodos nsis mingw32<br />
<br />
Use mingw32 3.4.5.20060117.1.dfsg-3 from gusty for ubuntu otherwise, .exe built are instables<br />
<br />
But with the new features, new dependencies can be asked.<br />
<br />
=== Ok, I can build it ! ===<br />
<br />
$ cd xmoto<br />
$ sh ./bootstrap<br />
$ ./configure<br />
$ make<br />
# make install<br />
<br />
Right now, you can start xmoto with "<code>src/xmoto</code>".<br />
<br />
If sh ./bootstrap failed, you have to edit the ./bootstrap file manually:<br />
aclocal -I config $ACLOCAL_FLAGS\<br />
&& automake --gnu --add-missing --copy \<br />
<br />
so it looks like that:<br />
aclocal-1.9 -I config $ACLOCAL_FLAGS\<br />
&& automake-1.9 --gnu --add-missing --copy \<br />
<br />
=== Doesn't work ? ===<br />
<br />
xmoto.bin not found !<br />
You probably reconfigure without making clean.<br />
Do:<br />
make clean<br />
./configure<br />
make<br />
make install<br />
<br />
=== Need help ? ===<br />
Join us on IRC, the channel is #xmoto on the freenode servers.<br />
irc://irc.freenode.net/xmoto</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4020Server command line2009-04-23T09:10:55Z<p>Nadenislamarre: /* unban */</p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
The main utility is to ban people from the server (via ip or profile name) and see some statistics about the server (traffic).<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
This command is used to add admnistrators.<br />
It takes 2 arguments : the id of the player to become an admnistrator and the password for this admnistrator.<br />
<br />
Note: use "lsplayers" to get the identifier of the player. Identifier are used instead of profile name because it's easier and your keyboard could have not some special chars (if you want a chineese, a russian, a greek or any man with a non ascii name because an administrator)<br />
<br />
In the following example, 0 is the identifier of the player (Nicolas in the previous screenshots) which will become admnistrator.<br />
$ addadmin 0 his_password<br />
<br />
==rmadmin==<br />
This command is used to remove an administrator. This command takes only 1 argument : the identifier of the administrator to remove, use lsadmins to get it.<br />
$ rmadmin 2<br />
<br />
==lsbans==<br />
This command lists the people banned on the server. For each ban, you can see its identifier (a number), the profile banned (* for all), and the ip banned (* for all). This command takes no argument.<br />
* 2: (Nicolas, *) means : anybody can connect with the profile Nicolas<br />
* 3: (*, 55.63.12.35) means : nobody can connect from the ip 55.63.12.35<br />
<br />
==ban==<br />
This command is used to ban somebody. You can ban by ip or by profile.<br />
This commands takes 2 or 3 parameters. The first argument is the id of the player (use the command lsplayers to get this id). The 2e argument is ip or profile. You can add a 3rd argument to precise the number of days (by default 30 days are set).<br />
<br />
ban 2 ip<br />
ban 2 profile<br />
ban 2 ip 50<br />
ban 2 ip 0<br />
<br />
==unban==<br />
This command is used to unban somebody. It takes only 1 argument, the id of the ban (Use lsbans to get it).<br />
<br />
==stats==<br />
This command displays some information about the server.<br />
<br />
[[Image:Server stats.png|500x500px]]<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4019Server command line2009-04-23T09:10:12Z<p>Nadenislamarre: /* ban */</p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
The main utility is to ban people from the server (via ip or profile name) and see some statistics about the server (traffic).<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
This command is used to add admnistrators.<br />
It takes 2 arguments : the id of the player to become an admnistrator and the password for this admnistrator.<br />
<br />
Note: use "lsplayers" to get the identifier of the player. Identifier are used instead of profile name because it's easier and your keyboard could have not some special chars (if you want a chineese, a russian, a greek or any man with a non ascii name because an administrator)<br />
<br />
In the following example, 0 is the identifier of the player (Nicolas in the previous screenshots) which will become admnistrator.<br />
$ addadmin 0 his_password<br />
<br />
==rmadmin==<br />
This command is used to remove an administrator. This command takes only 1 argument : the identifier of the administrator to remove, use lsadmins to get it.<br />
$ rmadmin 2<br />
<br />
==lsbans==<br />
This command lists the people banned on the server. For each ban, you can see its identifier (a number), the profile banned (* for all), and the ip banned (* for all). This command takes no argument.<br />
* 2: (Nicolas, *) means : anybody can connect with the profile Nicolas<br />
* 3: (*, 55.63.12.35) means : nobody can connect from the ip 55.63.12.35<br />
<br />
==ban==<br />
This command is used to ban somebody. You can ban by ip or by profile.<br />
This commands takes 2 or 3 parameters. The first argument is the id of the player (use the command lsplayers to get this id). The 2e argument is ip or profile. You can add a 3rd argument to precise the number of days (by default 30 days are set).<br />
<br />
ban 2 ip<br />
ban 2 profile<br />
ban 2 ip 50<br />
ban 2 ip 0<br />
<br />
==unban==<br />
==stats==<br />
This command displays some information about the server.<br />
<br />
[[Image:Server stats.png|500x500px]]<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4018Server command line2009-04-23T08:45:59Z<p>Nadenislamarre: /* lsbans */</p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
The main utility is to ban people from the server (via ip or profile name) and see some statistics about the server (traffic).<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
This command is used to add admnistrators.<br />
It takes 2 arguments : the id of the player to become an admnistrator and the password for this admnistrator.<br />
<br />
Note: use "lsplayers" to get the identifier of the player. Identifier are used instead of profile name because it's easier and your keyboard could have not some special chars (if you want a chineese, a russian, a greek or any man with a non ascii name because an administrator)<br />
<br />
In the following example, 0 is the identifier of the player (Nicolas in the previous screenshots) which will become admnistrator.<br />
$ addadmin 0 his_password<br />
<br />
==rmadmin==<br />
This command is used to remove an administrator. This command takes only 1 argument : the identifier of the administrator to remove, use lsadmins to get it.<br />
$ rmadmin 2<br />
<br />
==lsbans==<br />
This command lists the people banned on the server. For each ban, you can see its identifier (a number), the profile banned (* for all), and the ip banned (* for all). This command takes no argument.<br />
* 2: (Nicolas, *) means : anybody can connect with the profile Nicolas<br />
* 3: (*, 55.63.12.35) means : nobody can connect from the ip 55.63.12.35<br />
<br />
==ban==<br />
==unban==<br />
==stats==<br />
This command displays some information about the server.<br />
<br />
[[Image:Server stats.png|500x500px]]<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4017Server command line2009-04-22T15:17:32Z<p>Nadenislamarre: /* stats */</p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
The main utility is to ban people from the server (via ip or profile name) and see some statistics about the server (traffic).<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
This command is used to add admnistrators.<br />
It takes 2 arguments : the id of the player to become an admnistrator and the password for this admnistrator.<br />
<br />
Note: use "lsplayers" to get the identifier of the player. Identifier are used instead of profile name because it's easier and your keyboard could have not some special chars (if you want a chineese, a russian, a greek or any man with a non ascii name because an administrator)<br />
<br />
In the following example, 0 is the identifier of the player (Nicolas in the previous screenshots) which will become admnistrator.<br />
$ addadmin 0 his_password<br />
<br />
==rmadmin==<br />
This command is used to remove an administrator. This command takes only 1 argument : the identifier of the administrator to remove, use lsadmins to get it.<br />
$ rmadmin 2<br />
<br />
==lsbans==<br />
==ban==<br />
==unban==<br />
==stats==<br />
This command displays some information about the server.<br />
<br />
[[Image:Server stats.png|500x500px]]<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4016Server command line2009-04-22T15:12:06Z<p>Nadenislamarre: </p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
The main utility is to ban people from the server (via ip or profile name) and see some statistics about the server (traffic).<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
This command is used to add admnistrators.<br />
It takes 2 arguments : the id of the player to become an admnistrator and the password for this admnistrator.<br />
<br />
Note: use "lsplayers" to get the identifier of the player. Identifier are used instead of profile name because it's easier and your keyboard could have not some special chars (if you want a chineese, a russian, a greek or any man with a non ascii name because an administrator)<br />
<br />
In the following example, 0 is the identifier of the player (Nicolas in the previous screenshots) which will become admnistrator.<br />
$ addadmin 0 his_password<br />
<br />
==rmadmin==<br />
This command is used to remove an administrator. This command takes only 1 argument : the identifier of the administrator to remove, use lsadmins to get it.<br />
$ rmadmin 2<br />
<br />
==lsbans==<br />
==ban==<br />
==unban==<br />
==stats==<br />
[[Image:Server stats.png|500x500px]]<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=File:Server_stats.png&diff=4015File:Server stats.png2009-04-22T15:11:32Z<p>Nadenislamarre: </p>
<hr />
<div></div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4014Server command line2009-04-22T15:06:40Z<p>Nadenislamarre: </p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
The main utility is to ban people from the server (via ip or profile name) and see some statistics about the server (traffic).<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
This command is used to add admnistrators.<br />
It takes 2 arguments : the id of the player to become an admnistrator and the password for this admnistrator.<br />
<br />
Note: use "lsplayers" to get the identifier of the player. Identifier are used instead of profile name because it's easier and your keyboard could have not some special chars (if you want a chineese, a russian, a greek or any man with a non ascii name because an administrator)<br />
<br />
In the following example, 0 is the identifier of the player (Nicolas in the previous screenshots) which will become admnistrator.<br />
$ addadmin 0 his_password<br />
<br />
==rmadmin==<br />
This command is used to remove an administrator. This command takes only 1 argument : the identifier of the administrator to remove, use lsadmins to get it.<br />
$ rmadmin 2<br />
<br />
==lsbans==<br />
==ban==<br />
==unban==<br />
==stats==<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4013Server command line2009-04-22T15:06:23Z<p>Nadenislamarre: </p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
The main utility is to ban people from the server (via ip or profile name) and see some statistics about the server (traffic).<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
This command is used to add admnistrators.<br />
It takes 2 arguments : the id of the player to become an admnistrator and the password for this admnistrator.<br />
<br />
Note: use "lsplayers" to get the identifier of the player. Identifier are used instead of profile name because it's easier and your keyboard could have not some special chars (if you want a chineese, a russian, a greek or any man with a non ascii name because an administrator)<br />
<br />
In the following example, 0 is the identifier of the player (Nicolas in the previous screenshots) which will become admnistrator.<br />
$ addadmin 0 his_password<br />
<br />
==rmadmin==<br />
This command is used to remove an administrator. This command takes only 1 argument : the identifier of the administrator to remove, use lsadmins to get it.<br />
$ rmadmin 2<br />
<br />
==lsbans==<br />
==ban==<br />
==unban==<br />
==stats==<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4012Server command line2009-04-22T15:01:28Z<p>Nadenislamarre: /* rmadmin */</p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
This command is used to add admnistrators.<br />
It takes 2 arguments : the id of the player to become an admnistrator and the password for this admnistrator.<br />
<br />
Note: use "lsplayers" to get the identifier of the player. Identifier are used instead of profile name because it's easier and your keyboard could have not some special chars (if you want a chineese, a russian, a greek or any man with a non ascii name because an administrator)<br />
<br />
In the following example, 0 is the identifier of the player (Nicolas in the previous screenshots) which will become admnistrator.<br />
$ addadmin 0 his_password<br />
<br />
==rmadmin==<br />
This command is used to remove an administrator. This command takes only 1 argument : the identifier of the administrator to remove, use lsadmins to get it.<br />
$ rmadmin 2<br />
<br />
==lsbans==<br />
==ban==<br />
==unban==<br />
==stats==<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4011Server command line2009-04-22T14:54:03Z<p>Nadenislamarre: </p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
This command is used to add admnistrators.<br />
It takes 2 arguments : the id of the player to become an admnistrator and the password for this admnistrator.<br />
<br />
Note: use "lsplayers" to get the identifier of the player. Identifier are used instead of profile name because it's easier and your keyboard could have not some special chars (if you want a chineese, a russian, a greek or any man with a non ascii name because an administrator)<br />
<br />
In the following example, 0 is the identifier of the player (Nicolas in the previous screenshots) which will become admnistrator.<br />
$ addadmin 0 his_password<br />
<br />
==rmadmin==<br />
==lsbans==<br />
==ban==<br />
==unban==<br />
==stats==<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4010Server command line2009-04-22T14:53:12Z<p>Nadenislamarre: /* addadmin */</p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
This command is used to add admnistrators.<br />
It takes 2 arguments : the id of the player to become an admnistrator and the password for this admnistrator.<br />
<br />
Note: use "lsplayers" to get the identifier of the player. Identifier are used instead of profile name because it's easier and your keyboard could have not some special chars (if you want a chineese, a russian, a greek or any man with a non ascii name because an administrator)<br />
<br />
In the following example, 3 is the identifier of the player which will become admnistrator.<br />
$ addadmin 3 his_password<br />
<br />
==rmadmin==<br />
==lsbans==<br />
==ban==<br />
==unban==<br />
==stats==<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4009Server command line2009-04-22T14:47:55Z<p>Nadenislamarre: </p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
=Commands=<br />
==help==<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
==login==<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
==logout==<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
==changepassword==<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
==lsplayers==<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
==lsadmins==<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
==addadmin==<br />
==rmadmin==<br />
==lsbans==<br />
==ban==<br />
==unban==<br />
==stats==<br />
<br />
=Extra controls=<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4008Server command line2009-04-22T14:46:36Z<p>Nadenislamarre: /* Commands */</p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
==Commands==<br />
===help===<br />
This command lists the available commands and their syntax.<br />
This command takes no argument.<br />
<br />
===login===<br />
This command is required to identify yourself to the game server.<br />
Use it without any argument if there is still no administrator on the server.<br />
Give your password as argument if you're an administrator of the server.<br />
$ login mypassword<br />
<br />
===logout===<br />
This command can be used if you want to logout without closing X-Moto.<br />
This command takes no argument.<br />
<br />
===changepassword===<br />
Use this command to change your password. When an admninistrator is created, the initial password is choosed by the admnistrator which create the account. The first thing to do for the new admnistrator is to change his password.<br />
This command takes the new password as argument<br />
$ changepassword my_new_password<br />
<br />
===lsplayers===<br />
[[Image:Server lsplayers.png|500x500px]]<br />
<br />
This command lists the connected players on the server.<br />
For each player, you can see his identifier (a number), his name and his ip.<br />
This command takes no argument.<br />
<br />
===lsadmins===<br />
[[Image:Server lsadmins.png|500x500px]]<br />
<br />
This command lists the admnistrators on the server.<br />
For each administrator, you can see his identifier (a number), and his name.<br />
This command takes no argument.<br />
<br />
===addadmin===<br />
===rmadmin===<br />
===lsbans===<br />
===ban===<br />
===unban===<br />
===stats===<br />
<br />
==Extra controls==<br />
* <ctrl> l : clear the console<br />
* <ctrl> d : close the console<br />
* arrow up, arrow down : use shell history</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=File:Server_lsplayers.png&diff=4007File:Server lsplayers.png2009-04-22T14:42:48Z<p>Nadenislamarre: </p>
<hr />
<div></div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=File:Server_lsadmins.png&diff=4006File:Server lsadmins.png2009-04-22T14:40:59Z<p>Nadenislamarre: </p>
<hr />
<div></div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4005Server command line2009-04-22T14:29:13Z<p>Nadenislamarre: </p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
To play on the network, you need to start a server (one server for several players).<br />
<br />
Go in options => www => server and click on "Start the server".<br />
If you don't know what is a port, choose the default one (4130).<br />
<br />
[[Image:Server start.png|500x500px]]<br />
<br />
==Connect to the server==<br />
Once a server is started, any player on the network can connect to it (you've to know a name or an ip of the server).<br />
<br />
Go in levels => network, put the name of the server and click on "Connect".<br />
<br />
"localhost" means your own computer.<br />
<br />
[[Image:Server connect.png|500x500px]]<br />
<br />
==Open the console==<br />
Once connected, you can open the console using <ctrl><alt>s keyboard sequence.<br />
<br />
[[Image:Server console.png|500x500px]]<br />
<br />
A banner is displayed and you get a prompt so that you can type commands.<br />
<br />
===First admin creation===<br />
Thanks to the console, you'll be able to add server administrators.<br />
At the beginning, there is no default administrator defined.<br />
Only people connected from the localhost (ip 127.0.0.1) can login without password by typing the command "login".<br />
<br />
Note: once an admnistrator is created, only real administrators can connect. People from localhost can't anymore be connected without an account (protect your ~/.xmoto directory so that any system user can create account directly by modifiying database files).<br />
<br />
==Commands==</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=File:Server_console.png&diff=4004File:Server console.png2009-04-22T14:21:50Z<p>Nadenislamarre: </p>
<hr />
<div></div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=File:Server_connect.png&diff=4003File:Server connect.png2009-04-22T14:10:44Z<p>Nadenislamarre: </p>
<hr />
<div></div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=File:Server_start.png&diff=4002File:Server start.png2009-04-22T13:57:35Z<p>Nadenislamarre: </p>
<hr />
<div></div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4001Server command line2009-04-22T13:55:13Z<p>Nadenislamarre: /* ==Open the console */</p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
=Open the console=<br />
==First admin creation==<br />
<br />
=Commands=</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Server_command_line&diff=4000Server command line2009-04-22T13:54:44Z<p>Nadenislamarre: </p>
<hr />
<div>Since X-Moto 0.5.2, you can control the game server from the X-Moto game.<br />
<br />
=Connexion to the console=<br />
==Start your server==<br />
===Open the console=<br />
==First admin creation==<br />
<br />
=Commands=</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Main_Page&diff=3999Main Page2009-04-22T13:51:32Z<p>Nadenislamarre: /* Information */</p>
<hr />
<div>__NOTOC__<br />
<br />
[[de:Main_Page|Deutsch]] - [[ca:Main_Page|Català]] - [[es:Main_Page|Español]] - [[fr:Main_Page|Français]] - [[no:Main_Page|Norsk]] - [[pt:Main_Page|Portuguese]] -<br />
[[sv:Main_Page|Svenska]]<br />
<br />
== Information ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Return to Home Page]<br />
* [[manual|X-Moto Manual]]<br />
* [[Server command line|X-Moto server command line]]<br />
* [[Screenshots]]<br />
* [[Faq|FAQ]]<br />
* [[Philip's_xmoto_guide|Philips X-Moto Guide]]<br />
* [[X-Moto on PSP]]<br />
* [[IRC tutorial]]<br />
* [[Public X-Moto servers]]<br />
* [[Wiki Contributors]]<br />
'''Features'''<br />
* [[Use X-Moto on a USB-Key]]<br />
* [[Use private rooms in game (instead of World Highscores)]]<br />
* [[Joystick|Using a joystick to control the game]]<br />
* [[Wiimote|Using a wiimote to control the game]]<br />
* [[record_video|Recording Ingame Videos]]<br />
* [[Convert a replay to a video]]<br />
* [[Recording videos with an external program]]<br />
<br />
== Level Creation ==<br />
<br />
*[[About good level design]]<br />
*[[Level Checklist (for Creators and Testers)]]<br />
<br />
'''Editor'''<br />
* [[How to create smooth levels using Inkscape|How to create a smooth level with Inksmoto Level Editor]]<br />
* [[xmoto-edit|How to create a level with xmoto-edit (DEPRECATED)]]<br />
* [[Scripted levels|How to create a scripted level (please look scripting section below)]]<br />
* [[Others tips to make levels]]<br />
* [[Shortcuts for most used actions in the editor]]<br />
* [[Video tutorials]]<br />
'''Themes and Graphics'''<br />
* [[Make a theme|Make a theme/add a new sprite or texture]]<br />
* [[textures_creation|How to handle your own textures for level creation]]<br />
* [[How to create, test and upload an animated sprite]]<br />
* [[Background graphics pool|Background Graphics Pool]]<br />
* [[sprites_pool|Sprites Pool 4 Gimp]]<br />
* [[Svg Block Pool]]<br />
'''Scripting'''<br />
* [[How to include Scripts into a Level]]<br />
* [[Funtions for Game Events| Funtions for Game Events (Zones, OnSomersaults, etc.)]]<br />
* [[Level alteration Functions| Level alteration Functions (Blocks, Physics, etc.)]]<br />
* [[Player Functions| Player Functions (Win, Kill,Positioning, etc.) )]]<br />
* [[Camera Functions| Camera Functions (Zooming, Rotation, etc.)]]<br />
* [[Sound Functions]]<br />
'''Mods and Scripts'''<br />
* [[Skate Park Mod]]<br />
* [[Useful Scripts]]<br />
<br />
== Building XMoto ==<br />
* [[Build for Unix (like GNU/Linux)]]<br />
* [[Build for MacOSX]]<br />
* [[Build for Windows]]<br />
* [[Build from SVN]]<br />
* [[Build with CMake (experimental)]]<br />
<br />
== Administration ==<br />
* [[How to validate a highscore]]<br />
* [[How to validate a level]]<br />
* [[Forum's administration changes]]<br />
* [[How to unvalidate a highscore]]<br />
* [[How to update po pictures]]<br />
* [[How to remove a validated level]]<br />
<br />
== Development ==<br />
* [[Wishlist]]<br />
* [[Code documentation]]<br />
* [[Contributions|How to contribute to X-Moto]]<br />
* [[Translate X-Moto and X-Moto Website into your language]]<br />
* [[File formats]]<br />
* [[Net protocol]]<br />
* [[Access to the website sources]]<br />
* [[SDL_gfx|SDL_gfx porting effort]]<br />
* [[Chipmunk integration]]<br />
* [[Level collection list]]<br />
* [[Multiplayer design]]<br />
* [[Deliver a X-Moto version MEMO]]<br />
* [[Rooms competition idea]]</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Main_Page&diff=3998Main Page2009-04-22T13:51:04Z<p>Nadenislamarre: /* Information */</p>
<hr />
<div>__NOTOC__<br />
<br />
[[de:Main_Page|Deutsch]] - [[ca:Main_Page|Català]] - [[es:Main_Page|Español]] - [[fr:Main_Page|Français]] - [[no:Main_Page|Norsk]] - [[pt:Main_Page|Portuguese]] -<br />
[[sv:Main_Page|Svenska]]<br />
<br />
== Information ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Return to Home Page]<br />
* [[manual|X-Moto Manual]]<br />
* [[manual|X-Moto server command line]]<br />
* [[Screenshots]]<br />
* [[Faq|FAQ]]<br />
* [[Philip's_xmoto_guide|Philips X-Moto Guide]]<br />
* [[X-Moto on PSP]]<br />
* [[IRC tutorial]]<br />
* [[Public X-Moto servers]]<br />
* [[Wiki Contributors]]<br />
'''Features'''<br />
* [[Use X-Moto on a USB-Key]]<br />
* [[Use private rooms in game (instead of World Highscores)]]<br />
* [[Joystick|Using a joystick to control the game]]<br />
* [[Wiimote|Using a wiimote to control the game]]<br />
* [[record_video|Recording Ingame Videos]]<br />
* [[Convert a replay to a video]]<br />
* [[Recording videos with an external program]]<br />
<br />
== Level Creation ==<br />
<br />
*[[About good level design]]<br />
*[[Level Checklist (for Creators and Testers)]]<br />
<br />
'''Editor'''<br />
* [[How to create smooth levels using Inkscape|How to create a smooth level with Inksmoto Level Editor]]<br />
* [[xmoto-edit|How to create a level with xmoto-edit (DEPRECATED)]]<br />
* [[Scripted levels|How to create a scripted level (please look scripting section below)]]<br />
* [[Others tips to make levels]]<br />
* [[Shortcuts for most used actions in the editor]]<br />
* [[Video tutorials]]<br />
'''Themes and Graphics'''<br />
* [[Make a theme|Make a theme/add a new sprite or texture]]<br />
* [[textures_creation|How to handle your own textures for level creation]]<br />
* [[How to create, test and upload an animated sprite]]<br />
* [[Background graphics pool|Background Graphics Pool]]<br />
* [[sprites_pool|Sprites Pool 4 Gimp]]<br />
* [[Svg Block Pool]]<br />
'''Scripting'''<br />
* [[How to include Scripts into a Level]]<br />
* [[Funtions for Game Events| Funtions for Game Events (Zones, OnSomersaults, etc.)]]<br />
* [[Level alteration Functions| Level alteration Functions (Blocks, Physics, etc.)]]<br />
* [[Player Functions| Player Functions (Win, Kill,Positioning, etc.) )]]<br />
* [[Camera Functions| Camera Functions (Zooming, Rotation, etc.)]]<br />
* [[Sound Functions]]<br />
'''Mods and Scripts'''<br />
* [[Skate Park Mod]]<br />
* [[Useful Scripts]]<br />
<br />
== Building XMoto ==<br />
* [[Build for Unix (like GNU/Linux)]]<br />
* [[Build for MacOSX]]<br />
* [[Build for Windows]]<br />
* [[Build from SVN]]<br />
* [[Build with CMake (experimental)]]<br />
<br />
== Administration ==<br />
* [[How to validate a highscore]]<br />
* [[How to validate a level]]<br />
* [[Forum's administration changes]]<br />
* [[How to unvalidate a highscore]]<br />
* [[How to update po pictures]]<br />
* [[How to remove a validated level]]<br />
<br />
== Development ==<br />
* [[Wishlist]]<br />
* [[Code documentation]]<br />
* [[Contributions|How to contribute to X-Moto]]<br />
* [[Translate X-Moto and X-Moto Website into your language]]<br />
* [[File formats]]<br />
* [[Net protocol]]<br />
* [[Access to the website sources]]<br />
* [[SDL_gfx|SDL_gfx porting effort]]<br />
* [[Chipmunk integration]]<br />
* [[Level collection list]]<br />
* [[Multiplayer design]]<br />
* [[Deliver a X-Moto version MEMO]]<br />
* [[Rooms competition idea]]</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=IRC_tutorial&diff=3997IRC tutorial2009-04-21T20:10:19Z<p>Nadenislamarre: </p>
<hr />
<div>X-Moto has an [http://en.wikipedia.org/wiki/IRC IRC] chat. Feel free to join our '''#xmoto''' channel on the '''irc.freenode.net''' server. This is the place where X-moto developers, map makers and players meet. <br />
<br />
For the list of available IRC clients see [http://en.wikipedia.org/wiki/Comparison_of_Internet_Relay_Chat_clients here].<br />
<br />
=Online=<br />
Online irc clients are useful if you are not on your own computer.<br />
[http://irc2go.com/pjirc/?net=Netrusk&room=xmoto&name=XmotoPlayer Join here!]<br />
===Things needed:===<br />
* Chat Room: keep the preset (xmoto).<br />
* Nickname: you name that other people can see when chatting.<br />
* Realname: name that people can see from your info.<br />
Then hit continue! Allow the java and you are in. :)<br />
<br />
=Under Pidgin=<br />
<br />
For example, you can download [http://pidgin.im/ Pidgin] [http://pidgin.im/download/ here]. It runs in Linux, MS Windows and Mac OS X.<br />
When you start '''Pidgin''' for the first time it should look approximately like this: <br />
<br />
[[Image:Pidgin_screen1.png]]<br />
<br />
Now we need to add an IRC account. Put "'''irc.freenode.net'''"<br />
in the "'''server'''" field and your nickname for "'''screen name'''". This will be your name on the server(you can change it later).<br />
<br />
[[Image:Pidgin_screen2.png]]<br />
<br />
Save these settings and press "'''connect'''". You will see something like this:<br />
<br />
[[Image:Pidgin_screen4.png]]<br />
<br />
Now type "'''/join #xmoto'''" in this window or press '''Buddies->Join a chat''' in the main window. That's all, you are connected.<br />
<br />
[[Image:Pidgin_screen6.png]]<br />
<br />
=Under mIRC=<br />
<br />
mIRC is another popular IRC client. However mIRC is only for windows users, and it's not open source. But here is a short tuturial if you prefer mIRC:<br />
<br />
*The first step is to visit mIRC's [http://www.mirc.com/ homepage] and download the most recent mIRC client.<br />
<br />
It should look like this when you've installed mIRC, and launched it for the first time.<br />
<br />
[[Image:MIRC_screen1.png]]<br />
<br />
Then fill out the fields, but don't press ''"Connect"'' yet!<br />
Because we need to specify which server we are going to use.<br />
*Press ''"Servers"''<br />
Now a long list of servers will appear, but you'll be unable to find our server in the list. So we'll add it ourselves!<br />
*Press ''"Add"'', and type in the description and server-address:<br />
[[Image:MIRC_screen3.png]]<br />
*Press ''"Add"'' again...<br />
*Then mark it in the list and press ''"Select"''.<br />
*Now when our server is specified, press ''"Connect"''.<br />
*And the final thing; type in the channel name and join us! <br />
[[Image:MIRC_screen4.png]]</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Video_tutorials&diff=3805Video tutorials2008-12-31T17:43:06Z<p>Nadenislamarre: /* This is the Basic! */</p>
<hr />
<div>==This is the Basic!==<br />
<youtube>NcXafolwOQM&hl</youtube></div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Video_tutorials&diff=3804Video tutorials2008-12-31T17:40:54Z<p>Nadenislamarre: </p>
<hr />
<div>==This is the Basic!==<br />
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/NcXafolwOQM&hl=fr&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/NcXafolwOQM&hl=fr&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Main_Page&diff=3803Main Page2008-12-31T17:40:04Z<p>Nadenislamarre: /* Level Creation */</p>
<hr />
<div>__NOTOC__<br />
<br />
[[de:Main_Page|Deutsch]] - [[ca:Main_Page|Català]] - [[es:Main_Page|Español]] - [[fr:Main_Page|Français]] - [[no:Main_Page|Norsk]]<br />
<br />
== Information ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Return to Home Page]<br />
* [[manual|X-Moto Manual]]<br />
* [[Screenshots]]<br />
* [[Faq|FAQ]]<br />
* [[X-Moto on PSP]]<br />
* [[IRC tutorial]]<br />
* [[Public X-Moto servers]]<br />
* [[Wiki Contributors]]<br />
'''Features'''<br />
* [[Use X-Moto on a USB-Key]]<br />
* [[Use private rooms in game (instead of World Highscores)]]<br />
* [[Joystick|Using a joystick to control the game]]<br />
* [[Wiimote|Using a wiimote to control the game]]<br />
* [[record_video|Recording Ingame Videos]]<br />
* [[Convert a replay to a video]]<br />
* [[Recording videos with an external program]]<br />
<br />
== Level Creation ==<br />
<br />
*[[About good level design]]<br />
<br />
'''Editor'''<br />
* [[How to create smooth levels using Inkscape|How to create a smooth level with Inksmoto Level Editor]]<br />
* [[xmoto-edit|How to create a level with xmoto-edit (DEPRECATED)]]<br />
* [[Scripted levels|How to create a scripted level (please look scripting section below)]]<br />
* [[Others tips to make levels]]<br />
* [[Shortcuts for most used actions in the editor]]<br />
* [[Video tutorials]]<br />
'''Themes and Graphics'''<br />
* [[Make a theme|Make a theme/add a new sprite or texture]]<br />
* [[textures_creation|How to handle your own textures for level creation]]<br />
* [[How to create, test and upload an animated sprite]]<br />
* [[Background graphics pool|Background Graphics Pool]]<br />
* [[sprites_pool|Sprites Pool 4 Gimp]]<br />
'''Scripting'''<br />
* [[How to include Scripts into a Level]]<br />
* [[Funtions for Game Events| Funtions for Game Events (Zones, OnSomersaults, etc.)]]<br />
* [[Level alteration Functions| Level alteration Functions (Blocks, Physics, etc.)]]<br />
* [[Player Functions| Player Functions (Win, Kill,Positioning, etc.) )]]<br />
* [[Camera Functions| Camera Functions (Zooming, Rotation, etc.)]]<br />
* [[Sound Functions]]<br />
'''Mods and Scripts'''<br />
* [[Skate Park Mod]]<br />
* [[Useful Scripts]]<br />
<br />
== Building XMoto ==<br />
* [[Build for Unix (like GNU/Linux)]]<br />
* [[Build for MacOSX]]<br />
* [[Build for Windows]]<br />
* [[Build from SVN]]<br />
* [[Build with CMake (experimental)]]<br />
<br />
== Administration ==<br />
* [[How to validate a highscore]]<br />
* [[How to validate a level]]<br />
* [[Forum's administration changes]]<br />
* [[How to unvalidate a highscore]]<br />
* [[How to update po pictures]]<br />
* [[How to remove a validated level]]<br />
<br />
== Development ==<br />
* [[Wishlist]]<br />
* [[Code documentation]]<br />
* [[Contributions|How to contribute to X-Moto]]<br />
* [[Translate X-Moto and X-Moto Website into your language]]<br />
* [[File formats]]<br />
* [[Net protocol]]<br />
* [[Access to the website sources]]<br />
* [[SDL_gfx|SDL_gfx porting effort]]<br />
* [[Chipmunk integration]]<br />
* [[Level collection list]]<br />
* [[Multiplayer design]]<br />
* [[Deliver a X-Moto version MEMO]]<br />
* [[Rooms competition idea]]</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=X-Moto_on_PSP&diff=3802X-Moto on PSP2008-12-30T17:56:03Z<p>Nadenislamarre: </p>
<hr />
<div>=X-Moto on PSP=<br />
<br />
You will find on this page some work I have done for the PlayStation Portable and some games I have ported.<br />
In order to try these homebrews, you will need a PSP with a custom firmware.<br />
You can discuss about these and give feedbacks on my PSP forum. Thanks !<br />
<br />
If you enjoy my softwares and ports, feel free to make a donation [http://royale.zerezo.com/psp].<br />
<br />
==Installation==<br />
* Download: X-Moto-PSP-0.x.zip on the xmoto website<br />
* Unzip and install in your PSP firmware 3/4/5.x folder.<br />
<br />
Controls:<br />
* up/cross: throttle<br />
* down/square: brake<br />
* left/left trigger: left flip<br />
* right/right trigger: right flip<br />
* circle: change direction<br />
* triangle: zoom out<br />
* select: enable fps and ugly mode<br />
* start: restart level<br />
<br />
Known issues:<br />
* Very slow...<br />
* No sound.<br />
* No menus.<br />
* Not the latest version of X-Moto.<br />
* And many more...<br />
<br />
=How to build X-Moto for the PSP=<br />
Here is a quick tutorial to explain how you can build X-Moto for the PSP from source code.<br />
This is only required if you want to contribute to the development.<br />
If you just want to play, you can download the PSP port directly from the xmoto website.<br />
<br />
I assume you are running a Debian or Ubuntu Linux system, but it should be easy to use these instructions for another Linux distribution.<br />
Basically, this will build a cross-compiler on your computer, with all the libraries needed by X-Moto.<br />
Depending on your hardware, this process can be quite long (about 2 hours)...<br />
<br />
==Build the toolchain==<br />
sudo apt-get install subversion<br />
svn co svn://svn.pspdev.org/psp/trunk/psptoolchain<br />
cd psptoolchain<br />
<br />
Follow the instructions in the readme-ubuntu.txt file (install required packages for building process and edit your .bashrc file to add the path).<br />
<br />
sudo ./toolchain-sudo.sh<br />
cd ..<br />
<br />
==Install DA SDK==<br />
This step might be optional in the future, but currently it is needed because some libraries depend on headers and libraries not available in the standard SDK.<br />
<br />
wget http://www.gwailos.com/downloads/401M33-2.rar<br />
unrar x 401M33-2.rar<br />
sudo cp SDK/include/kubridge.h /usr/local/pspdev/psp/sdk/include/<br />
sudo cp SDK/lib/libpspkubridge.a /usr/local/pspdev/psp/sdk/lib/<br />
<br />
==Build the libraries==<br />
svn co svn://svn.pspdev.org/psp/trunk/psplibraries<br />
cd psplibraries<br />
<br />
Follow the instructions in the readme-ubuntu.txt file (install required packages for building process).<br />
sudo ./libraries-sudo.sh<br />
cd..<br />
<br />
==Build libode==<br />
svn co svn://svn.ps2dev.org/psp/trunk/ode<br />
cd ode<br />
<br />
Edit the config/makefile.psp file and append "-lpspvfpu" to the LINK_OPENGL variable.<br />
make<br />
sudo cp -rf include/* /usr/local/pspdev/psp/include/<br />
sudo cp -rf lib/* /usr/local/pspdev/psp/lib/<br />
cd ..<br />
<br />
==Build libcurl==<br />
svn co svn://svn.pspdev.org/pspware/trunk/libcurl/<br />
cd libcurl<br />
LDFLAGS="-L$(psp-config --psp-prefix)/lib -L$(psp-config --pspsdk-path)/lib" \<br />
LIBS="-lc -lpspnet_inet -lpspnet_resolver -lpspuser" \<br />
./configure --host=psp --disable-shared --prefix=$(psp-config --psp-prefix)<br />
make CFLAGS=-G0<br />
sudo PATH=/usr/local/pspdev/bin/:$PATH make install<br />
cd ..<br />
<br />
==Build X-Moto-PSP==<br />
Download X-Moto version 0.4.2 :<br />
<br />
wget http://download.tuxfamily.org/xmoto/xmoto/0.4.2/xmoto-0.4.2-src.tar.gz<br />
tar zxvf xmoto-0.4.2-src.tar.gz<br />
<br />
Apply the X-Moto-PSP 0.2 patch :<br />
wget http://royale.zerezo.com/psp/X-Moto-PSP-0.2.patch.bz2<br />
bunzip2 X-Moto-PSP-0.2.patch.bz2<br />
cd xmoto-0.4.2<br />
patch -p1 < ../X-Moto-PSP-0.2.patch<br />
<br />
And finally build X-Moto for the PSP :<br />
cd src<br />
make -f Makefile.psp<br />
cd ../..<br />
<br />
You should end up with a "EBOOT.PBP" file in the src folder, which is the PSP binary for X-Moto.<br />
<br />
==Copy X-Moto-PSP to your PSP==<br />
mkdir X-Moto-PSP<br />
cp xmoto-0.4.2/readme.txt xmoto-0.4.2/changes.txt xmoto-0.4.2/src/EBOOT.PBP X-Moto-PSP<br />
cp -r xmoto-0.4.2/bin/xmoto.bin xmoto-0.4.2/bin/Textures xmoto-0.4.2/po X-Moto-PSP<br />
<br />
Copy a dummy config folder as well :<br />
cp -rf ~/.xmoto X-Moto-PSP/config<br />
<br />
Edit the X-Moto-PSP/config/config.dat file to change the resolution to 480x272 fullscreen :<br />
var name="DisplayWidth" value="480"<br />
var name="DisplayHeight" value="272"<br />
var name="DisplayBPP" value="24"<br />
var name="DisplayWindowed" value="false"<br />
var name="MenuGraphics" value="Low"<br />
var name="GameGraphics" value="Low"<br />
<br />
Finally, copy the X-Moto-PSP folder to your PSP in psp/game.<br />
You will need a custom firmware on your PSP in order to run the game.<br />
Feel free to leave a comment if you spot any issue in this tutorial wink</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=X-Moto_on_PSP&diff=3801X-Moto on PSP2008-12-30T17:46:33Z<p>Nadenislamarre: </p>
<hr />
<div>=How to build X-Moto for the PSP=<br />
Here is a quick tutorial to explain how you can build X-Moto for the PSP from source code.<br />
This is only required if you want to contribute to the development.<br />
If you just want to play, you can download the PSP port directly from the xmoto website.<br />
<br />
I assume you are running a Debian or Ubuntu Linux system, but it should be easy to use these instructions for another Linux distribution.<br />
Basically, this will build a cross-compiler on your computer, with all the libraries needed by X-Moto.<br />
Depending on your hardware, this process can be quite long (about 2 hours)...<br />
<br />
==Build the toolchain==<br />
sudo apt-get install subversion<br />
svn co svn://svn.pspdev.org/psp/trunk/psptoolchain<br />
cd psptoolchain<br />
<br />
Follow the instructions in the readme-ubuntu.txt file (install required packages for building process and edit your .bashrc file to add the path).<br />
<br />
sudo ./toolchain-sudo.sh<br />
cd ..<br />
<br />
==Install DA SDK==<br />
This step might be optional in the future, but currently it is needed because some libraries depend on headers and libraries not available in the standard SDK.<br />
<br />
wget http://www.gwailos.com/downloads/401M33-2.rar<br />
unrar x 401M33-2.rar<br />
sudo cp SDK/include/kubridge.h /usr/local/pspdev/psp/sdk/include/<br />
sudo cp SDK/lib/libpspkubridge.a /usr/local/pspdev/psp/sdk/lib/<br />
<br />
==Build the libraries==<br />
svn co svn://svn.pspdev.org/psp/trunk/psplibraries<br />
cd psplibraries<br />
<br />
Follow the instructions in the readme-ubuntu.txt file (install required packages for building process).<br />
sudo ./libraries-sudo.sh<br />
cd..<br />
<br />
==Build libode==<br />
svn co svn://svn.ps2dev.org/psp/trunk/ode<br />
cd ode<br />
<br />
Edit the config/makefile.psp file and append "-lpspvfpu" to the LINK_OPENGL variable.<br />
make<br />
sudo cp -rf include/* /usr/local/pspdev/psp/include/<br />
sudo cp -rf lib/* /usr/local/pspdev/psp/lib/<br />
cd ..<br />
<br />
==Build libcurl==<br />
svn co svn://svn.pspdev.org/pspware/trunk/libcurl/<br />
cd libcurl<br />
LDFLAGS="-L$(psp-config --psp-prefix)/lib -L$(psp-config --pspsdk-path)/lib" \<br />
LIBS="-lc -lpspnet_inet -lpspnet_resolver -lpspuser" \<br />
./configure --host=psp --disable-shared --prefix=$(psp-config --psp-prefix)<br />
make CFLAGS=-G0<br />
sudo PATH=/usr/local/pspdev/bin/:$PATH make install<br />
cd ..<br />
<br />
==Build X-Moto-PSP==<br />
Download X-Moto version 0.4.2 :<br />
<br />
wget http://download.tuxfamily.org/xmoto/xmoto/0.4.2/xmoto-0.4.2-src.tar.gz<br />
tar zxvf xmoto-0.4.2-src.tar.gz<br />
<br />
Apply the X-Moto-PSP 0.2 patch :<br />
wget http://royale.zerezo.com/psp/X-Moto-PSP-0.2.patch.bz2<br />
bunzip2 X-Moto-PSP-0.2.patch.bz2<br />
cd xmoto-0.4.2<br />
patch -p1 < ../X-Moto-PSP-0.2.patch<br />
<br />
And finally build X-Moto for the PSP :<br />
cd src<br />
make -f Makefile.psp<br />
cd ../..<br />
<br />
You should end up with a "EBOOT.PBP" file in the src folder, which is the PSP binary for X-Moto.<br />
<br />
==Copy X-Moto-PSP to your PSP==<br />
mkdir X-Moto-PSP<br />
cp xmoto-0.4.2/readme.txt xmoto-0.4.2/changes.txt xmoto-0.4.2/src/EBOOT.PBP X-Moto-PSP<br />
cp -r xmoto-0.4.2/bin/xmoto.bin xmoto-0.4.2/bin/Textures xmoto-0.4.2/po X-Moto-PSP<br />
<br />
Copy a dummy config folder as well :<br />
cp -rf ~/.xmoto X-Moto-PSP/config<br />
<br />
Edit the X-Moto-PSP/config/config.dat file to change the resolution to 480x272 fullscreen :<br />
var name="DisplayWidth" value="480"<br />
var name="DisplayHeight" value="272"<br />
var name="DisplayBPP" value="24"<br />
var name="DisplayWindowed" value="false"<br />
var name="MenuGraphics" value="Low"<br />
var name="GameGraphics" value="Low"<br />
<br />
Finally, copy the X-Moto-PSP folder to your PSP in psp/game.<br />
You will need a custom firmware on your PSP in order to run the game.<br />
Feel free to leave a comment if you spot any issue in this tutorial wink</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Main_Page&diff=3613Main Page2008-12-10T11:54:22Z<p>Nadenislamarre: /* Information */</p>
<hr />
<div>__NOTOC__<br />
<br />
[[de:Main_Page|Deutsch]] - [[ca:Main_Page|Català]] - [[es:Main_Page|Español]] - [[fr:Main_Page|Français]] - [[no:Main_Page|Norsk]]<br />
<br />
== Information ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Return to Home Page]<br />
* [[manual|X-Moto Manual]]<br />
* [[Screenshots]]<br />
* [[Faq|FAQ]]<br />
* [[X-Moto on PSP]]<br />
* [[IRC tutorial]]<br />
* [[Public X-Moto servers]]<br />
* [[Wiki Contributors]]<br />
'''Features'''<br />
* [[Use X-Moto on a USB-Key]]<br />
* [[Use private rooms in game (instead of World Highscores)]]<br />
* [[Joystick|Using a joystick to control the game]]<br />
* [[Wiimote|Using a wiimote to control the game]]<br />
* [[record_video|Recording Ingame Videos]]<br />
* [[Convert a replay to a video]]<br />
<br />
== Level Creation ==<br />
<br />
*[[About good level design]]<br />
<br />
'''Editor'''<br />
* [[How to create smooth levels using Inkscape|How to create a smooth level with Inksmoto Level Editor]]<br />
* [[xmoto-edit|How to create a level with xmoto-edit (DEPRECATED)]]<br />
* [[Scripted levels|How to create a scripted level (please look scripting section below)]]<br />
* [[Others tips to make levels]]<br />
* [[Shortcuts for most used actions in the editor]]<br />
'''Themes and Graphics'''<br />
* [[Make a theme|Make a theme/add a new sprite or texture]]<br />
* [[textures_creation|How to handle your own textures for level creation]]<br />
* [[How to create, test and upload an animated sprite]]<br />
* [[Background graphics pool|Background Graphics Pool]]<br />
* [[sprites_pool|Sprites Pool 4 Gimp]]<br />
'''Scripting'''<br />
* [[How to include Scripts into a Level]]<br />
* [[Funtions for Game Events| Funtions for Game Events (Zones, OnSomersaults, etc.)]]<br />
* [[Level alteration Functions| Level alteration Functions (Blocks, Physics, etc.)]]<br />
* [[Player Functions| Player Functions (Win, Kill,Positioning, etc.) )]]<br />
* [[Camera Functions| Camera Functions (Zooming, Rotation, etc.)]]<br />
* [[Sound Functions]]<br />
'''Mods and Scripts'''<br />
* [[Skate Park Mod]]<br />
<br />
<br />
== Building XMoto ==<br />
* [[Build for Unix (like GNU/Linux)]]<br />
* [[Build for MacOSX]]<br />
* [[Build for Windows]]<br />
* [[Build from SVN]]<br />
* [[Build with CMake (experimental)]]<br />
<br />
== Administration ==<br />
* [[How to validate a highscore]]<br />
* [[How to validate a level]]<br />
* [[Forum's administration changes]]<br />
* [[How to unvalidate a highscore]]<br />
* [[How to update po pictures]]<br />
* [[How to remove a validated level]]<br />
<br />
== Development ==<br />
* [[Wishlist]]<br />
* [[Code documentation]]<br />
* [[Contributions|How to contribute to X-Moto]]<br />
* [[Translate X-Moto and X-Moto Website into your language]]<br />
* [[File formats]]<br />
* [[Net protocol]]<br />
* [[Access to the website sources]]<br />
* [[SDL_gfx|SDL_gfx porting effort]]<br />
* [[Chipmunk integration]]<br />
* [[Level collection list]]<br />
* [[Multiplayer design]]<br />
* [[Deliver a X-Moto version MEMO]]<br />
* [[Rooms competition idea]]</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Public_X-Moto_servers&diff=3599Public X-Moto servers2008-12-06T09:27:01Z<p>Nadenislamarre: </p>
<hr />
<div>* games.tuxfamily.org</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Main_Page&diff=3598Main Page2008-12-06T09:26:48Z<p>Nadenislamarre: /* Information */</p>
<hr />
<div>__NOTOC__<br />
<br />
[[de:Main_Page|Deutsch]] - [[ca:Main_Page|Català]] - [[es:Main_Page|Español]] - [[fr:Main_Page|Français]] - [[no:Main_Page|Norsk]]<br />
<br />
== Information ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Return to Home Page]<br />
* [[manual|X-Moto Manual]]<br />
* [[Screenshots]]<br />
* [[Faq|FAQ]]<br />
* [[IRC tutorial]]<br />
* [[Public X-Moto servers]]<br />
* [[Wiki Contributors]]<br />
'''Features'''<br />
* [[Use X-Moto on a USB-Key]]<br />
* [[Use private rooms in game (instead of World Highscores)]]<br />
* [[Joystick|Using a joystick to control the game]]<br />
* [[Wiimote|Using a wiimote to control the game]]<br />
* [[record_video|Recording Ingame Videos]]<br />
* [[Convert a replay to a video]]<br />
<br />
== Level Creation ==<br />
<br />
*[[About good level design]]<br />
<br />
'''Editor'''<br />
* [[How to create smooth levels using Inkscape|How to create a smooth level with Inksmoto Level Editor]]<br />
* [[xmoto-edit|How to create a level with xmoto-edit (DEPRECATED)]]<br />
* [[Scripted levels|How to create a scripted level (please look scripting section below)]]<br />
* [[Others tips to make levels]]<br />
* [[Shortcuts for most used actions in the editor]]<br />
'''Themes and Graphics'''<br />
* [[Make a theme|Make a theme/add a new sprite or texture]]<br />
* [[textures_creation|How to handle your own textures for level creation]]<br />
* [[How to create, test and upload an animated sprite]]<br />
* [[Background graphics pool|Background Graphics Pool]]<br />
* [[sprites_pool|Sprites Pool 4 Gimp]]<br />
'''Scripting'''<br />
* [[How to include Scripts into a Level]]<br />
* [[Funtions for Game Events| Funtions for Game Events (Zones, OnSomersaults, etc.)]]<br />
* [[Level alteration Functions| Level alteration Functions (Blocks, Physics, etc.)]]<br />
* [[Player Functions| Player Functions (Win, Kill,Positioning, etc.) )]]<br />
* [[Camera Functions| Camera Functions (Zooming, Rotation, etc.)]]<br />
* [[Sound Functions]]<br />
'''Mods and Scripts'''<br />
* [[Skate Park Mod]]<br />
<br />
<br />
== Building XMoto ==<br />
* [[Build for Unix (like GNU/Linux)]]<br />
* [[Build for MacOSX]]<br />
* [[Build for Windows]]<br />
* [[Build from SVN]]<br />
* [[Build with CMake (experimental)]]<br />
<br />
== Administration ==<br />
* [[How to validate a highscore]]<br />
* [[How to validate a level]]<br />
* [[Forum's administration changes]]<br />
* [[How to unvalidate a highscore]]<br />
* [[How to update po pictures]]<br />
* [[How to remove a validated level]]<br />
<br />
== Development ==<br />
* [[Wishlist]]<br />
* [[Code documentation]]<br />
* [[Contributions|How to contribute to X-Moto]]<br />
* [[Translate X-Moto and X-Moto Website into your language]]<br />
* [[File formats]]<br />
* [[Net protocol]]<br />
* [[Access to the website sources]]<br />
* [[SDL_gfx|SDL_gfx porting effort]]<br />
* [[Chipmunk integration]]<br />
* [[Level collection list]]<br />
* [[Multiplayer design]]<br />
* [[Deliver a X-Moto version MEMO]]<br />
* [[Rooms competition idea]]</div>Nadenislamarrehttps://wiki.xmoto.tuxfamily.org/index.php?title=Scripted_levels&diff=3593Scripted levels2008-12-04T18:36:00Z<p>Nadenislamarre: /* SetPhysicsBlockPos (block, fX, fY) */</p>
<hr />
<div>[[Ca:Scripted levels|Català]] - [[Es:Scripted levels|Español]]<br />
<br />
= Introduction =<br />
Scripting allows a level to become dynamic. You can change physic settings, move objects, modify game logic, etc. A script is written in the Lua language and can be included in a level file.<br />
<br />
Documentation about Lua can be found here :<br />
http://www.lua.org/manual/5.1/<br />
<br />
To write a script, you must know a little about a level file. It is an xml file. It includes somes properties like the name of the level, description, author, date, etc. Moreover, it includes block and sprite definitions. A block is composed of vertices which link together to draw polygons.<br />
<br />
Since 0.3.0, xmoto supports multiplayers ; in the script, a player is defined by an index. The first player has the number 0, the second the number 1, ...<br />
<br />
The script examples on this page will use this basic level file:<br />
<br />
<?xml version="1.0" encoding="utf-8"?><br />
<level id="tutscript"><br />
<info><br />
<name>tutscript</name><br />
<description></description><br />
<author></author><br />
<date></date><br />
<sky>sky1</sky><br />
</info><br />
<script><br />
</script><br />
<limits left="0" right="50" top="30" bottom="0"/><br />
<block id="Block0"><br />
<position x="0" y="0"/><br />
<usetexture id="default"/><br />
<vertex x="5" y="5"/><br />
<vertex x="5" y="10"/><br />
<vertex x="10" y="10"/><br />
<vertex x="10" y="5"/><br />
</block><br />
<entity id="MyPlayerStart0" typeid="PlayerStart"><br />
<size r="0.4"/><br />
<position x="7.5" y="10"/><br />
</entity><br />
<entity id="Strawberry0" typeid="Strawberry"><br />
<size r="0.4"/><br />
<position x="20" y="0.5"/><br />
</entity><br />
<entity id="SnowMan0" typeid="Sprite"><br />
<param name="name" value="SnowMan"/><br />
<position x="19" y="0.2"/><br />
<param name="z" value="-1"/><br />
</entity><br />
<zone id="Zone0"><br />
<box left="40" right="50" top="5" bottom="0"/><br />
</zone><br />
</level><br />
<br />
This level can be made easily with the xmoto level editor. It includes a block called Block0 which is a square, a strawberry called Strawberry0 and a zone called Zone0. A zone is an invisible part of the level that can execute actions when the player is inside.<br />
<br />
Some functions require a minimum X-Moto version to work. If you use one of these functions, please put this information in the level. For example, to make your level require X-Moto version 0.2.0, add this line to your level:<br />
<br />
<level id="tutscript" rversion="0.2.0"><br />
<br />
[[Image:Scripted_level.jpg]]<br />
<br />
All the code of the script is written in Lua. You can find the syntax here. However, if you choose to include the script in an xml file, < and > symbol must be replaced by &amp;lt; and &amp;gt;. The code of the script can be included between <script> and </script> in the level file.<br />
<br />
= Functions called by XMoto =<br />
<br />
== OnLoad() ==<br />
=== Explanation ===<br />
This function is called one time when the level starts. You must return true if nothing bad happened.<br />
<br />
=== Script example ===<br />
The example displays a message at the start of the level.<br />
<br />
function OnLoad()<br />
Game.Message("This level is scripted")<br />
return true<br />
end<br />
<br />
== Tick() ==<br />
=== Explanation ===<br />
Function called 1 time every hundredth.<br />
You must return true if nothing bad happened.<br />
Be aware that if this function use is abusive, levels will not be validated :<br />
action function like setBlockPos, setPlayerPos, ...<br />
(contrary to request function getBlockPos, getTime, and lua code)<br />
require that the information is store into the replay. If you put a setBlockPos<br />
call into the Tick function, it will make big replays : around 20 bytes * 100 * 60 / minute<br />
=> several hundreads of KB / minute<br />
To limit this if you really want to call such functions into your level :<br />
- first, play your level and check that replay size is under 100 ko<br />
- reduce the number of time you call setBlockPos by adding a variable to make<br />
this function called not in all Tick() but 1/3 for example<br />
- add a zone so that the animation (tick) is called only when you're<br />
in this zone<br />
- use dynamicBlock or dynamicEntity functions<br />
<br />
=== Script example ===<br />
This example will initialize gravity to 0 ; then, it will increment it with the time. Because earth gravity is 9.81, the earth gravity will not be reached before the 9.81 seconds. Be aware that in xmoto, vertical gravity must be multiplied by -1 because of screen coords which are reversed.<br />
<br />
function Tick()<br />
if Game.GetTime() < 9.81<br />
then<br />
Game.SetGravity(0, Game.GetTime() * -1)<br />
end<br />
return true<br />
end<br />
<br />
function Load()<br />
Game.SetGravity(0, 0)<br />
return true<br />
end<br />
<br />
== Entity.Touch() ==<br />
=== Explanation ===<br />
This function is called when an entity (a strawberry for example) is touched. The entity must be declared in the script. Note that the <size r> parameter allows to choose the distance of the entity which must be considered so that it is touched.<br />
<br />
=== Script example ===<br />
The example displays a message when the strawberry is touched.<br />
<br />
Strawberry0 = {}<br />
<br />
function Strawberry0.Touch()<br />
Game.Message("Nice strawberry !")<br />
end<br />
<br />
== Entity.TouchBy(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when an entity (a strawberry for example) is touched. The entity must be declared in the script. Note that the <size r> parameter allows to choose the distance of the entity which must be considered so that it is touched.<br />
<br />
=== Script example ===<br />
The example displays a message when the strawberry is touched.<br />
<br />
Strawberry0 = {}<br />
<br />
function Strawberry0.TouchBy(player)<br />
Game.Message("Player "..player.." takes the strawberry")<br />
end<br />
<br />
== Zone.OnEnter() ==<br />
=== Explanation ===<br />
This function is called when a player enters in a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player enters into the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.Message("Entering in the zone")<br />
end<br />
<br />
== Zone.OnEnterBy(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when a player enters in a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player enters into the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnterBy(player)<br />
Game.Message("Player "..player.." enters the zone")<br />
end<br />
<br />
== Zone.OnLeave() ==<br />
=== Explanation ===<br />
This function is called when a player leaves a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player leaves the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnLeave()<br />
Game.Message("Leaving the zone")<br />
end<br />
<br />
== Zone.OnLeaveBy() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function is called when a player leaves a zone.<br />
<br />
=== Script example ===<br />
The example displays a message when a player leaves the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnLeaveBy(player)<br />
Game.Message("Player "..player.." leaves the zone")<br />
end<br />
<br />
== OnSomersault(bClockWise) ==<br />
[require Xmoto >= 0.2.1]<br />
<br />
=== Explanation ===<br />
This function is called each time a player make a new somersault. bClockWise is 1 is the somersault is clockwise, 0 if counterclockwise.<br />
<br />
=== Script example ===<br />
The example displays a message when a player makes a somersault.<br />
<br />
function OnSomersault(bClockWise)<br />
if(bClockWise == 1) <br />
then<br />
Game.Message("ClockWise Somersault")<br />
else<br />
Game.Message("CounterClockWise Somersault")<br />
end<br />
end<br />
<br />
== OnSomersaultBy(bClockWise, player) ==<br />
[require Xmoto >= 0.3.0]<br />
<br />
=== Explanation ===<br />
This function is called each time a player make a new somersault. bClockWise is 1 is the somersault is clockwise, 0 if counterclockwise.<br />
<br />
=== Script example ===<br />
The example displays a message when a player makes a somersault.<br />
<br />
function OnSomersaultBy(bClockWise, player)<br />
Game.Message("Nice ! player "..player)<br />
end<br />
<br />
== OnWheel1Touchs(status), OnWheel2Touchs(status) ==<br />
[require Xmoto >= 0.2.1]<br />
<br />
=== Explanation ===<br />
This function is called each time just the wheel 1 touchs the ground or stops to touch the ground. (status is 1 is the ground was not touching and is now touching, and 0 else)<br />
<br />
=== Script example ===<br />
The example displays the new max duration of a jump each time a new one is done.<br />
<br />
max_jump_time = 1.0 -- start at 1 to not count smaller jumps<br />
jump_begin = 0.0<br />
touch_1 = false<br />
touch_2 = false<br />
<br />
function OnWheel1Touchs(bStatus)<br />
if(bStatus == 1) <br />
then<br />
updateMax()<br />
touch_1 = true<br />
else<br />
touch_1 = false<br />
jump_begin = Game.GetTime()<br />
end<br />
end<br />
<br />
function OnWheel2Touchs(bStatus)<br />
if(bStatus == 1) <br />
then<br />
updateMax()<br />
touch_2 = true<br />
else<br />
touch_2 = false<br />
jump_begin = Game.GetTime()<br />
end<br />
end<br />
<br />
function updateMax()<br />
if(touch_1 == false and touch_2 == false)<br />
then<br />
if(Game.GetTime() - jump_begin > max_jump_time)<br />
then<br />
max_jump_time = Game.GetTime() - jump_begin<br />
Game.Message("New high jump: "..max_jump_time)<br />
end<br />
end<br />
end<br />
<br />
== OnWheel1TouchsBy(status, player), OnWheel2TouchsBy(status, player) ==<br />
[require Xmoto >= 0.3.0]<br />
<br />
=== Explanation ===<br />
This function is called each time just the wheel 1 touchs the ground or stops to touch the ground. (status is 1 is the ground was not touching and is now touching, and 0 else)<br />
<br />
=== Script example ===<br />
function OnWheel1TouchsBy(status, player)<br />
if(status == 1) <br />
then<br />
Game.Message("Player "..player.." touches with wheel 1")<br />
end<br />
end<br />
<br />
function OnWheel2TouchsBy(status, player)<br />
if(status == 1) <br />
then<br />
Game.Message("Player "..player.." touches with wheel 2")<br />
end<br />
end<br />
<br />
= Callable X-Moto functions =<br />
<br />
== GetTime() ==<br />
=== Explanation ===<br />
Return the time since the start of the level.<br />
<br />
=== Script example ===<br />
The example displays a message if the player takes more than 10 seconds to enter the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
if Game.GetTime() > 10.0<br />
then<br />
Game.Message("10 seconds to come there, that's a lot !")<br />
end<br />
end<br />
<br />
== Message(msgs) ==<br />
=== Explanation ===<br />
Display a message on the screen. The message is automatically remove after 5 seconds. You can call this function several times : the messages will be all displayed.<br />
<br />
=== Script example ===<br />
The example displays some messages at the start of the level.<br />
<br />
function OnLoad()<br />
Game.Message("This level is scripted")<br />
Game.Message("GO GO GO !!!")<br />
return true<br />
end<br />
<br />
== ClearMessages() ==<br />
=== Explanation ===<br />
Remove messages on the screen.<br />
<br />
=== Script example ===<br />
The example shows how to clear old messages and display a new one in some circumstances.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.ClearMessages()<br />
Game.Message("OnEnter")<br />
end<br />
<br />
function Zone0.OnLeave()<br />
Game.ClearMessages()<br />
Game.Message("OnLeave")<br />
end<br />
<br />
== SetGravity(x, y) ==<br />
=== Explanation ===<br />
Change the gravity (horizontal and vertical) in the game.<br />
<br />
=== Script example ===<br />
The example shows how to reverse gravity. Be aware that in X-Moto, vertical gravity must be multiplied by -1 because screen coordinates are reversed in the y direction.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0, 9.81)<br />
return true<br />
end<br />
<br />
== GetGravity() ==<br />
=== Explanation ===<br />
Return the pair(horizontal gravity, vertical gravity).<br />
<br />
=== Script example ===<br />
The example displays the wind and gravity at the start of the level.<br />
<br />
function OnLoad()<br />
x, y = Game.GetGravity()<br />
Game.Message("Wind : "..x)<br />
Game.Message("Gravity : "..(y*-1))<br />
return true<br />
end<br />
<br />
== IsPlayerInZone(zone) ==<br />
=== Explanation ===<br />
Return true if a player is in the specified zone.<br />
<br />
=== Script example ===<br />
This example is a bit more complicated. When the player enters the zone, gravity slowly decreases. Once the player leaves the zone, the gravity suddenly becomes 9.81.<br />
<br />
Zone0 = {}<br />
x = -9.81<br />
<br />
function Tick()<br />
if Game.IsPlayerInZone("Zone0")<br />
then<br />
Game.SetGravity(0, x)<br />
x = x + 0.1<br />
end<br />
<br />
return true<br />
end<br />
<br />
function Zone0.OnLeave()<br />
x = -9.81<br />
Game.SetGravity(0, x)<br />
end<br />
<br />
== IsAPlayerInZone(zone, player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return true if the player is in the specified zone.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
if Game.IsAPlayerInZone("Zone0", 0) == false<br />
then<br />
Game.Message("This player 0 is not in the zone")<br />
end<br />
return true<br />
end<br />
<br />
== SetPlayerPosition(x, y, bRight) ==<br />
=== Explanation ===<br />
Set the position and direction of the players in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example teleports the playerq each time one enters the zone.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
== SetAPlayerPosition(x, y, bRight, player) ==<br />
=== Explanation ===<br />
Set the position and direction of the player in the game. bRight can be 0 or 1.<br />
<br />
=== Script example ===<br />
The example show how to teleport the player 0 at start of the level to the position (20, 5)<br />
<br />
function OnLoad()<br />
Game.SetAPlayerPosition(20, 5, 1, 0)<br />
return true<br />
end<br />
<br />
== GetPlayerPosition() ==<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of the player 0 in the game.<br />
<br />
=== Script example ===<br />
This example make the player unable to get the strawberry ;-)<br />
<br />
function Tick()<br />
x, y, bright = Game.GetPlayerPosition()<br />
if x > 18<br />
then<br />
Game.SetPlayerPosition(5, 0, 1)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== GetPlayerVelocity(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the velocity of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetPlayerSpeed(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the speed of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetPlayerAngle(player) ==<br />
[require Xmoto >= 0.5.0] <br />
<br />
=== Explanation ===<br />
Return the angle of the player.<br />
<br />
=== Script example ===<br />
This example show informations when the player pressed the key M.<br />
function OnLoad()<br />
Game.SetKeyHook("M", "Infos")<br />
return true<br />
end<br />
<br />
function Infos()<br />
Game.Message("Velocity: "..Game.GetPlayerVelocity(0))<br />
Game.Message("Speed: "..Game.GetPlayerSpeed(0))<br />
Game.Message("Angle: "..Game.GetPlayerAngle(0))<br />
end<br />
<br />
== GetAPlayerPosition(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
Return the triplet (x, y, bRight) which give the position of a player in the game.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
x, y, bright = Game.GetAPlayerPosition(0)<br />
Game.Message("Player0 position is ("..x..","..y..")")<br />
return true<br />
end<br />
<br />
== SetEntityPos(entity, x, y) ==<br />
=== Explanation ===<br />
Set the position of the entity to coordinates (x, y) in the game.<br />
<br />
=== Script example ===<br />
The example changes the position of the strawberry every second.<br />
<br />
function Tick()<br />
i,f = math.mod(math.ceil(Game.GetTime()), 2)<br />
<br />
if i == 1<br />
then<br />
Game.SetEntityPos("Strawberry0", 10, 0.5)<br />
else<br />
Game.SetEntityPos("Strawberry0", 30, 0.5)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== GetEntityPos(entity) ==<br />
=== Explanation ===<br />
Return the position of the entity entity in the game.<br />
<br />
=== Script example ===<br />
This example shows another way to move a strawberry.<br />
<br />
last_update = 0<br />
<br />
function Tick()<br />
sec = math.ceil(Game.GetTime())<br />
<br />
if last_update < sec<br />
then<br />
x, y = Game.GetEntityPos("Strawberry0")<br />
<br />
if(x == 20)<br />
then<br />
x_new = 25<br />
else<br />
x_new = 20<br />
end<br />
<br />
if(y == 0.5)<br />
then<br />
y_new = 2<br />
else<br />
y_new = 0.5<br />
end<br />
<br />
Game.SetEntityPos("Strawberry0", x_new, y_new)<br />
last_update = sec<br />
end<br />
<br />
return true<br />
end<br />
<br />
== SetKeyHook(key, function) ==<br />
=== Explanation ===<br />
Whenever the player hits the "key" specified, a function will be called.<br />
<br />
=== Script example ===<br />
The example shows how to change gravity just by pressing a key.<br />
<br />
g = -9.81<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("G", "GravityChange")<br />
return true<br />
end<br />
<br />
function GravityChange()<br />
g = g * -1<br />
Game.SetGravity(0, g)<br />
end<br />
<br />
== GetKeyByAction(function) ==<br />
=== Explanation ===<br />
Return the key associated to an action. Possible actions are Drive, Brake, PullBack, PushForward, ChangeDirection.<br />
<br />
=== Script example ===<br />
The example displays how to drive at level start.<br />
<br />
function OnLoad()<br />
Game.Message("To drive, press "..Game.GetKeyByAction("Drive"))<br />
return true<br />
end<br />
<br />
== Log(msgs) ==<br />
=== Explanation ===<br />
Log a message in the xmoto.log.<br />
<br />
=== Script example ===<br />
The example log the message "An error occured" when the level starts.<br />
<br />
function OnLoad()<br />
Game.Log("An error occured")<br />
return true<br />
end<br />
<br />
== MoveBlock(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function allows X-Moto to move a block in the level. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />). Be aware that moving a block can be dangerous: make sure that the player will not be inside the block once you have moved it.<br />
<br />
=== Script example ===<br />
In the example, when the player presses the key M, the block moves to the right.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "MoveTheBlock")<br />
return true<br />
end<br />
<br />
function MoveTheBlock()<br />
Game.MoveBlock("Block0", 1, 0)<br />
end<br />
<br />
== SetBlockCenter(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function gives the center of the block relative to the block position (then, to the level if block position is (0, 0)). The center is used by the function SetBlockPos(), GetBlockPos() and SetBlockRotation(). This function should generally used in the Load() function because the center should not logically be changed (however, you can change it).<br />
<br />
=== Script example ===<br />
In the example, the center of the block is set to the center of the square. Then, when the player press M, the block is placed just under the player.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
<br />
== SetBlockPos(block, x, y) ==<br />
[require Xmoto >= 0.2.0] <br />
=== Explanation ===<br />
This function allows X-Moto to change the position of a block according to its center. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />). Be aware that moving a block can be dangerous: make sure that the player will not be inside the block once you have moved it.<br />
<br />
=== Script example ===<br />
In the example, the center of the block is set to the center of the square. Then, when the player press M, the block is placed just under the player.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
<br />
== GetBlockPos(block) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function gives the position of a given block. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
The example shows how to use this function as a condition. Here, you can move the block under the bike only if you play on the right.<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
x, y = Game.GetPlayerPosition()<br />
bx, by = Game.GetBlockPos("Block0")<br />
if(x > bx)<br />
then<br />
Game.SetBlockPos("Block0", x, y -2.5 -1)<br />
end<br />
end<br />
<br />
== SetBlockRotation(block, angle) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function rotates a block. The block must be dynamic (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
In the example, if the player keeps the key M pressed, the block will rotate.<br />
<br />
a = 0<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("M", "PutTheBlock")<br />
Game.SetBlockCenter("Block0", 7.5, 7.5)<br />
return true<br />
end<br />
<br />
function PutTheBlock()<br />
a = a + math.pi / 256.0<br />
Game.SetBlockRotation("Block0", a)<br />
end<br />
<br />
== SetDynamicEntityRotation(entity, initAngle, radius, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function tells an entity to make circles for a given duration. The current position of the entity on the circle of radius radius is at position initAngle (in rad). The entity will make a circle in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negative arguments allow you to change the behavior of the animation. For example, a negative period will rotate the entity in the negative direction.<br />
<br />
=== Script example ===<br />
The example shows how to easily move the strawberry. InitAngle is set to -PI/2 because the strawberry is placed at the bottom where we want it moves.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityRotation("Strawberry0", -math.pi/2, 2, 500, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicEntitySelfRotation(entity, period, startTime, endTime) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function allows to tell an entity to rotate for a given duration. The entity will rotate in period hundreads. The animation will start in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense.<br />
<br />
=== Script example ===<br />
The example shows how to rotate easily a entity.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntitySelfRotation("Entity2", 1000, 0, 0);<br />
return true;<br />
end;<br />
<br />
== SetDynamicEntityTranslation(entity, fX, fY, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function allows to tell an entity to make translation for a given duration. The translation's length is fX on the X axis and fY on the Y axis. The entity will make the translation in period/2 hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation.<br />
<br />
=== Script example ===<br />
The example shows an example of composed animations.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityTranslation("Strawberry0", 10, 0, 500, 0, 0)<br />
Game.SetDynamicEntityTranslation("Strawberry0", 0, 1, 100, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicEntityNone(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function removed all the animations applicated on an entity.<br />
<br />
=== Script example ===<br />
The example first shows how to ask an entity to make a translation in a first time and then, to make rotations. If the user press the key S, the strawberry stops to move.<br />
<br />
function OnLoad()<br />
Game.SetDynamicEntityTranslation("Strawberry0", -2, 0, 1000, 0, 500)<br />
Game.SetDynamicEntityRotation("Strawberry0", -math.pi/2, 2, 500, 500, 0)<br />
Game.SetKeyHook("S", "StopAnimation")<br />
return true<br />
end<br />
<br />
function StopAnimation()<br />
Game.SetDynamicEntityNone("Strawberry0")<br />
end<br />
<br />
== SetDynamicBlockRotation(block, initAngle, radius, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function allows to tell a block to make circles for a given duration. The current position of the block on the circle of radius radius is at position initAngle (in rad). The block will make a circle in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make move blocks to fast otherwise the bike could go throw the block.<br />
<br />
=== Script example ===<br />
The example shows how to make move easily a block.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockRotation("Block0", -math.pi/2, 2, 500, 0, 0)<br />
return true<br />
end<br />
<br />
== SetDynamicBlockSelfRotation(block, period, startTime, endTime) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function allows to tell a block to rotate for a given duration. The block will rotate in period hundreads. The animation will starts in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. Note that negativ arguments allow to change the behavior of the animation, for example, a negativ period will tell to turn in the other sense. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make move blocks to fast otherwise the bike could go throw the block.<br />
<br />
=== Script example ===<br />
The example shows how to rotate easily a block.<br />
<br />
function OnLoad()<br />
Game.SetBlockCenter("Block2", -2.5, -19.0);<br />
Game.SetDynamicBlockSelfRotation("Block2", 1000, 0, 0);<br />
return true;<br />
end;<br />
<br />
== SetDynamicBlockTranslation(block, fX, fY, period, startTime, endTime) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
<p>This function tells a block to make a translation for a given duration. A translation is a looped movement from one point to another, and back. The translation's length is fX on the X axis and fY on the Y axis. The animation will start in startTime hundredths and will finish in endTime hundredths, so the duration is endTime-startTime/100 seconds. An endTime of 0 means an infinite animation. Note that you can compose rotations and translations. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />). Don't make blocks move too fast otherwise the bike could go through the block.</p><br />
<br />
<p>block: Defines which Block should move<br><br />
fX: Defines where on the X-Axis the Block should move<br><br />
fY: Defines where on the Y-Axis the Block should move<br><br />
period: Defines how long it takes the Block to move back to the starting point<br><br />
startTime: Defines when the translation should start<br><br />
endTime: Defines when the translation should end</p><br />
<br />
In order to make replay files as small as possible, you should use Translation instead of the MoveBlock function. An example on how to convert a MoveBlock function into a Translation is given below.<br />
<br />
=== Script example ===<br />
In this example, the block makes an infinite movement: It moves from its originating point (0,0) to (10,1) within 750ms, and then back in another 750ms.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 10, 1, 1500, 0, 0)<br />
return true<br />
end<br />
<br />
Example on how to convert a MoveBlock function into a Translation (see above):<br />
<br />
function Tick()<br />
Game.MoveBlock("Block0", 0.5,0)<br />
return true<br />
end<br />
<br />
Block0 moves forever to the right: 0.5px every 1/100s<br />
So it moves at a speed of 300m/60s<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 300, 0, 12000, 0, 6000)<br />
return true<br />
end<br />
<br />
This is the MoveBlock function in the translation-version. <br />
It moves 300m to the right and 300m back to the left in 12000ms. endTime is set to 12000/2=6000, so that the translation stops as soon as Block0 reaches (300,0)<br />
<br />
== SetDynamicBlockNone(block) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
This function stops all the animation applied on the block. The block must be set dynamic so that it works (modify the level to get <position x="0" y="0" dynamic="true" />).<br />
<br />
=== Script example ===<br />
In the example, the block will move until the player presses the key S.<br />
<br />
function OnLoad()<br />
Game.SetDynamicBlockTranslation("Block0", 10, 1, 1500, 0, 0)<br />
Game.SetKeyHook("S", "StopAnimation")<br />
return true<br />
end<br />
<br />
function StopAnimation()<br />
Game.SetDynamicBlockNone("Block0")<br />
end<br />
<br />
== CameraZoom(z) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
In some levels, you may want that the camera is a bit more far from the player. Use this function to change the camera zoom.<br />
<br />
=== Script example ===<br />
The example shows how a different zoom can be used to play a level.<br />
<br />
function OnLoad()<br />
Game.CameraZoom(-0.05)<br />
return true<br />
end<br />
<br />
== CameraMove(x, y) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
For some particular levels, you may want the camera to be moved. Use this function to do that.<br />
<br />
=== Script example ===<br />
The example shows how you can focus a level on the part above the player.<br />
<br />
function OnLoad()<br />
Game.CameraMove(0, 3)<br />
return true<br />
end<br />
<br />
== CameraRotate(angle) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera be rotated. Use this function to do that.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.CameraRotate(math.pi / 4.0);<br />
return true<br />
end<br />
<br />
== CameraAdaptToGravity() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera be rotated. Use this function to do that in function of the gravity.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0.0, 9.81)<br />
Game.CameraAdaptToGravity()<br />
return true<br />
end<br />
<br />
== SetCameraRotationSpeed(z) ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
For some particular levels, you may want that the camera beeing rotated does that at a certain speed. With this function you can make it rotate either very slow ( z = 0.1 ) or extremely fast ( z = 7.2 ). The values are given in RAD, so they can reach from 0 to 2 * PI.<br />
<br />
=== Script example ===<br />
The example shows how you use this function.<br />
<br />
function OnLoad()<br />
Game.SetGravity(0.0, 9.81)<br />
Game.SetCameraRotationSpeed(0.2)<br />
Game.CameraAdaptToGravity()<br />
return true<br />
end<br />
<br />
== GetEntityRadius(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
Return the radius of an entity. This radius is used for collision. You can use this function for your own collision or anything else.<br />
<br />
=== Script example ===<br />
The example shows you the radius of the strawberry.<br />
<br />
function OnLoad()<br />
Game.Message("Radius of the strawberry : "..Game.GetEntityRadius("Strawberry0"))<br />
return true<br />
end<br />
<br />
== IsEntityTouched(entity) ==<br />
[require Xmoto >= 0.2.0]<br />
=== Explanation ===<br />
There is a function called when you touch an entity. But sometimes you want to know when you don't touch an entity. Use this function.<br />
<br />
=== Script example ===<br />
The example shows how to make an action when the player is not touching an entity.<br />
<br />
g = -9.81<br />
<br />
function OnLoad()<br />
Game.Message("Gravity is increasing while you are not touching the snowman")<br />
return true<br />
end<br />
<br />
function Tick()<br />
if(Game.IsEntityTouched("SnowMan0") == 0)<br />
then<br />
g = g - 0.03<br />
Game.SetGravity(0, g);<br />
end<br />
return true<br />
end<br />
<br />
==Game.AddPenaltyTime(time) ==<br />
[require Xmoto >= 0.5.0]<br />
=== Explanation ===<br />
Increment the value of the time counter to make a penalty.<br />
<br />
=== Script example ===<br />
In the following example, the time will be increased of 5 seconds if the player enters in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.AddPenaltyTime(5.0)<br />
end<br />
<br />
== KillPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the players die. It's interesting if you want the players be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
In the following example, the player will die when he will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillPlayer()<br />
end<br />
<br />
== KillAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player dies. It's interesting if you want the player be killed by an enemy for example.<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.KillAPlayer(0)<br />
return true<br />
end<br />
<br />
== KillEntity(entityID) ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, the entity entityID will be deleted. The entity can be a strawberry or any sprite.<br />
<br />
=== Script example ===<br />
In the following example, the strawberry will be deleted when the player will enter in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.KillEntity("Strawberry0")<br />
end<br />
<br />
== WinPlayer() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
If you call this function, all players win the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
In the following example, the player win on entering in the zone Zone0.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.WinPlayer()<br />
end<br />
<br />
== WinAPlayer(player) ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
If you call this function, a player wins the game (even if there are remaining strawberries).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.WinAPlayer(0)<br />
return true<br />
end<br />
<br />
== RemainingStrawberries() ==<br />
[require Xmoto >= 0.2.1]<br />
=== Explanation ===<br />
This function returns the number of strawberries remaining in the level.<br />
<br />
=== Script example ===<br />
In the following example, when the player will enter in the zone Zone0, the number of remaining strawberries is displayed.<br />
<br />
Zone0 = {}<br />
<br />
function Zone0.OnEnter()<br />
Game.Message(Game.RemainingStrawberries())<br />
end<br />
<br />
== NumberOfPlayers() ==<br />
[require Xmoto >= 0.3.0]<br />
=== Explanation ===<br />
This function returns the number of players (dead or in live) in the level<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
Game.Message(Game.NumberOfPlayers().." players")<br />
return true<br />
end<br />
<br />
== AddForceToPlayer(forceX, forceY, startTime, endTime, player) ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
This function apply an external force on the player player. The force will apply from startTime to endTime or will be infinite if endTime is 0. startTime and endTime are expressed in hundreaths and are relativ to the call function time. The force applied will be of (forceX, forceY). Application point is the center of the biker. In the example, a force will be applied to all players from time 5 to 10 seconds. Force is expressed in newton, mg/s-2 (meter * gramm / (seconds * seconds)).<br />
<br />
=== Script example ===<br />
function OnLoad()<br />
for i=0,Game.NumberOfPlayers()-1 do<br />
Game.Message("Kicking player "..(i+1))<br />
Game.AddForceToPlayer(0, 1000, 500, 1000, i)<br />
end<br />
<br />
return true<br />
end<br />
<br />
== PlayAudio("NameOfSound") ==<br />
[require Xmoto >= 0.4.2]<br />
=== Explanation ===<br />
Using this function you can play a sound effect (or a music). The parameter is the name of the sound, which is defined in the actually used theme file.<br />
In the following example, there must be a zone named "Zone0", As soon as you enter the zone, the sound effect is played:<br />
<br />
=== Script example ===<br />
Zone0 = {}<br />
function Zone0.OnEnter()<br />
Game.PlaySound("ring");<br />
end<br />
<br />
<br />
<br />
== SetPhysicsBlockSelfRotation (block, torque, startTime, endTime) ==<br />
[require Xmoto >= 0.5.0]<br />
=== Explanation ===<br />
This function allows to tell a block to rotate for a given duration. The rotation will be performed by applying forces (torque) on the block (if possible). The block will rotate in period hundreads. The forces application will start in startTime hundreadths and will finish in endTime hundreadths, so, the duration time is endTime-startTime/100 seconds. An endTime of 0 means an infinite application. Note that negativ arguments allow to change the behavior of the forces, for example, a negativ torque will tell to turn in the other sense. <br />
<br />
=== Script example ===</div>Nadenislamarre