https://wiki.xmoto.tuxfamily.org/api.php?action=feedcontributions&user=Googlebotti&feedformat=atomX-Moto - User contributions [en]2024-03-28T12:08:42ZUser contributionsMediaWiki 1.28.2https://wiki.xmoto.tuxfamily.org/index.php?title=Getting_svn_of_inksmoto_(svg2lvl)_for_windows_using_Tortoise_SVN&diff=4560Getting svn of inksmoto (svg2lvl) for windows using Tortoise SVN2010-04-01T10:26:19Z<p>Googlebotti: /* Step 2. Checkout */</p>
<hr />
<div>== General ==<br />
There is another way to get it too, this one illustartes the way to get it with Tortoise SVN so that you can easily update to the newest version.<br />
== Things needed ==<br />
You need:<br />
* Microsoft Windows<br />
* Tortoise SVN (or another svn program, I like tortoise best)<br />
* patience... (not really)<br />
* Latest official inksmoto and inkscape installed<br />
<br />
== Step 1. Get Tortoise SVN ==<br />
Download the installer here: [http://tortoisesvn.net/downloads Tortoise SVN] Install it.<br />
== Step 2. Checkout ==<br />
Make sure that you remove the old inksmoto files from the extensions folder before proceeding.<br />
Go to your Inkscape installation directory and there to the share folder, for example:<br />
*"C:\Program Files\Inkscape\share\"<br />
Then Right-Click the extensions folder to see the context menu of windows, you should see the tortoise svn and a button which says: "SVN Check out...".<br />
* URL of repository: svn://svn.tuxfamily.org/svnroot/xmoto/svg2lvl/trunk/extensions/<br />
* Checkout directory: [install dir]\share\extensions<br />
Click Ok. Wait... It will download all the files needed and then you are done. Just open inkscape and voila.<br />
<br />
== Step 3. Testing ==<br />
Open Inkscape and begin testing and developing. voila!</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Getting_svn_of_inksmoto_(svg2lvl)_for_windows_using_Tortoise_SVN&diff=4559Getting svn of inksmoto (svg2lvl) for windows using Tortoise SVN2010-04-01T10:23:59Z<p>Googlebotti: /* Things needed */</p>
<hr />
<div>== General ==<br />
There is another way to get it too, this one illustartes the way to get it with Tortoise SVN so that you can easily update to the newest version.<br />
== Things needed ==<br />
You need:<br />
* Microsoft Windows<br />
* Tortoise SVN (or another svn program, I like tortoise best)<br />
* patience... (not really)<br />
* Latest official inksmoto and inkscape installed<br />
<br />
== Step 1. Get Tortoise SVN ==<br />
Download the installer here: [http://tortoisesvn.net/downloads Tortoise SVN] Install it.<br />
== Step 2. Checkout ==<br />
Go to your Inkscape installation directory and there to the share folder, for example:<br />
*"C:\Program Files\Inkscape\share\"<br />
Then Right-Click the extensions folder to see the context menu of windows, you should see the tortoise svn and a button which says: "SVN Check out...".<br />
* URL of repository: svn://svn.tuxfamily.org/svnroot/xmoto/svg2lvl/trunk/extensions/<br />
* Checkout directory: [install dir]\share\extensions<br />
Click Ok.<br />
== Step 3. Testing ==<br />
Open Inkscape and begin testing and developing. voila!</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Network_Rules&diff=4547Network Rules2010-02-24T18:48:10Z<p>Googlebotti: </p>
<hr />
<div>The X-Moto network should be a safe and pleasant experience available to everyone. For this reason I am suggesting a few simple rules that when followed allow a better view of the game for everyone.<br />
<br />
==Rules==<br />
<br />
* Keep language as english only, (unless of course there is no one else online other than you). See list of other languages at the bottom. This is because english is accepted as a universal language (most people must learn it), this makes communication easier.<br />
<br />
* Keep obscenities at a low level. After all we wouldn't like young kids asking there parents what those words mean^^<br />
<br />
* Do not ask for personal infomation (age, nationality and stuff is fine, but, I really don't care if your called Ben Dover from Big Rock in America :P)<br />
<br />
* Respect earns respect<br />
<br />
* Act maturely at all times, if they start it, don't respond, or say something like "I'm glad you think that", or "I lvoe you to". This help lower arguaments<br />
<br />
To enforce rules like this there are a number of admins in place, who may ban or kick on occassions.<br />
<br />
===Language ports===<br />
<br />
* French -- 4131<br />
* English - 9000<br />
<br />
Know any others? Add them here!</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4527Basics of Scripting2010-01-07T18:17:13Z<p>Googlebotti: /* General */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player does somethingorother...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make a explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
Just paste the script and edit the options. :)<br />
<br />
== How-to make a trainer script? ==<br />
Loads of people have been asking about this, it is rather simple. All you need is:<br />
* a keyhook<br />
* an entity (like a sprite)<br />
and here it is:<br />
function OnLoad()<br />
Game.SetKeyHook("1","trainer1") -- create the keyhook on load of the level<br />
return true -- without this x-moto crashes<br />
end<br />
<br />
function trainer1()<br />
x,y=Game.GetEntityPos("entity1") --get position of the entity<br />
--throw the player to the position we just got<br />
Game.SetPlayerPosition(x,y,0) -- the 0 can be set to 1 if you want the player to face right after teleport<br />
end<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave in unwanted ways or fix crashes. It is a good idea to '''comment lines which you think makes the script crash''' and then start uncommenting them line by line until you find the crashing line, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''', otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then, to find the exact line, '''count''' the script's lines '''ignoring all empty lines''' and if you have joined lines with ";" you must break them, that way you should be able to find the correct line, since the Lua script parser removes empty lines before executing the script. '''This method does not always work as the parser does more than just removes empty lines.'''<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Level_FAQ&diff=4495Level FAQ2009-11-03T18:08:54Z<p>Googlebotti: /* 6. But ELMA is so much better than Xmoto! */</p>
<hr />
<div>=Frequently asked Questions=<br />
<br />
===1. How can I create my own Level?===<br />
Its simple: First, download the newest release of the Inksmoto level editor on the main page.<br>Second, read the '''[[How_to_create_smooth_levels_using_Inkscape|wiki tutorials]]''' to learn how to use it.<br>Third, read the guide '''[[About_good_level_design| about good level design]]''', to learn about our quality standards, and why not every first try level gets available for download.<br><br />
<br />
===2. It doesnt work, can you help me?===<br />
Generally you should make sure that the problem isn't caused by anything which is widely described in the [[Main_Page|wiki]] or already discussed in the [http://forum.xmoto.tuxfamily.org/ forum]!<br>If you still have no idea whats the cause, come to our IRC channel to ask for help. Usually you can meet some insiders there that are willing to help.<br>Provide all necessary information such as software versions, logfiles and error messages!<br />
<br />
===3. Your level standards suck! For Elma there are 3,5 Million Levels available and not just 2000!===<br />
Regardless of quantitive considerations, we decided to have some quality standards, which make it '''possible to enjoy the game for all kinds of players''': Beginners, Average and Casual Players, as well as XMoto Professionals. Its not enough doing a level just for some pro players, who dont like Graphics or to upload levels just to have an own level in the game.<br><br />
There are graphically poor levels in the game, which is mostly caused by the fact, that XMoto exists for many years now, and the graphical engine wasn't as far developed in the old days as it is today. So there's no need to emphasize the fact that there are poor levels, because we know! And we don't care about Elma!<br />
<br />
===4. But its so hard to make XMoto levels, that meet your requirements!===<br />
Well, no one said it would be easy! Some gameplay experience, artistic and design skills are required to be able to make a good level. <br />
<br />
===5. Can Elma levels be used in XMoto?===<br />
Since XMoto and Elma use different physics engines, and another level format as well, it is '''not possible''' to use Elma levels in XMoto. Anyway if you feel that an Elma level should be available for XMoto, you could do a GPL remake, which applies to the different physics and needs, but interprets the gameplay of the original level.<br />
<br />
===6. But ELMA is so much better than XMoto!===<br />
Well, who prefers Elma plays Elma, who likes XMoto plays XMoto. Whining about level or gameplay issues serves no purpose for any developper or level admin. XMoto is XMoto is XMoto.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Level_FAQ&diff=4494Level FAQ2009-11-03T18:08:46Z<p>Googlebotti: /* 5. Can Elma levels be used in xmoto? */</p>
<hr />
<div>=Frequently asked Questions=<br />
<br />
===1. How can I create my own Level?===<br />
Its simple: First, download the newest release of the Inksmoto level editor on the main page.<br>Second, read the '''[[How_to_create_smooth_levels_using_Inkscape|wiki tutorials]]''' to learn how to use it.<br>Third, read the guide '''[[About_good_level_design| about good level design]]''', to learn about our quality standards, and why not every first try level gets available for download.<br><br />
<br />
===2. It doesnt work, can you help me?===<br />
Generally you should make sure that the problem isn't caused by anything which is widely described in the [[Main_Page|wiki]] or already discussed in the [http://forum.xmoto.tuxfamily.org/ forum]!<br>If you still have no idea whats the cause, come to our IRC channel to ask for help. Usually you can meet some insiders there that are willing to help.<br>Provide all necessary information such as software versions, logfiles and error messages!<br />
<br />
===3. Your level standards suck! For Elma there are 3,5 Million Levels available and not just 2000!===<br />
Regardless of quantitive considerations, we decided to have some quality standards, which make it '''possible to enjoy the game for all kinds of players''': Beginners, Average and Casual Players, as well as XMoto Professionals. Its not enough doing a level just for some pro players, who dont like Graphics or to upload levels just to have an own level in the game.<br><br />
There are graphically poor levels in the game, which is mostly caused by the fact, that XMoto exists for many years now, and the graphical engine wasn't as far developed in the old days as it is today. So there's no need to emphasize the fact that there are poor levels, because we know! And we don't care about Elma!<br />
<br />
===4. But its so hard to make XMoto levels, that meet your requirements!===<br />
Well, no one said it would be easy! Some gameplay experience, artistic and design skills are required to be able to make a good level. <br />
<br />
===5. Can Elma levels be used in XMoto?===<br />
Since XMoto and Elma use different physics engines, and another level format as well, it is '''not possible''' to use Elma levels in XMoto. Anyway if you feel that an Elma level should be available for XMoto, you could do a GPL remake, which applies to the different physics and needs, but interprets the gameplay of the original level.<br />
<br />
===6. But ELMA is so much better than Xmoto!===<br />
Well, who prefers Elma plays Elma, who likes XMoto plays XMoto. Whining about level or gameplay issues serves no purpose for any developper or level admin. XMoto is XMoto is XMoto.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Level_FAQ&diff=4493Level FAQ2009-11-03T18:07:42Z<p>Googlebotti: /* 3. Your level standards suck! For Elma there are 3,5 Million Levels available and not just 2000! */</p>
<hr />
<div>=Frequently asked Questions=<br />
<br />
===1. How can I create my own Level?===<br />
Its simple: First, download the newest release of the Inksmoto level editor on the main page.<br>Second, read the '''[[How_to_create_smooth_levels_using_Inkscape|wiki tutorials]]''' to learn how to use it.<br>Third, read the guide '''[[About_good_level_design| about good level design]]''', to learn about our quality standards, and why not every first try level gets available for download.<br><br />
<br />
===2. It doesnt work, can you help me?===<br />
Generally you should make sure that the problem isn't caused by anything which is widely described in the [[Main_Page|wiki]] or already discussed in the [http://forum.xmoto.tuxfamily.org/ forum]!<br>If you still have no idea whats the cause, come to our IRC channel to ask for help. Usually you can meet some insiders there that are willing to help.<br>Provide all necessary information such as software versions, logfiles and error messages!<br />
<br />
===3. Your level standards suck! For Elma there are 3,5 Million Levels available and not just 2000!===<br />
Regardless of quantitive considerations, we decided to have some quality standards, which make it '''possible to enjoy the game for all kinds of players''': Beginners, Average and Casual Players, as well as XMoto Professionals. Its not enough doing a level just for some pro players, who dont like Graphics or to upload levels just to have an own level in the game.<br><br />
There are graphically poor levels in the game, which is mostly caused by the fact, that XMoto exists for many years now, and the graphical engine wasn't as far developed in the old days as it is today. So there's no need to emphasize the fact that there are poor levels, because we know! And we don't care about Elma!<br />
<br />
===4. But its so hard to make XMoto levels, that meet your requirements!===<br />
Well, no one said it would be easy! Some gameplay experience, artistic and design skills are required to be able to make a good level. <br />
<br />
===5. Can Elma levels be used in xmoto?===<br />
Since XMoto and Elma use different physics engines, and another level format as well, it is '''not possible''' to use Elma levels in XMoto. Anyway if you feel that an Elma level should be available for XMoto, you could do a GPL remake, which applies to the different physics and needs, but interprets the gameplay of the original level.<br />
<br />
===6. But ELMA is so much better than Xmoto!===<br />
Well, who prefers Elma plays Elma, who likes XMoto plays XMoto. Whining about level or gameplay issues serves no purpose for any developper or level admin. XMoto is XMoto is XMoto.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Level_FAQ&diff=4492Level FAQ2009-11-03T18:07:23Z<p>Googlebotti: /* 5. Can Elma levels be used in xmoto? */</p>
<hr />
<div>=Frequently asked Questions=<br />
<br />
===1. How can I create my own Level?===<br />
Its simple: First, download the newest release of the Inksmoto level editor on the main page.<br>Second, read the '''[[How_to_create_smooth_levels_using_Inkscape|wiki tutorials]]''' to learn how to use it.<br>Third, read the guide '''[[About_good_level_design| about good level design]]''', to learn about our quality standards, and why not every first try level gets available for download.<br><br />
<br />
===2. It doesnt work, can you help me?===<br />
Generally you should make sure that the problem isn't caused by anything which is widely described in the [[Main_Page|wiki]] or already discussed in the [http://forum.xmoto.tuxfamily.org/ forum]!<br>If you still have no idea whats the cause, come to our IRC channel to ask for help. Usually you can meet some insiders there that are willing to help.<br>Provide all necessary information such as software versions, logfiles and error messages!<br />
<br />
===3. Your level standards suck! For Elma there are 3,5 Million Levels available and not just 2000!===<br />
Regardless of quantitive considerations, we decided to have some quality standards, which make it possible to enjoy the game for all kinds of players: Beginners, Average and Casual Players, as well as XMoto Professionals. Its not enough doing a level just for some pro players, who dont like Graphics or to upload levels just to have an own level in the game.<br><br />
There are graphically poor levels in the game, which is mostly caused by the fact, that XMoto exists for many years now, and the graphical engine wasn't as far developed in the old days as it is today. So there's no need to emphasize the fact that there are poor levels, because we know! And we don't care about Elma!<br />
<br />
===4. But its so hard to make XMoto levels, that meet your requirements!===<br />
Well, no one said it would be easy! Some gameplay experience, artistic and design skills are required to be able to make a good level. <br />
<br />
===5. Can Elma levels be used in xmoto?===<br />
Since XMoto and Elma use different physics engines, and another level format as well, it is '''not possible''' to use Elma levels in XMoto. Anyway if you feel that an Elma level should be available for XMoto, you could do a GPL remake, which applies to the different physics and needs, but interprets the gameplay of the original level.<br />
<br />
===6. But ELMA is so much better than Xmoto!===<br />
Well, who prefers Elma plays Elma, who likes XMoto plays XMoto. Whining about level or gameplay issues serves no purpose for any developper or level admin. XMoto is XMoto is XMoto.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Level_FAQ&diff=4491Level FAQ2009-11-03T18:07:06Z<p>Googlebotti: /* 5. Can Elma levels be used in xmoto? */</p>
<hr />
<div>=Frequently asked Questions=<br />
<br />
===1. How can I create my own Level?===<br />
Its simple: First, download the newest release of the Inksmoto level editor on the main page.<br>Second, read the '''[[How_to_create_smooth_levels_using_Inkscape|wiki tutorials]]''' to learn how to use it.<br>Third, read the guide '''[[About_good_level_design| about good level design]]''', to learn about our quality standards, and why not every first try level gets available for download.<br><br />
<br />
===2. It doesnt work, can you help me?===<br />
Generally you should make sure that the problem isn't caused by anything which is widely described in the [[Main_Page|wiki]] or already discussed in the [http://forum.xmoto.tuxfamily.org/ forum]!<br>If you still have no idea whats the cause, come to our IRC channel to ask for help. Usually you can meet some insiders there that are willing to help.<br>Provide all necessary information such as software versions, logfiles and error messages!<br />
<br />
===3. Your level standards suck! For Elma there are 3,5 Million Levels available and not just 2000!===<br />
Regardless of quantitive considerations, we decided to have some quality standards, which make it possible to enjoy the game for all kinds of players: Beginners, Average and Casual Players, as well as XMoto Professionals. Its not enough doing a level just for some pro players, who dont like Graphics or to upload levels just to have an own level in the game.<br><br />
There are graphically poor levels in the game, which is mostly caused by the fact, that XMoto exists for many years now, and the graphical engine wasn't as far developed in the old days as it is today. So there's no need to emphasize the fact that there are poor levels, because we know! And we don't care about Elma!<br />
<br />
===4. But its so hard to make XMoto levels, that meet your requirements!===<br />
Well, no one said it would be easy! Some gameplay experience, artistic and design skills are required to be able to make a good level. <br />
<br />
===5. Can Elma levels be used in xmoto?===<br />
Since XMoto and Elma use different physics engines, and another level format as well, it is '''not''' possible to use Elma levels in XMoto. Anyway if you feel that an Elma level should be available for XMoto, you could do a GPL remake, which applies to the different physics and needs, but interprets the gameplay of the original level.<br />
<br />
===6. But ELMA is so much better than Xmoto!===<br />
Well, who prefers Elma plays Elma, who likes XMoto plays XMoto. Whining about level or gameplay issues serves no purpose for any developper or level admin. XMoto is XMoto is XMoto.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Level_FAQ&diff=4490Level FAQ2009-11-03T18:05:08Z<p>Googlebotti: /* 2. It doesnt work, can you help me? */</p>
<hr />
<div>=Frequently asked Questions=<br />
<br />
===1. How can I create my own Level?===<br />
Its simple: First, download the newest release of the Inksmoto level editor on the main page.<br>Second, read the '''[[How_to_create_smooth_levels_using_Inkscape|wiki tutorials]]''' to learn how to use it.<br>Third, read the guide '''[[About_good_level_design| about good level design]]''', to learn about our quality standards, and why not every first try level gets available for download.<br><br />
<br />
===2. It doesnt work, can you help me?===<br />
Generally you should make sure that the problem isn't caused by anything which is widely described in the [[Main_Page|wiki]] or already discussed in the [http://forum.xmoto.tuxfamily.org/ forum]!<br>If you still have no idea whats the cause, come to our IRC channel to ask for help. Usually you can meet some insiders there that are willing to help.<br>Provide all necessary information such as software versions, logfiles and error messages!<br />
<br />
===3. Your level standards suck! For Elma there are 3,5 Million Levels available and not just 2000!===<br />
Regardless of quantitive considerations, we decided to have some quality standards, which make it possible to enjoy the game for all kinds of players: Beginners, Average and Casual Players, as well as XMoto Professionals. Its not enough doing a level just for some pro players, who dont like Graphics or to upload levels just to have an own level in the game.<br><br />
There are graphically poor levels in the game, which is mostly caused by the fact, that XMoto exists for many years now, and the graphical engine wasn't as far developed in the old days as it is today. So there's no need to emphasize the fact that there are poor levels, because we know! And we don't care about Elma!<br />
<br />
===4. But its so hard to make XMoto levels, that meet your requirements!===<br />
Well, no one said it would be easy! Some gameplay experience, artistic and design skills are required to be able to make a good level. <br />
<br />
===5. Can Elma levels be used in xmoto?===<br />
Since XMoto and Elma use different physics engines, and another level format as well, it is NOT possible to use Elma levels in XMoto. Anyway if you feel that an Elma level should be available for XMoto, you could do a GPL remake, which applies to the different physics and needs, but interprets the gameplay of the original level.<br />
<br />
===6. But ELMA is so much better than Xmoto!===<br />
Well, who prefers Elma plays Elma, who likes XMoto plays XMoto. Whining about level or gameplay issues serves no purpose for any developper or level admin. XMoto is XMoto is XMoto.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Level_FAQ&diff=4489Level FAQ2009-11-03T18:01:20Z<p>Googlebotti: /* 1. How can I create my own Level? */</p>
<hr />
<div>=Frequently asked Questions=<br />
<br />
===1. How can I create my own Level?===<br />
Its simple: First, download the newest release of the Inksmoto level editor on the main page.<br>Second, read the '''[[How_to_create_smooth_levels_using_Inkscape|wiki tutorials]]''' to learn how to use it.<br>Third, read the guide '''[[About_good_level_design| about good level design]]''', to learn about our quality standards, and why not every first try level gets available for download.<br><br />
<br />
===2. It doesnt work, can you help me?===<br />
Generally you should make sure that the problem isn't caused by anything wich is widely described in the WIKI or already discussed in the FORUM!<br>If you still have no idea whats the cause, come to our IRC channel to ask for help. Usually you can meet some insiders there that are willing to help.<br>Provide all necessary information like versions of used software, logfiles, output information!<br />
<br />
===3. Your level standards suck! For Elma there are 3,5 Million Levels available and not just 2000!===<br />
Regardless of quantitive considerations, we decided to have some quality standards, which make it possible to enjoy the game for all kinds of players: Beginners, Average and Casual Players, as well as XMoto Professionals. Its not enough doing a level just for some pro players, who dont like Graphics or to upload levels just to have an own level in the game.<br><br />
There are graphically poor levels in the game, which is mostly caused by the fact, that XMoto exists for many years now, and the graphical engine wasn't as far developed in the old days as it is today. So there's no need to emphasize the fact that there are poor levels, because we know! And we don't care about Elma!<br />
<br />
===4. But its so hard to make XMoto levels, that meet your requirements!===<br />
Well, no one said it would be easy! Some gameplay experience, artistic and design skills are required to be able to make a good level. <br />
<br />
===5. Can Elma levels be used in xmoto?===<br />
Since XMoto and Elma use different physics engines, and another level format as well, it is NOT possible to use Elma levels in XMoto. Anyway if you feel that an Elma level should be available for XMoto, you could do a GPL remake, which applies to the different physics and needs, but interprets the gameplay of the original level.<br />
<br />
===6. But ELMA is so much better than Xmoto!===<br />
Well, who prefers Elma plays Elma, who likes XMoto plays XMoto. Whining about level or gameplay issues serves no purpose for any developper or level admin. XMoto is XMoto is XMoto.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Inksmoto-0.6.0&diff=4430Inksmoto-0.6.02009-08-23T00:45:54Z<p>Googlebotti: /* Get the .lvl in order to upload it */</p>
<hr />
<div>=About=<br />
The Inksmoto level editor is implemented as an extension to [http://www.inkscape.org/ Inkscape], an Open Source vector graphics editor.<br />
<br />
Svg of levels build with the 0.4.1 version of Inksmoto are not compatible with this release.<br />
<br />
Even if the application windows changed, there's still plenty of stuffs from the 0.4.x and 0.5.x tutorials which applies to the 0.6.0 version, check them out: <br />
*[[Inkscape-0.4.0|Inksmoto 0.4.1 tutorial]]<br />
*[[Inksmoto-0.5.0|Inksmoto 0.5.1 tutorial]]<br />
<br />
=Installation=<br />
<br />
=Tutorial: First steps=<br />
<br />
This part of the tutorial learns the basics to be able to create a level.<br />
<br />
==Quick look at inkscape==<br />
<br />
[[Image:Inksmoto_060_01.png]]<br />
<br />
Here is the list of useful tools from Inkscape to create Xmoto levels:<br />
# The selection tool<br />
# The path editing tool<br />
# The sculpting tool<br />
# The zoom in/out tool<br />
# The rectangle tool<br />
# The circle tool<br />
# The star tool<br />
# The hand draw tool<br />
# The bezier curves draw tool<br />
# The Xmoto properties menu<br />
<br />
To learn how to use Inkscape you can use the official Inkscape tutorials:<br />
[[Image:Inkscape2.png]]<br />
<br />
You can also get tutorials on YouTube.<br />
<br />
==The Xmoto extensions==<br />
<br />
The Xmoto extensions from the ''Effects'' menu allows you to set Xmoto properties to Inkscape objects in the drawing.<br />
<br />
Here is a description of the different entries of the Xmoto menu:<br />
*'''Blocks'''<br />
**''Change Block Properties'': Change the properties of the selected blocks.<br />
**''Change Block Texture'': Change the texture and edge effects of the selected blocks.<br />
*'''Entities'''<br />
**''Strawberry'': Convert the selected shapes into a strawberry.<br />
**''End of level'': Convert the selected shapes into a end of the level.<br />
**''Particle Source'': Convert the selected shapes into a particle source (fire or smoke).<br />
**''Player Start'': Convert the selected shapes into the start position of the player.<br />
**''Sprite'': Convert the selected shapes into a sprite (with many parameters for the sprite).<br />
**''Wrecker'': Convert the selected shapes into a wrecker.<br />
*'''Joint'''<br />
**''Add Pin Joint'': add a pin joint between two physical blocks.<br />
**''Add Pivot Joint'': add a pivot joint between to physical blocks.<br />
**''Jointed Line...'': create a line of jointed blocks<br />
*'''Level'''<br />
**''Set layers properties'': Set which layers are for background and what are their scrolling parameters.<br />
**''Set sky properties'': Change the sky of the level.<br />
**''Set level properties'': Mandatory options for the level, like its name and id.<br />
**''Set other level properties'': Allow sprite replacement of the /strawberry/wrecker/end of level/. Add a music to the level.<br />
*'''Other'''<br />
**''Install keyboard shortcuts'': Install the Inksmoto specific shortcuts.<br />
**''Inksmoto tutorial'': Display the link of this tutorial on the wiki.<br />
**''Launch level in X-Moto'': Launch the level in Xmoto.<br />
**''Show the object informations'': Show the Xmoto properties of the selected shapes.<br />
**''Get new textures and sprites'': Download new textures and sprites from the Internet.<br />
**''Recreate last.lvl'': Recreate the last.lvl level to reload it into Xmoto.<br />
**''Copy'': Copy the xmoto properties of an object.<br />
**''Paste'': Paste the xmoto properties stored into the selected objects.<br />
**''Change id'': Change the id of an element (mandatory use for entities).<br />
**''Begin recording a trace session'': For unittesting.<br />
**''End recording a trace session'': For unittesting (the generated tests are in ~/.inkscape/extensions/cur_tests).<br />
*'''Zones'''<br />
**''Convert into Zone'': Convert the selected shapes into zones (currently, only rectangular zones are used).<br />
<br />
==Install the Inksmoto shortcuts==<br />
<br />
You should begin by installing the Inksmoto specific shortcuts.<br />
Use the menu entry ''Effects->X-moto->Other->Install keyboard shortcuts''.<br />
<br />
Then restart Inkscape to enable them.<br />
<br />
The shortcuts are:<br />
*"t": change texture of the selected blocks<br />
*"b": change properties of the selected blocks<br />
*"p": add a pin joint between two physical blocks<br />
*"o": add a pivot joint between two physical blocks<br />
*"y": change the selected objects into strawberry<br />
*"s": change properties of the selected sprites<br />
*"z": change the selected objects into zone<br />
*"w": change the selected objects into wrecker<br />
*"u": change the selected objects into a particle source<br />
*"r": change the selected objects into the player start<br />
*"e": change the selected objects into the end of level<br />
*"a": set layers properties<br />
*"q": set level properties<br />
*"h": set other level properties<br />
*"k": set sky properties<br />
*"x": launch the .lvl into Xmoto<br />
*"l": recreate last.lvl into the home directory (in .inkscape/extensions/)<br />
*"c": copy the xmoto properties of an object<br />
*"v": paste the xmoto properties stored in the selected objects<br />
*"i": change the id of an object<br />
<br />
==Drawing a simple level==<br />
<br />
Let's draw a simple level using only the Rectangle, Circle and Star tools.<br />
<br />
First, set the zoom of Inkscape to 100% (defaulted to 35% when you create a new svg), then draw your level.<br />
<br />
Here's is a simple level drawn using the Star tool and the Rectangle tool for the shapes and the Circle tool for the two little circles:<br />
[[Image:inksmoto_050_02.png]]<br />
<br />
==Set level properties==<br />
<br />
Now that the shapes of the level are drawn, we have to assign them Xmoto properties. For example, we want some shapes to be solid blocks, some others to be background blocks, change their texture...<br />
<br />
===Example===<br />
<br />
To change solid blocks texture, select them, then go to the Xmoto effect menu and use the menu entry ''Effects->X-moto->Blocks->Change Block Texture'' (or press 't').<br />
<br />
[[Image:inksmoto_050_03.png]]<br />
<br />
The ''Block textures'' window opens.<br />
<br />
[[Image:inksmoto_050_04.png]]<br />
<br />
Click on the white thumbnail to select the texture we want. The ''Texture Selection'' window pops up:<br />
<br />
[[Image:inksmoto_050_05.png]]<br />
<br />
Click on the texture wanted for the blocks. Now the ''Block textures'' window displays the right texture:<br />
<br />
[[Image:inksmoto_050_06.png]]<br />
<br />
Press ''OK''. The texture is then displayed in Inkscape:<br />
<br />
[[Image:inksmoto_050_07.png]]<br />
<br />
Repeat the same procedure to change the texture for the three other blocks.<br />
<br />
Now, we want to set them as background blocks. Select them, and use this menu entry: ''Effects->X-moto->Blocks->Change Block Properties'' (or press 'b').<br />
<br />
[[Image:inksmoto_050_08.png]]<br />
<br />
The ''Block properties'' window opens. Check ''Background block'' then press ''OK''.<br />
<br />
[[Image:inksmoto_050_09.png]]<br />
<br />
Now we have to set the level start and its end.<br />
<br />
Select the first circle and use this menu entry: ''Effects->X-moto->Entities->Player Start''.<br />
Then select the second circle and use this menu entry: ''Effects->X-moto->Entities->End Of Level''.<br />
<br />
The level looks like this:<br />
<br />
[[Image:inksmoto_060_02.png]]<br />
<br />
==Save the level==<br />
<br />
Now that our level is drawn and its shapes have Xmoto properties, we have to set the properties of the level, like its name, author, ...<br />
<br />
Use the Xmoto menu entry ''Effects->X-moto->Level->Set level properties''. The ''Level properties'' window pops up:<br />
<br />
[[Image:inksmoto_050_11.png]]<br />
<br />
Entries in this window (bold ones are mandatory):<br />
* lua script: If your level has a lua script, enter the lua file with its full path.<br />
* '''level id''': The id of the level (only letters, digits and underscore, no space).<br />
* '''level name''': The real name of the level.<br />
* '''author''': The author of the level (you).<br />
* description: A message to add to the level.<br />
* border texture: Choose the texture which be displayed around the level. <br />
<br />
==Test the level in Xmoto==<br />
<br />
Now our level is ready to be tested in Xmoto. Use the Xmoto menu entry ''Effects->X-moto->Other->Launch level in X-moto'' (or press 'x'). The ''Launch level in X-Moto'' window pops up:<br />
<br />
[[Image:inksmoto_050_12.png]]<br />
<br />
If the Xmoto executable is present in your PATH (under Linux and MacOSX), you don't have to fill the parameter. If you're under Windows or you want to use a specific Xmoto executable, then enter your Xmoto executable with its full path. <br />
<br />
Here is the level in Xmoto:<br />
<br />
[[Image:inksmoto_050_13.png]]<br />
<br />
==Get the .lvl in order to upload it==<br />
<br />
Now that the level is ready, we have to upload it to the Xmoto website http://xmoto.tuxfamily.org/index.php?page=sendyourlevel<br />
<br />
You have to send the level as a .lvl file, not a .svg<br />
*svg: Vector graphic format<br />
*lvl: Xmoto level<br />
<br />
There's two ways to get the .lvl:<br />
*When you launch the level in Xmoto from within Inksmoto, the file last.svg and last.lvl are created in the Inkscape home extensions directory:<br />
**Linux & MacOSX: ~/.inkscape/extensions<br />
**Windows: C:\Documents And Settings\<USER>\Application Data\Inkscape\extensions\<br />
***To open Application Data you might have to do Start->run...(or Win-Button+R)->%APPDATA%<br />
<br />
*You can also save the svg and the lvl separately using ''File->Save a Copy...'' and choosing the appropriate file format ''(X-Moto Level (*.lvl))''.<br />
<br />
==Svg file of the tutorial==<br />
<br />
Here is the corresponding svg file of the tutorial level: [[Media:Tutorial_050.svg]]<br />
<br />
=Tutorial: What's new in 0.6.0=<br />
<br />
==copying xmoto attributes between objects==<br />
<br />
Now you can select an object in Inkscape and copy its Xmoto properties and then select one or more objects and set the copied Xmoto properties.<br />
<br />
==Better display of block edges in inkscape==<br />
<br />
Now the edge effects are displayed with two different colors when two differents edge effects are set to a block. And the colors matches the angle set for them.<br />
<br />
[[Image:inksmoto_060_03.png]]<br />
<br />
==Display the block's texture scaled==<br />
<br />
Now the texture is displayed on the block with the right scale, as in Xmoto.<br />
<br />
[[Image:Inksmoto_060_04.png]]<br />
<br />
==Default level/level_id==<br />
<br />
For fast testing you can generate the .lvl and launch it in Xmoto without having to set the level id and name.<br />
'''But set them before uploading your level to the Xmoto website'''.<br />
<br />
==New extension to change the id of xmoto objects==<br />
<br />
Due to how the entities are displayed in Inkscape, you can no longer change the id of an entity with 'right click->Object Properties'. If you do that, the entity will not have the id you specified in the .lvl and it will cause problems when you want to use this entity in a script.<br />
<br />
Now you have to use the 'Change id' window to set it ('i' short key)<br />
<br />
==jointed line==<br />
<br />
This new extension allow you to easily create jointed bridges, etc. with joints.<br />
See this page for a full description : [[Jointed Line]]<br />
<br />
==Inksmoto default values==<br />
<br />
Now when you open the window properties for a new object (sprite, blocks, ...), the default values are the one from the last choices you made in this window and no longer a blanck window.<br />
<br />
==Show xmoto sprites in Inkscape==<br />
<br />
Now instead of just coloring the shape, the sprites are displayed in Inkscape (along with the collision circle), with full properties (scale, rotation, flip). Every entities are displayed.<br />
<br />
[[Image:Inksmoto_060_05.png]]<br />
<br />
==automatic generation of regression tests to inksmoto==<br />
<br />
Now you can record what you're doing in Inksmoto and replay it later.<br />
This is an easy way to generate the unittests for Inksmoto.<br />
<br />
Use the two extensions in the 'Other' menu to record your sessions.<br />
The tests are generated in ''~/.inkscape/extensions/cur_tests''.<br />
<br />
You can play the generated tests with:<br />
cd <inksmoto install dir>/inksmoto/inksmoto_unittests<br />
python xmotoTestCase.py<br />
<br />
Example:<br />
~/bordel/svg2lvl-svn/inkscape/extensions/inksmoto/inksmoto_unittests$ python xmotoTestCase.py<br />
tests from module 'test_testBlocks' loaded<br />
...<br />
----------------------------------------------------------------------<br />
Ran 3 tests in 0.511s<br />
<br />
OK<br />
<br />
==Support for Xmoto 0.5.2 features==<br />
<br />
You can set a block color and texture.<br />
<br />
You can customise the edge effects:<br />
*color<br />
*scale<br />
*depth<br />
<br />
[[Image:Inksmoto_060_06.png]]</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Scripted_levels&diff=4418Scripted levels2009-08-12T16:21:29Z<p>Googlebotti: /* StartTimer(Name,Delay=100,Loops=0) */</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 />
== 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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Scripted_levels&diff=4417Scripted levels2009-08-12T13:55:18Z<p>Googlebotti: /* StartTimer(Name,Delay=100,Loops=0) */</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 />
timer={} --declare the timer<br />
function OnLoad()<br />
Game.StartTimer("timer",100,0) --create the timer<br />
Game.StartTimer("timer") -- is equal to the one above because defaults are 100 and 0<br />
- delay - 100 is equal to 1 second 1000 = 10 seconds and so on<br />
- loops - 0 means infinite more means that amount of loops is done and then the timer is deleted<br />
Game.StopTimer("timer") --now we stop the timer<br />
Game.StartTimer("timer") --now the timer is restarted, but not re-created.<br />
Game.StartTimer("timer",200,2) --now we reset the timer to delay of 2s and only to make 2 loops <br />
return true<br />
end<br />
--once the timer is created x-moto will update it and call this function<br />
-- name.Tick(loops) every time the delay has passed, loops=amount of loops<br />
-- done so far<br />
function timer.Tick(loops) <br />
if loops==1 then Game.Message("first loop!") end<br />
if loops==2 then Game.KillPlayer() end -- after 4 seconds (delay 200 and 2 loops) we kill the player!<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 />
== 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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Main_Page&diff=4394Fi:Main Page2009-08-01T19:16:01Z<p>Googlebotti: </p>
<hr />
<div>__NOTOC__<br />
<br />
[[Main_Page|English]] - [[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 />
<br />
== Tietoa ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Palaa kotisivulle]<br />
* [[manual|X-Moto Manuaali]]<br />
* [[Server command line|X-Moto serververin komentorivi]]<br />
* [[Fi:Screenshots|Ruutukaappauksia]]<br />
* [[Faq|U.K.K]]<br />
* [[Philip's_xmoto_guide|Philipsin X-Moto Opas]]<br />
* [[X-Moto on PSP|X-Moto PSP:llä]]<br />
* [[IRC tutorial|IRC-opas]]<br />
* [[Public X-Moto servers|Julkiset X-Moto serverit]]<br />
* [[Wiki Contributors|Wikin tekijät]]<br />
* [[how to capture, edit and create a movie|Kuinka tallettaa, muokata ja tehdä elokuva]]<br />
'''Ominaisuudet'''<br />
* [[Use X-Moto on a USB-Key|X-Moto USB-tikulla]]<br />
* [[Use private rooms in game (instead of World Highscores)|Yksityisten huoneiden käyttö (MM sijaan)]]<br />
* [[Joystick|Joystikin käyttö]]<br />
* [[Wiimote|Wiimoten käyttö]]<br />
* [[record_video|Videoiden tallennus]]<br />
* [[Convert a replay to a video|Toistovideon muunto videoksi]]<br />
* [[Recording videos with an external program|Videoiden nauhoitus ulkoisella ohjelmalla]]<br />
<br />
== Kentän luonti ==<br />
<br />
*[[About good level design|Hyvästä kentän suunnittelusta]]<br />
*[[Level Checklist (for Creators and Testers)|Tarkistuslista (kentän tekijöille ja testaajille)]]<br />
<br />
'''Editori'''<br />
* [[How to create smooth levels using Inkscape|Kuinka tehdä sulavia kenttiä Inkscapella]]<br />
* [[xmoto-edit|Kentän teko Xmoto-editillä (EPÄARVOSTETTUA)]]<br />
* [[Scripted levels|Skriptattujen kenttien luonti (katso lisää alempaa)]]<br />
* [[Others tips to make levels|Muita neuvoja kenttien tekoon]]<br />
* [[Shortcuts for most used actions in the editor|Kenttä editorin pikanäppäimet]]<br />
* [[Video tutorials|Video oppaita]]<br />
'''Teemat ja Grafiikka'''<br />
* [[Make a theme|Teeman luonti/uuden spriten lisääminen]]<br />
* [[textures_creation|Kuinka käsitellä omia tekstuureja]]<br />
* [[How to create, test and upload an animated sprite|Kuinka luoda, testata ja lähettää animoitu sprite]]<br />
* [[Background graphics pool|Tausta allas]]<br />
* [[sprites_pool|Sprites allas Gimpille]]<br />
* [[Svg Block Pool|Svg palikka allas]]<br />
'''Scriptaus'''<br />
* [[Basics of Scripting|Skriptauksen perusteet]]<br />
* [[How to include Scripts into a Level|Kuinka lisätä skriptiä kenttiin]]<br />
* [[LTS - Learn To Script Series|LTS - Learn To Script Sarja]]<br />
* [[Funtions for Game Events|Funktiot pelin tapahtumille (Zonet, Voltit, jne.)]]<br />
* [[Level alteration Functions|Kentän muokkaus funktiot (Palikat, Fysiikka, jne.)]]<br />
* [[Player Functions|Pelaaja funktiot (Voita, Tapa, Teleporttaus, jne.) )]]<br />
* [[Camera Functions|Kamera funktiot (Zoomaus, Pyöritys, jne.)]]<br />
* [[Sound Functions|Ääni funktiot]]<br />
'''Modit ja Skriptit'''<br />
* [[Skate Park Mod|Skeitti puisto skripti]]<br />
'''Kehitys'''<br />
* [[Getting svn of inksmoto (svg2lvl) for windows using Tortoise SVN|Inksmoton (svg2lvl) kehitysversion saanti windowsille käyttäen Tortoise SVN:nää]]<br />
<br />
== X-Moton kääntäminen ==<br />
* [[Build for Unix (like GNU/Linux)|Kääntö Unixille (kuten GNU/Linux)]]<br />
* [[Build for MacOSX|Kääntö MacOSX:lle]]<br />
* [[Build for Windows|Kääntö Windowsille]]<br />
* [[Build from SVN|Kääntö lähdekoodeista]]<br />
* [[Build with CMake (experimental)|Kääntö CMakella (kokeilullinen)]]<br />
<br />
== Hallinnointi ==<br />
* [[How to validate a highscore|Kuinka hyväksyä ennätys]]<br />
* [[How to validate a level|Kuinka hyväksyä kenttä]]<br />
* [[How to validate a sprite|Kuinka hyväksyä sprite]]<br />
* [[Forum's administration changes|Fooruminen hallinnon muutokset]]<br />
* [[How to unvalidate a highscore|Kuinka poistaa ennätys]]<br />
* [[How to update po pictures|Kuinka päivittää po kuvat]]<br />
* [[How to remove a validated level|Kuinka poistaa hyväksytty kenttä]]<br />
<br />
== Kehitys ==<br />
* [[Wishlist|Toivelista]]<br />
* [[Code documentation|Koodin dokumentaatio]]<br />
* [[Contributions|Kuinka auttaa X-Motoa]]<br />
* [[Translate X-Moto and X-Moto Website into your language|X-Moton ja X-Moton nettisivujen kääntäminen]]<br />
* [[File formats|Tiedostotyypit]]<br />
* [[Net protocol|Netti-protocolla]]<br />
* [[Access to the website sources|Nettisivujen lähdekoodien saanti]]<br />
* [[SDL_gfx|SDL_gfx:n porttaus työ]]<br />
* [[Chipmunk integration|Chipmunk intergraatio]]<br />
* [[Level collection list|Kenttä kokoelma lista]]<br />
* [[Multiplayer design|Moninpelin suunnitelma]]<br />
* [[Deliver a X-Moto version MEMO|Toimita X-Moto versio muistio]]<br />
* [[Rooms competition idea|Huone pelaamisen idea]]</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Main_Page&diff=4393Fi:Main Page2009-08-01T19:15:33Z<p>Googlebotti: /* Tietoa */</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 />
<br />
== Tietoa ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Palaa kotisivulle]<br />
* [[manual|X-Moto Manuaali]]<br />
* [[Server command line|X-Moto serververin komentorivi]]<br />
* [[Fi:Screenshots|Ruutukaappauksia]]<br />
* [[Faq|U.K.K]]<br />
* [[Philip's_xmoto_guide|Philipsin X-Moto Opas]]<br />
* [[X-Moto on PSP|X-Moto PSP:llä]]<br />
* [[IRC tutorial|IRC-opas]]<br />
* [[Public X-Moto servers|Julkiset X-Moto serverit]]<br />
* [[Wiki Contributors|Wikin tekijät]]<br />
* [[how to capture, edit and create a movie|Kuinka tallettaa, muokata ja tehdä elokuva]]<br />
'''Ominaisuudet'''<br />
* [[Use X-Moto on a USB-Key|X-Moto USB-tikulla]]<br />
* [[Use private rooms in game (instead of World Highscores)|Yksityisten huoneiden käyttö (MM sijaan)]]<br />
* [[Joystick|Joystikin käyttö]]<br />
* [[Wiimote|Wiimoten käyttö]]<br />
* [[record_video|Videoiden tallennus]]<br />
* [[Convert a replay to a video|Toistovideon muunto videoksi]]<br />
* [[Recording videos with an external program|Videoiden nauhoitus ulkoisella ohjelmalla]]<br />
<br />
== Kentän luonti ==<br />
<br />
*[[About good level design|Hyvästä kentän suunnittelusta]]<br />
*[[Level Checklist (for Creators and Testers)|Tarkistuslista (kentän tekijöille ja testaajille)]]<br />
<br />
'''Editori'''<br />
* [[How to create smooth levels using Inkscape|Kuinka tehdä sulavia kenttiä Inkscapella]]<br />
* [[xmoto-edit|Kentän teko Xmoto-editillä (EPÄARVOSTETTUA)]]<br />
* [[Scripted levels|Skriptattujen kenttien luonti (katso lisää alempaa)]]<br />
* [[Others tips to make levels|Muita neuvoja kenttien tekoon]]<br />
* [[Shortcuts for most used actions in the editor|Kenttä editorin pikanäppäimet]]<br />
* [[Video tutorials|Video oppaita]]<br />
'''Teemat ja Grafiikka'''<br />
* [[Make a theme|Teeman luonti/uuden spriten lisääminen]]<br />
* [[textures_creation|Kuinka käsitellä omia tekstuureja]]<br />
* [[How to create, test and upload an animated sprite|Kuinka luoda, testata ja lähettää animoitu sprite]]<br />
* [[Background graphics pool|Tausta allas]]<br />
* [[sprites_pool|Sprites allas Gimpille]]<br />
* [[Svg Block Pool|Svg palikka allas]]<br />
'''Scriptaus'''<br />
* [[Basics of Scripting|Skriptauksen perusteet]]<br />
* [[How to include Scripts into a Level|Kuinka lisätä skriptiä kenttiin]]<br />
* [[LTS - Learn To Script Series|LTS - Learn To Script Sarja]]<br />
* [[Funtions for Game Events|Funktiot pelin tapahtumille (Zonet, Voltit, jne.)]]<br />
* [[Level alteration Functions|Kentän muokkaus funktiot (Palikat, Fysiikka, jne.)]]<br />
* [[Player Functions|Pelaaja funktiot (Voita, Tapa, Teleporttaus, jne.) )]]<br />
* [[Camera Functions|Kamera funktiot (Zoomaus, Pyöritys, jne.)]]<br />
* [[Sound Functions|Ääni funktiot]]<br />
'''Modit ja Skriptit'''<br />
* [[Skate Park Mod|Skeitti puisto skripti]]<br />
'''Kehitys'''<br />
* [[Getting svn of inksmoto (svg2lvl) for windows using Tortoise SVN|Inksmoton (svg2lvl) kehitysversion saanti windowsille käyttäen Tortoise SVN:nää]]<br />
<br />
== X-Moton kääntäminen ==<br />
* [[Build for Unix (like GNU/Linux)|Kääntö Unixille (kuten GNU/Linux)]]<br />
* [[Build for MacOSX|Kääntö MacOSX:lle]]<br />
* [[Build for Windows|Kääntö Windowsille]]<br />
* [[Build from SVN|Kääntö lähdekoodeista]]<br />
* [[Build with CMake (experimental)|Kääntö CMakella (kokeilullinen)]]<br />
<br />
== Hallinnointi ==<br />
* [[How to validate a highscore|Kuinka hyväksyä ennätys]]<br />
* [[How to validate a level|Kuinka hyväksyä kenttä]]<br />
* [[How to validate a sprite|Kuinka hyväksyä sprite]]<br />
* [[Forum's administration changes|Fooruminen hallinnon muutokset]]<br />
* [[How to unvalidate a highscore|Kuinka poistaa ennätys]]<br />
* [[How to update po pictures|Kuinka päivittää po kuvat]]<br />
* [[How to remove a validated level|Kuinka poistaa hyväksytty kenttä]]<br />
<br />
== Kehitys ==<br />
* [[Wishlist|Toivelista]]<br />
* [[Code documentation|Koodin dokumentaatio]]<br />
* [[Contributions|Kuinka auttaa X-Motoa]]<br />
* [[Translate X-Moto and X-Moto Website into your language|X-Moton ja X-Moton nettisivujen kääntäminen]]<br />
* [[File formats|Tiedostotyypit]]<br />
* [[Net protocol|Netti-protocolla]]<br />
* [[Access to the website sources|Nettisivujen lähdekoodien saanti]]<br />
* [[SDL_gfx|SDL_gfx:n porttaus työ]]<br />
* [[Chipmunk integration|Chipmunk intergraatio]]<br />
* [[Level collection list|Kenttä kokoelma lista]]<br />
* [[Multiplayer design|Moninpelin suunnitelma]]<br />
* [[Deliver a X-Moto version MEMO|Toimita X-Moto versio muistio]]<br />
* [[Rooms competition idea|Huone pelaamisen idea]]</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Main_Page&diff=4392Main Page2009-08-01T19:15:13Z<p>Googlebotti: </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 />
* [[how to capture, edit and create a movie]]<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 />
* [[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 />
* [[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 />
'''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 />
* [[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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Main_Page&diff=4391Fi:Main Page2009-08-01T19:13:37Z<p>Googlebotti: /* 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 />
<br />
== Tietoa ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Palaa kotisivulle]<br />
* [[manual|X-Moto Manuaali]]<br />
* [[Server command line|X-Moto serververin komentorivi]]<br />
* [[Fi:Screenshots|Ruutukaappauksia]]<br />
* [[Faq|U.K.K]]<br />
* [[Philip's_xmoto_guide|Philipsin X-Moto Opas]]<br />
* [[X-Moto on PSP|X-Moto PSP:llä]]<br />
* [[IRC tutorial|IRC-opas]]<br />
* [[Public X-Moto servers|Julkiset X-Moto serverit]]<br />
* [[Wiki Contributors|Wikin tekjät]]<br />
* [[how to capture, edit and create a movie|Kuinka tallettaa, muokata ja tehdä elokuva]]<br />
'''Ominaisuudet'''<br />
* [[Use X-Moto on a USB-Key|X-Moto USB-tikulla]]<br />
* [[Use private rooms in game (instead of World Highscores)|Yksityisten huoneiden käyttö (MM sijaan)]]<br />
* [[Joystick|Joystikin käyttö]]<br />
* [[Wiimote|Wiimoten käyttö]]<br />
* [[record_video|Videoiden tallennus]]<br />
* [[Convert a replay to a video|Toistovideon muunto videoksi]]<br />
* [[Recording videos with an external program|Videoiden nauhoitus ulkoisella ohjelmalla]]<br />
<br />
== Kentän luonti ==<br />
<br />
*[[About good level design|Hyvästä kentän suunnittelusta]]<br />
*[[Level Checklist (for Creators and Testers)|Tarkistuslista (kentän tekijöille ja testaajille)]]<br />
<br />
'''Editori'''<br />
* [[How to create smooth levels using Inkscape|Kuinka tehdä sulavia kenttiä Inkscapella]]<br />
* [[xmoto-edit|Kentän teko Xmoto-editillä (EPÄARVOSTETTUA)]]<br />
* [[Scripted levels|Skriptattujen kenttien luonti (katso lisää alempaa)]]<br />
* [[Others tips to make levels|Muita neuvoja kenttien tekoon]]<br />
* [[Shortcuts for most used actions in the editor|Kenttä editorin pikanäppäimet]]<br />
* [[Video tutorials|Video oppaita]]<br />
'''Teemat ja Grafiikka'''<br />
* [[Make a theme|Teeman luonti/uuden spriten lisääminen]]<br />
* [[textures_creation|Kuinka käsitellä omia tekstuureja]]<br />
* [[How to create, test and upload an animated sprite|Kuinka luoda, testata ja lähettää animoitu sprite]]<br />
* [[Background graphics pool|Tausta allas]]<br />
* [[sprites_pool|Sprites allas Gimpille]]<br />
* [[Svg Block Pool|Svg palikka allas]]<br />
'''Scriptaus'''<br />
* [[Basics of Scripting|Skriptauksen perusteet]]<br />
* [[How to include Scripts into a Level|Kuinka lisätä skriptiä kenttiin]]<br />
* [[LTS - Learn To Script Series|LTS - Learn To Script Sarja]]<br />
* [[Funtions for Game Events|Funktiot pelin tapahtumille (Zonet, Voltit, jne.)]]<br />
* [[Level alteration Functions|Kentän muokkaus funktiot (Palikat, Fysiikka, jne.)]]<br />
* [[Player Functions|Pelaaja funktiot (Voita, Tapa, Teleporttaus, jne.) )]]<br />
* [[Camera Functions|Kamera funktiot (Zoomaus, Pyöritys, jne.)]]<br />
* [[Sound Functions|Ääni funktiot]]<br />
'''Modit ja Skriptit'''<br />
* [[Skate Park Mod|Skeitti puisto skripti]]<br />
'''Kehitys'''<br />
* [[Getting svn of inksmoto (svg2lvl) for windows using Tortoise SVN|Inksmoton (svg2lvl) kehitysversion saanti windowsille käyttäen Tortoise SVN:nää]]<br />
<br />
== X-Moton kääntäminen ==<br />
* [[Build for Unix (like GNU/Linux)|Kääntö Unixille (kuten GNU/Linux)]]<br />
* [[Build for MacOSX|Kääntö MacOSX:lle]]<br />
* [[Build for Windows|Kääntö Windowsille]]<br />
* [[Build from SVN|Kääntö lähdekoodeista]]<br />
* [[Build with CMake (experimental)|Kääntö CMakella (kokeilullinen)]]<br />
<br />
== Hallinnointi ==<br />
* [[How to validate a highscore|Kuinka hyväksyä ennätys]]<br />
* [[How to validate a level|Kuinka hyväksyä kenttä]]<br />
* [[How to validate a sprite|Kuinka hyväksyä sprite]]<br />
* [[Forum's administration changes|Fooruminen hallinnon muutokset]]<br />
* [[How to unvalidate a highscore|Kuinka poistaa ennätys]]<br />
* [[How to update po pictures|Kuinka päivittää po kuvat]]<br />
* [[How to remove a validated level|Kuinka poistaa hyväksytty kenttä]]<br />
<br />
== Kehitys ==<br />
* [[Wishlist|Toivelista]]<br />
* [[Code documentation|Koodin dokumentaatio]]<br />
* [[Contributions|Kuinka auttaa X-Motoa]]<br />
* [[Translate X-Moto and X-Moto Website into your language|X-Moton ja X-Moton nettisivujen kääntäminen]]<br />
* [[File formats|Tiedostotyypit]]<br />
* [[Net protocol|Netti-protocolla]]<br />
* [[Access to the website sources|Nettisivujen lähdekoodien saanti]]<br />
* [[SDL_gfx|SDL_gfx:n porttaus työ]]<br />
* [[Chipmunk integration|Chipmunk intergraatio]]<br />
* [[Level collection list|Kenttä kokoelma lista]]<br />
* [[Multiplayer design|Moninpelin suunnitelma]]<br />
* [[Deliver a X-Moto version MEMO|Toimita X-Moto versio muistio]]<br />
* [[Rooms competition idea|Huone pelaamisen idea]]</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Main_Page&diff=4390Fi:Main Page2009-08-01T19:08:24Z<p>Googlebotti: /* Administration */</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 />
<br />
== Tietoa ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Palaa kotisivulle]<br />
* [[manual|X-Moto Manuaali]]<br />
* [[Server command line|X-Moto serververin komentorivi]]<br />
* [[Fi:Screenshots|Ruutukaappauksia]]<br />
* [[Faq|U.K.K]]<br />
* [[Philip's_xmoto_guide|Philipsin X-Moto Opas]]<br />
* [[X-Moto on PSP|X-Moto PSP:llä]]<br />
* [[IRC tutorial|IRC-opas]]<br />
* [[Public X-Moto servers|Julkiset X-Moto serverit]]<br />
* [[Wiki Contributors|Wikin tekjät]]<br />
* [[how to capture, edit and create a movie|Kuinka tallettaa, muokata ja tehdä elokuva]]<br />
'''Ominaisuudet'''<br />
* [[Use X-Moto on a USB-Key|X-Moto USB-tikulla]]<br />
* [[Use private rooms in game (instead of World Highscores)|Yksityisten huoneiden käyttö (MM sijaan)]]<br />
* [[Joystick|Joystikin käyttö]]<br />
* [[Wiimote|Wiimoten käyttö]]<br />
* [[record_video|Videoiden tallennus]]<br />
* [[Convert a replay to a video|Toistovideon muunto videoksi]]<br />
* [[Recording videos with an external program|Videoiden nauhoitus ulkoisella ohjelmalla]]<br />
<br />
== Kentän luonti ==<br />
<br />
*[[About good level design|Hyvästä kentän suunnittelusta]]<br />
*[[Level Checklist (for Creators and Testers)|Tarkistuslista (kentän tekijöille ja testaajille)]]<br />
<br />
'''Editori'''<br />
* [[How to create smooth levels using Inkscape|Kuinka tehdä sulavia kenttiä Inkscapella]]<br />
* [[xmoto-edit|Kentän teko Xmoto-editillä (EPÄARVOSTETTUA)]]<br />
* [[Scripted levels|Skriptattujen kenttien luonti (katso lisää alempaa)]]<br />
* [[Others tips to make levels|Muita neuvoja kenttien tekoon]]<br />
* [[Shortcuts for most used actions in the editor|Kenttä editorin pikanäppäimet]]<br />
* [[Video tutorials|Video oppaita]]<br />
'''Teemat ja Grafiikka'''<br />
* [[Make a theme|Teeman luonti/uuden spriten lisääminen]]<br />
* [[textures_creation|Kuinka käsitellä omia tekstuureja]]<br />
* [[How to create, test and upload an animated sprite|Kuinka luoda, testata ja lähettää animoitu sprite]]<br />
* [[Background graphics pool|Tausta allas]]<br />
* [[sprites_pool|Sprites allas Gimpille]]<br />
* [[Svg Block Pool|Svg palikka allas]]<br />
'''Scriptaus'''<br />
* [[Basics of Scripting|Skriptauksen perusteet]]<br />
* [[How to include Scripts into a Level|Kuinka lisätä skriptiä kenttiin]]<br />
* [[LTS - Learn To Script Series|LTS - Learn To Script Sarja]]<br />
* [[Funtions for Game Events|Funktiot pelin tapahtumille (Zonet, Voltit, jne.)]]<br />
* [[Level alteration Functions|Kentän muokkaus funktiot (Palikat, Fysiikka, jne.)]]<br />
* [[Player Functions|Pelaaja funktiot (Voita, Tapa, Teleporttaus, jne.) )]]<br />
* [[Camera Functions|Kamera funktiot (Zoomaus, Pyöritys, jne.)]]<br />
* [[Sound Functions|Ääni funktiot]]<br />
'''Modit ja Skriptit'''<br />
* [[Skate Park Mod|Skeitti puisto skripti]]<br />
'''Kehitys'''<br />
* [[Getting svn of inksmoto (svg2lvl) for windows using Tortoise SVN|Inksmoton (svg2lvl) kehitysversion saanti windowsille käyttäen Tortoise SVN:nää]]<br />
<br />
== X-Moton kääntäminen ==<br />
* [[Build for Unix (like GNU/Linux)|Kääntö Unixille (kuten GNU/Linux)]]<br />
* [[Build for MacOSX|Kääntö MacOSX:lle]]<br />
* [[Build for Windows|Kääntö Windowsille]]<br />
* [[Build from SVN|Kääntö lähdekoodeista]]<br />
* [[Build with CMake (experimental)|Kääntö CMakella (kokeilullinen)]]<br />
<br />
== Hallinnointi ==<br />
* [[How to validate a highscore|Kuinka hyväksyä ennätys]]<br />
* [[How to validate a level|Kuinka hyväksyä kenttä]]<br />
* [[How to validate a sprite|Kuinka hyväksyä sprite]]<br />
* [[Forum's administration changes|Fooruminen hallinnon muutokset]]<br />
* [[How to unvalidate a highscore|Kuinka poistaa ennätys]]<br />
* [[How to update po pictures|Kuinka päivittää po kuvat]]<br />
* [[How to remove a validated level|Kuinka poistaa hyväksytty kenttä]]<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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Main_Page&diff=4389Fi:Main Page2009-08-01T19:05:36Z<p>Googlebotti: /* Building XMoto */</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 />
<br />
== Tietoa ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Palaa kotisivulle]<br />
* [[manual|X-Moto Manuaali]]<br />
* [[Server command line|X-Moto serververin komentorivi]]<br />
* [[Fi:Screenshots|Ruutukaappauksia]]<br />
* [[Faq|U.K.K]]<br />
* [[Philip's_xmoto_guide|Philipsin X-Moto Opas]]<br />
* [[X-Moto on PSP|X-Moto PSP:llä]]<br />
* [[IRC tutorial|IRC-opas]]<br />
* [[Public X-Moto servers|Julkiset X-Moto serverit]]<br />
* [[Wiki Contributors|Wikin tekjät]]<br />
* [[how to capture, edit and create a movie|Kuinka tallettaa, muokata ja tehdä elokuva]]<br />
'''Ominaisuudet'''<br />
* [[Use X-Moto on a USB-Key|X-Moto USB-tikulla]]<br />
* [[Use private rooms in game (instead of World Highscores)|Yksityisten huoneiden käyttö (MM sijaan)]]<br />
* [[Joystick|Joystikin käyttö]]<br />
* [[Wiimote|Wiimoten käyttö]]<br />
* [[record_video|Videoiden tallennus]]<br />
* [[Convert a replay to a video|Toistovideon muunto videoksi]]<br />
* [[Recording videos with an external program|Videoiden nauhoitus ulkoisella ohjelmalla]]<br />
<br />
== Kentän luonti ==<br />
<br />
*[[About good level design|Hyvästä kentän suunnittelusta]]<br />
*[[Level Checklist (for Creators and Testers)|Tarkistuslista (kentän tekijöille ja testaajille)]]<br />
<br />
'''Editori'''<br />
* [[How to create smooth levels using Inkscape|Kuinka tehdä sulavia kenttiä Inkscapella]]<br />
* [[xmoto-edit|Kentän teko Xmoto-editillä (EPÄARVOSTETTUA)]]<br />
* [[Scripted levels|Skriptattujen kenttien luonti (katso lisää alempaa)]]<br />
* [[Others tips to make levels|Muita neuvoja kenttien tekoon]]<br />
* [[Shortcuts for most used actions in the editor|Kenttä editorin pikanäppäimet]]<br />
* [[Video tutorials|Video oppaita]]<br />
'''Teemat ja Grafiikka'''<br />
* [[Make a theme|Teeman luonti/uuden spriten lisääminen]]<br />
* [[textures_creation|Kuinka käsitellä omia tekstuureja]]<br />
* [[How to create, test and upload an animated sprite|Kuinka luoda, testata ja lähettää animoitu sprite]]<br />
* [[Background graphics pool|Tausta allas]]<br />
* [[sprites_pool|Sprites allas Gimpille]]<br />
* [[Svg Block Pool|Svg palikka allas]]<br />
'''Scriptaus'''<br />
* [[Basics of Scripting|Skriptauksen perusteet]]<br />
* [[How to include Scripts into a Level|Kuinka lisätä skriptiä kenttiin]]<br />
* [[LTS - Learn To Script Series|LTS - Learn To Script Sarja]]<br />
* [[Funtions for Game Events|Funktiot pelin tapahtumille (Zonet, Voltit, jne.)]]<br />
* [[Level alteration Functions|Kentän muokkaus funktiot (Palikat, Fysiikka, jne.)]]<br />
* [[Player Functions|Pelaaja funktiot (Voita, Tapa, Teleporttaus, jne.) )]]<br />
* [[Camera Functions|Kamera funktiot (Zoomaus, Pyöritys, jne.)]]<br />
* [[Sound Functions|Ääni funktiot]]<br />
'''Modit ja Skriptit'''<br />
* [[Skate Park Mod|Skeitti puisto skripti]]<br />
'''Kehitys'''<br />
* [[Getting svn of inksmoto (svg2lvl) for windows using Tortoise SVN|Inksmoton (svg2lvl) kehitysversion saanti windowsille käyttäen Tortoise SVN:nää]]<br />
<br />
== X-Moton kääntäminen ==<br />
* [[Build for Unix (like GNU/Linux)|Kääntö Unixille (kuten GNU/Linux)]]<br />
* [[Build for MacOSX|Kääntö MacOSX:lle]]<br />
* [[Build for Windows|Kääntö Windowsille]]<br />
* [[Build from SVN|Kääntö lähdekoodeista]]<br />
* [[Build with CMake (experimental)|Kääntö CMakella (kokeilullinen)]]<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 />
* [[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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Main_Page&diff=4388Fi:Main Page2009-08-01T19:03:47Z<p>Googlebotti: /* Kentän luonti */</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 />
<br />
== Tietoa ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Palaa kotisivulle]<br />
* [[manual|X-Moto Manuaali]]<br />
* [[Server command line|X-Moto serververin komentorivi]]<br />
* [[Fi:Screenshots|Ruutukaappauksia]]<br />
* [[Faq|U.K.K]]<br />
* [[Philip's_xmoto_guide|Philipsin X-Moto Opas]]<br />
* [[X-Moto on PSP|X-Moto PSP:llä]]<br />
* [[IRC tutorial|IRC-opas]]<br />
* [[Public X-Moto servers|Julkiset X-Moto serverit]]<br />
* [[Wiki Contributors|Wikin tekjät]]<br />
* [[how to capture, edit and create a movie|Kuinka tallettaa, muokata ja tehdä elokuva]]<br />
'''Ominaisuudet'''<br />
* [[Use X-Moto on a USB-Key|X-Moto USB-tikulla]]<br />
* [[Use private rooms in game (instead of World Highscores)|Yksityisten huoneiden käyttö (MM sijaan)]]<br />
* [[Joystick|Joystikin käyttö]]<br />
* [[Wiimote|Wiimoten käyttö]]<br />
* [[record_video|Videoiden tallennus]]<br />
* [[Convert a replay to a video|Toistovideon muunto videoksi]]<br />
* [[Recording videos with an external program|Videoiden nauhoitus ulkoisella ohjelmalla]]<br />
<br />
== Kentän luonti ==<br />
<br />
*[[About good level design|Hyvästä kentän suunnittelusta]]<br />
*[[Level Checklist (for Creators and Testers)|Tarkistuslista (kentän tekijöille ja testaajille)]]<br />
<br />
'''Editori'''<br />
* [[How to create smooth levels using Inkscape|Kuinka tehdä sulavia kenttiä Inkscapella]]<br />
* [[xmoto-edit|Kentän teko Xmoto-editillä (EPÄARVOSTETTUA)]]<br />
* [[Scripted levels|Skriptattujen kenttien luonti (katso lisää alempaa)]]<br />
* [[Others tips to make levels|Muita neuvoja kenttien tekoon]]<br />
* [[Shortcuts for most used actions in the editor|Kenttä editorin pikanäppäimet]]<br />
* [[Video tutorials|Video oppaita]]<br />
'''Teemat ja Grafiikka'''<br />
* [[Make a theme|Teeman luonti/uuden spriten lisääminen]]<br />
* [[textures_creation|Kuinka käsitellä omia tekstuureja]]<br />
* [[How to create, test and upload an animated sprite|Kuinka luoda, testata ja lähettää animoitu sprite]]<br />
* [[Background graphics pool|Tausta allas]]<br />
* [[sprites_pool|Sprites allas Gimpille]]<br />
* [[Svg Block Pool|Svg palikka allas]]<br />
'''Scriptaus'''<br />
* [[Basics of Scripting|Skriptauksen perusteet]]<br />
* [[How to include Scripts into a Level|Kuinka lisätä skriptiä kenttiin]]<br />
* [[LTS - Learn To Script Series|LTS - Learn To Script Sarja]]<br />
* [[Funtions for Game Events|Funktiot pelin tapahtumille (Zonet, Voltit, jne.)]]<br />
* [[Level alteration Functions|Kentän muokkaus funktiot (Palikat, Fysiikka, jne.)]]<br />
* [[Player Functions|Pelaaja funktiot (Voita, Tapa, Teleporttaus, jne.) )]]<br />
* [[Camera Functions|Kamera funktiot (Zoomaus, Pyöritys, jne.)]]<br />
* [[Sound Functions|Ääni funktiot]]<br />
'''Modit ja Skriptit'''<br />
* [[Skate Park Mod|Skeitti puisto skripti]]<br />
'''Kehitys'''<br />
* [[Getting svn of inksmoto (svg2lvl) for windows using Tortoise SVN|Inksmoton (svg2lvl) kehitysversion saanti windowsille käyttäen Tortoise SVN:nää]]<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 />
* [[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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Main_Page&diff=4387Fi:Main Page2009-08-01T19:00:54Z<p>Googlebotti: /* Kentän luonti */</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 />
<br />
== Tietoa ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Palaa kotisivulle]<br />
* [[manual|X-Moto Manuaali]]<br />
* [[Server command line|X-Moto serververin komentorivi]]<br />
* [[Fi:Screenshots|Ruutukaappauksia]]<br />
* [[Faq|U.K.K]]<br />
* [[Philip's_xmoto_guide|Philipsin X-Moto Opas]]<br />
* [[X-Moto on PSP|X-Moto PSP:llä]]<br />
* [[IRC tutorial|IRC-opas]]<br />
* [[Public X-Moto servers|Julkiset X-Moto serverit]]<br />
* [[Wiki Contributors|Wikin tekjät]]<br />
* [[how to capture, edit and create a movie|Kuinka tallettaa, muokata ja tehdä elokuva]]<br />
'''Ominaisuudet'''<br />
* [[Use X-Moto on a USB-Key|X-Moto USB-tikulla]]<br />
* [[Use private rooms in game (instead of World Highscores)|Yksityisten huoneiden käyttö (MM sijaan)]]<br />
* [[Joystick|Joystikin käyttö]]<br />
* [[Wiimote|Wiimoten käyttö]]<br />
* [[record_video|Videoiden tallennus]]<br />
* [[Convert a replay to a video|Toistovideon muunto videoksi]]<br />
* [[Recording videos with an external program|Videoiden nauhoitus ulkoisella ohjelmalla]]<br />
<br />
== Kentän luonti ==<br />
<br />
*[[About good level design|Hyvästä kentän suunnittelusta]]<br />
*[[Level Checklist (for Creators and Testers)|Tarkistuslista (kentän tekijöille ja testaajille)]]<br />
<br />
'''Editori'''<br />
* [[How to create smooth levels using Inkscape|Kuinka tehdä sulavia kenttiä Inkscapella]]<br />
* [[xmoto-edit|Kentän teko Xmoto-editillä (EPÄARVOSTETTUA)]]<br />
* [[Scripted levels|Skriptattujen kenttien luonti (katso lisää alempaa)]]<br />
* [[Others tips to make levels|Muita neuvoja kenttien tekoon]]<br />
* [[Shortcuts for most used actions in the editor|Kenttä editorin pikanäppäimet]]<br />
* [[Video tutorials|Video oppaita]]<br />
'''Teemat ja Grafiikka'''<br />
* [[Make a theme|Teeman luonti/uuden spriten lisääminen]]<br />
* [[textures_creation|Kuinka käsitellä omia tekstuureja]]<br />
* [[How to create, test and upload an animated sprite|Kuinka luoda, testata ja lähettää animoitu sprite]]<br />
* [[Background graphics pool|Tausta allas]]<br />
* [[sprites_pool|Sprites allas Gimpille]]<br />
* [[Svg Block Pool|Svg palikka allas]]<br />
'''Scriptaus'''<br />
* [[Basics of Scripting|Skriptauksen perusteet]]<br />
* [[How to include Scripts into a Level|Kuinka lisätä skriptiä kenttiin]]<br />
* [[LTS - Learn To Script Series|LTS - Learn To Script Sarja]]<br />
* [[Funtions for Game Events|Funktiot pelin tapahtumille (Zonet, Voltit, jne.)]]<br />
* [[Level alteration Functions|Kentän muokkaus funktiot (Palikat, Fysiikka, jne.)]]<br />
* [[Player Functions|Pelaaja funktiot (Voita, Tapa, Teleporttaus, jne.) )]]<br />
* [[Camera Functions|Kamera funktiot (Zoomaus, Pyöritys, jne.)]]<br />
* [[Sound Functions|Ääni funktiot]]<br />
'''Mods and Scripts'''<br />
* [[Skate Park Mod]]<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 />
* [[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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Main_Page&diff=4386Fi:Main Page2009-08-01T18:56:19Z<p>Googlebotti: </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 />
<br />
== Tietoa ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Palaa kotisivulle]<br />
* [[manual|X-Moto Manuaali]]<br />
* [[Server command line|X-Moto serververin komentorivi]]<br />
* [[Fi:Screenshots|Ruutukaappauksia]]<br />
* [[Faq|U.K.K]]<br />
* [[Philip's_xmoto_guide|Philipsin X-Moto Opas]]<br />
* [[X-Moto on PSP|X-Moto PSP:llä]]<br />
* [[IRC tutorial|IRC-opas]]<br />
* [[Public X-Moto servers|Julkiset X-Moto serverit]]<br />
* [[Wiki Contributors|Wikin tekjät]]<br />
* [[how to capture, edit and create a movie|Kuinka tallettaa, muokata ja tehdä elokuva]]<br />
'''Ominaisuudet'''<br />
* [[Use X-Moto on a USB-Key|X-Moto USB-tikulla]]<br />
* [[Use private rooms in game (instead of World Highscores)|Yksityisten huoneiden käyttö (MM sijaan)]]<br />
* [[Joystick|Joystikin käyttö]]<br />
* [[Wiimote|Wiimoten käyttö]]<br />
* [[record_video|Videoiden tallennus]]<br />
* [[Convert a replay to a video|Toistovideon muunto videoksi]]<br />
* [[Recording videos with an external program|Videoiden nauhoitus ulkoisella ohjelmalla]]<br />
<br />
== Kentän luonti ==<br />
<br />
*[[About good level design|Hyvästä kentän suunnittelusta]]<br />
*[[Level Checklist (for Creators and Testers)|Tarkistuslista (kentän tekijöille ja testaajille)]]<br />
<br />
'''Editor'''<br />
* [[How to create smooth levels using Inkscape|Kuinka tehdä sulavia kenttiä Inkscapella]]<br />
* [[xmoto-edit|Kentän teko Xmoto-editillä (EPÄARVOSTETTUA)]]<br />
* [[Scripted levels|Skriptattujen kenttien luonti (katso lisää alempaa)]]<br />
* [[Others tips to make levels|Muita neuvoja kenttien tekoon]]<br />
* [[Shortcuts for most used actions in the editor|Kenttä editorin pikanäppäimet]]<br />
* [[Video tutorials|Video oppaita]]<br />
'''Teemat ja Grafiikka'''<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 />
* [[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 />
* [[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 />
'''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 />
* [[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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Screenshots&diff=4385Fi:Screenshots2009-08-01T18:51:58Z<p>Googlebotti: </p>
<hr />
<div>__NOTOC__<br />
<br />
[[Screenshots|English]] - [[pt:Screenshots|Portuguese]] <br />
<br />
=X-Moto kuvia=<br />
<br />
<br />
{|<br />
| [[Image:Screenshot0023.png|thumb|left]] || [[Image:Screenshot0005.png|thumb|center]] || [[Image:Screenshot0018.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0022.png|thumb|left]] || [[Image:Screenshot0020.png|thumb|center]] || [[Image:Screenshot0019.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0025.png|thumb|left]] || [[Image:Screenshot0027.png|thumb|center]] || [[Image:Screenshot0030.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0034.png|thumb|left]] || [[Image:Screenshot0036.png|thumb|center]] || [[Image:Screenshot0037.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0038.png|thumb|left]] || [[Image:Xmoto01.png|thumb|center]] || [[Image:Xmoto02.png|thumb|right]]<br />
|}<br />
<br />
=Inksmoto Kenttä editorin kuvia=<br />
<br />
<br />
{|<br />
| [[Image:Inksmoto01.png|thumb|left]] || [[Image:Inksmoto02.png|thumb|center]] || [[Image:Inksmoto03.png|thumb|right]]<br />
|-<br />
| [[Image:Inksmoto4.png|thumb|left]]<br />
|}</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Screenshots&diff=4384Screenshots2009-08-01T18:51:45Z<p>Googlebotti: </p>
<hr />
<div>__NOTOC__<br />
<br />
[[pt:Screenshots|Portuguese]] - [[fi:Screenshots|Suomi]]<br />
<br />
=Xmoto screenshots=<br />
<br />
<br />
{|<br />
| [[Image:Screenshot0023.png|thumb|left]] || [[Image:Screenshot0005.png|thumb|center]] || [[Image:Screenshot0018.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0022.png|thumb|left]] || [[Image:Screenshot0020.png|thumb|center]] || [[Image:Screenshot0019.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0025.png|thumb|left]] || [[Image:Screenshot0027.png|thumb|center]] || [[Image:Screenshot0030.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0034.png|thumb|left]] || [[Image:Screenshot0036.png|thumb|center]] || [[Image:Screenshot0037.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0038.png|thumb|left]] || [[Image:Xmoto01.png|thumb|center]] || [[Image:Xmoto02.png|thumb|right]]<br />
|}<br />
<br />
=Inksmoto Level Editor screenshots=<br />
<br />
<br />
{|<br />
| [[Image:Inksmoto01.png|thumb|left]] || [[Image:Inksmoto02.png|thumb|center]] || [[Image:Inksmoto03.png|thumb|right]]<br />
|-<br />
| [[Image:Inksmoto4.png|thumb|left]]<br />
|}</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Main_Page&diff=4383Fi:Main Page2009-08-01T18:51:22Z<p>Googlebotti: </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 />
== Tietoa ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Palaa kotisivulle]<br />
* [[manual|X-Moto Manuaali]]<br />
* [[Server command line|X-Moto serververin komentorivi]]<br />
* [[Screenshots|Ruutukaappauksia]]<br />
* [[Faq|U.K.K]]<br />
* [[Philip's_xmoto_guide|Philipsin X-Moto Opas]]<br />
* [[X-Moto on PSP|X-Moto PSP:llä]]<br />
* [[IRC tutorial|IRC-opas]]<br />
* [[Public X-Moto servers|Julkiset X-Moto serverit]]<br />
* [[Wiki Contributors|Wikin tekjät]]<br />
* [[how to capture, edit and create a movie|Kuinka tallettaa, muokata ja tehdä elokuva]]<br />
'''Ominaisuudet'''<br />
* [[Use X-Moto on a USB-Key|X-Moto USB-tikulla]]<br />
* [[Use private rooms in game (instead of World Highscores)|Yksityisten huoneiden käyttö (MM sijaan)]]<br />
* [[Joystick|Joystikin käyttö]]<br />
* [[Wiimote|Wiimoten käyttö]]<br />
* [[record_video|Videoiden tallennus]]<br />
* [[Convert a replay to a video|Toistovideon muunto videoksi]]<br />
* [[Recording videos with an external program|Videoiden nauhoitus ulkoisella ohjelmalla]]<br />
<br />
== Kentän luonti ==<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 />
* [[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 />
* [[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 />
'''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 />
* [[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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Main_Page&diff=4382Fi:Main Page2009-08-01T18:50:31Z<p>Googlebotti: </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 />
== Tietoa ==<br />
<br />
* [http://xmoto.tuxfamily.org/ Palaa kotisivulle]<br />
* [[manual|X-Moto Manuaali]]<br />
* [[Server command line|X-Moto serververin komentorivi]]<br />
* [[Ruutukaappauksia]]<br />
* [[Faq|U.K.K]]<br />
* [[Philip's_xmoto_guide|Philipsin X-Moto Opas]]<br />
* [[X-Moto on PSP|X-Moto PSP:llä]]<br />
* [[IRC tutorial|IRC-opas]]<br />
* [[Public X-Moto servers|Julkiset X-Moto serverit]]<br />
* [[Wiki Contributors|Wikin tekjät]]<br />
* [[how to capture, edit and create a movie|Kuinka tallettaa, muokata ja tehdä elokuva]]<br />
'''Ominaisuudet'''<br />
* [[Use X-Moto on a USB-Key|X-Moto USB-tikulla]]<br />
* [[Use private rooms in game (instead of World Highscores)|Yksityisten huoneiden käyttö (MM sijaan)]]<br />
* [[Joystick|Joystikin käyttö]]<br />
* [[Wiimote|Wiimoten käyttö]]<br />
* [[record_video|Videoiden tallennus]]<br />
* [[Convert a replay to a video|Toistovideon muunto videoksi]]<br />
* [[Recording videos with an external program|Videoiden nauhoitus ulkoisella ohjelmalla]]<br />
<br />
== Kentän luonti ==<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 />
* [[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 />
* [[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 />
'''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 />
* [[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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Screenshots&diff=4381Fi:Screenshots2009-08-01T18:38:55Z<p>Googlebotti: </p>
<hr />
<div>__NOTOC__<br />
<br />
[[Screenshots|English]] <br />
[[pt:Screenshots|Portuguese]] <br />
<br />
=X-Moto kuvia=<br />
<br />
<br />
{|<br />
| [[Image:Screenshot0023.png|thumb|left]] || [[Image:Screenshot0005.png|thumb|center]] || [[Image:Screenshot0018.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0022.png|thumb|left]] || [[Image:Screenshot0020.png|thumb|center]] || [[Image:Screenshot0019.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0025.png|thumb|left]] || [[Image:Screenshot0027.png|thumb|center]] || [[Image:Screenshot0030.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0034.png|thumb|left]] || [[Image:Screenshot0036.png|thumb|center]] || [[Image:Screenshot0037.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0038.png|thumb|left]] || [[Image:Xmoto01.png|thumb|center]] || [[Image:Xmoto02.png|thumb|right]]<br />
|}<br />
<br />
=Inksmoto Kenttä editorin kuvia=<br />
<br />
<br />
{|<br />
| [[Image:Inksmoto01.png|thumb|left]] || [[Image:Inksmoto02.png|thumb|center]] || [[Image:Inksmoto03.png|thumb|right]]<br />
|-<br />
| [[Image:Inksmoto4.png|thumb|left]]<br />
|}</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Screenshots&diff=4380Fi:Screenshots2009-08-01T18:38:27Z<p>Googlebotti: </p>
<hr />
<div>__NOTOC__<br />
<br />
[[Screenshots|English]] <br />
[[pt:Screenshots|Portuguese]] <br />
[[fi:Screenshots|Suomi]]<br />
<br />
=X-Moto kuvia=<br />
<br />
<br />
{|<br />
| [[Image:Screenshot0023.png|thumb|left]] || [[Image:Screenshot0005.png|thumb|center]] || [[Image:Screenshot0018.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0022.png|thumb|left]] || [[Image:Screenshot0020.png|thumb|center]] || [[Image:Screenshot0019.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0025.png|thumb|left]] || [[Image:Screenshot0027.png|thumb|center]] || [[Image:Screenshot0030.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0034.png|thumb|left]] || [[Image:Screenshot0036.png|thumb|center]] || [[Image:Screenshot0037.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0038.png|thumb|left]] || [[Image:Xmoto01.png|thumb|center]] || [[Image:Xmoto02.png|thumb|right]]<br />
|}<br />
<br />
=Inksmoto Kenttä editorin kuvia=<br />
<br />
<br />
{|<br />
| [[Image:Inksmoto01.png|thumb|left]] || [[Image:Inksmoto02.png|thumb|center]] || [[Image:Inksmoto03.png|thumb|right]]<br />
|-<br />
| [[Image:Inksmoto4.png|thumb|left]]<br />
|}</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Screenshots&diff=4379Screenshots2009-08-01T18:37:51Z<p>Googlebotti: </p>
<hr />
<div>__NOTOC__<br />
<br />
[[pt:Screenshots|Portuguese]]<br />
[[fi:Screenshots|Suomi]]<br />
<br />
=Xmoto screenshots=<br />
<br />
<br />
{|<br />
| [[Image:Screenshot0023.png|thumb|left]] || [[Image:Screenshot0005.png|thumb|center]] || [[Image:Screenshot0018.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0022.png|thumb|left]] || [[Image:Screenshot0020.png|thumb|center]] || [[Image:Screenshot0019.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0025.png|thumb|left]] || [[Image:Screenshot0027.png|thumb|center]] || [[Image:Screenshot0030.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0034.png|thumb|left]] || [[Image:Screenshot0036.png|thumb|center]] || [[Image:Screenshot0037.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0038.png|thumb|left]] || [[Image:Xmoto01.png|thumb|center]] || [[Image:Xmoto02.png|thumb|right]]<br />
|}<br />
<br />
=Inksmoto Level Editor screenshots=<br />
<br />
<br />
{|<br />
| [[Image:Inksmoto01.png|thumb|left]] || [[Image:Inksmoto02.png|thumb|center]] || [[Image:Inksmoto03.png|thumb|right]]<br />
|-<br />
| [[Image:Inksmoto4.png|thumb|left]]<br />
|}</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Screenshots&diff=4378Fi:Screenshots2009-08-01T18:37:26Z<p>Googlebotti: </p>
<hr />
<div>__NOTOC__<br />
<br />
[[pt:Screenshots|Portuguese]] <br />
[[fi:Screenshots|Suomi]]<br />
<br />
=X-Moto kuvia=<br />
<br />
<br />
{|<br />
| [[Image:Screenshot0023.png|thumb|left]] || [[Image:Screenshot0005.png|thumb|center]] || [[Image:Screenshot0018.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0022.png|thumb|left]] || [[Image:Screenshot0020.png|thumb|center]] || [[Image:Screenshot0019.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0025.png|thumb|left]] || [[Image:Screenshot0027.png|thumb|center]] || [[Image:Screenshot0030.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0034.png|thumb|left]] || [[Image:Screenshot0036.png|thumb|center]] || [[Image:Screenshot0037.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0038.png|thumb|left]] || [[Image:Xmoto01.png|thumb|center]] || [[Image:Xmoto02.png|thumb|right]]<br />
|}<br />
<br />
=Inksmoto Kenttä editorin kuvia=<br />
<br />
<br />
{|<br />
| [[Image:Inksmoto01.png|thumb|left]] || [[Image:Inksmoto02.png|thumb|center]] || [[Image:Inksmoto03.png|thumb|right]]<br />
|-<br />
| [[Image:Inksmoto4.png|thumb|left]]<br />
|}</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Fi:Screenshots&diff=4377Fi:Screenshots2009-08-01T18:36:48Z<p>Googlebotti: </p>
<hr />
<div>__NOTOC__<br />
<br />
[[pt:Screenshots|Portuguese]] [[fi:Screenshots|Suomi]]<br />
<br />
=X-Moto kuvia=<br />
<br />
<br />
{|<br />
| [[Image:Screenshot0023.png|thumb|left]] || [[Image:Screenshot0005.png|thumb|center]] || [[Image:Screenshot0018.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0022.png|thumb|left]] || [[Image:Screenshot0020.png|thumb|center]] || [[Image:Screenshot0019.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0025.png|thumb|left]] || [[Image:Screenshot0027.png|thumb|center]] || [[Image:Screenshot0030.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0034.png|thumb|left]] || [[Image:Screenshot0036.png|thumb|center]] || [[Image:Screenshot0037.png|thumb|right]]<br />
|-<br />
| [[Image:Screenshot0038.png|thumb|left]] || [[Image:Xmoto01.png|thumb|center]] || [[Image:Xmoto02.png|thumb|right]]<br />
|}<br />
<br />
=Inksmoto Kenttä editorin kuvia=<br />
<br />
<br />
{|<br />
| [[Image:Inksmoto01.png|thumb|left]] || [[Image:Inksmoto02.png|thumb|center]] || [[Image:Inksmoto03.png|thumb|right]]<br />
|-<br />
| [[Image:Inksmoto4.png|thumb|left]]<br />
|}</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=How_to_validate_a_sprite&diff=4309How to validate a sprite2009-07-21T23:20:45Z<p>Googlebotti: /* Notes */</p>
<hr />
<div>= How to validate =<br />
* Download the image file<br />
* Put it to .xmoto/textures/ where it belongs to<br />
* Edit you theme file xml<br />
* Fix the theme file xml (most probably screwed ;-))<br />
* Re-Upload sprite with your theme xml<br />
* Remove old upload<br />
* Click Validate<br />
<br />
= Notes =<br />
There is a glitch in the website code which causes <br />
* Validating of animated and normal sprites break, the link generated for the website doens't work, so it must be fixed by hand (to be continuted)</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=How_to_validate_a_sprite&diff=4308How to validate a sprite2009-07-20T13:51:57Z<p>Googlebotti: </p>
<hr />
<div>= How to validate =<br />
* Download the image file<br />
* Put it to .xmoto/textures/ where it belongs to<br />
* Edit you theme file xml<br />
* Fix the theme file xml (most probably screwed ;-))<br />
* Re-Upload sprite with your theme xml<br />
* Remove old upload<br />
* Click Validate<br />
<br />
= Notes =<br />
There is a glitch in the website code which causes <br />
* Validating of animated sprites break, the link generated for the website doens't work, so it must be fixed by hand (to be continuted)</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Main_Page&diff=4307Main Page2009-07-20T13:42:19Z<p>Googlebotti: /* Administration */</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 />
* [[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 />
* [[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 />
'''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 />
* [[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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4301Basics of Scripting2009-07-20T05:57:33Z<p>Googlebotti: /* General */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make a explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
Just paste the script and edit the options. :)<br />
<br />
== How-to make a trainer script? ==<br />
Loads of people have been asking about this, it is rather simple. All you need is:<br />
* a keyhook<br />
* an entity (like a sprite)<br />
and here it is:<br />
function OnLoad()<br />
Game.SetKeyHook("1","trainer1") -- create the keyhook on load of the level<br />
return true -- without this x-moto crashes<br />
end<br />
<br />
function trainer1()<br />
x,y=Game.GetEntityPos("entity1") --get position of the entity<br />
--throw the player to the position we just got<br />
Game.SetPlayerPosition(x,y,0) -- the 0 can be set to 1 if you want the player to face right after teleport<br />
end<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to '''comment lines which you think makes the script crash''' and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''' and if you have joined lines with ";" you must break them, that is how you should be able to find the correct line, since the Lua script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4300Basics of Scripting2009-07-20T05:28:02Z<p>Googlebotti: /* General */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make a explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
Just paste the script and edit the options. :)<br />
<br />
== How-to make a trainer script? ==<br />
Loads of people have been asking about this, it is rather simple. All you need is:<br />
* a keyhook<br />
* an entity (like a sprite)<br />
and here it is:<br />
function OnLoad()<br />
Game.SetKeyHook("1","trainer1") -- create the keyhook on load of the level<br />
return true -- without this x-moto crashes<br />
end<br />
<br />
function trainer1()<br />
x,y=Game.GetEntityPos("entity1") --get position of the entity<br />
--throw the player to the position we just got<br />
Game.SetPlayerPosition(x,y,0) -- the 0 can be set to 1 if you want the player to face right after teleport<br />
end<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''' and if you have joined lines with ";" you must break them, that is how you should be able to find the correct line, since the Lua script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4297Basics of Scripting2009-07-14T20:03:02Z<p>Googlebotti: /* How-to make a trainer script? */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make a explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
Just paste the script and edit the options. :)<br />
<br />
== How-to make a trainer script? ==<br />
Loads of people have been asking about this, it is rather simple. All you need is:<br />
* a keyhook<br />
* an entity (like a sprite)<br />
and here it is:<br />
function OnLoad()<br />
Game.SetKeyHook("1","trainer1") -- create the keyhook on load of the level<br />
return true -- without this x-moto crashes<br />
end<br />
<br />
function trainer1()<br />
x,y=Game.GetEntityPos("entity1") --get position of the entity<br />
--throw the player to the position we just got<br />
Game.SetPlayerPosition(x,y,0) -- the 0 can be set to 1 if you want the player to face right after teleport<br />
end<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''', that is how you should be able to find the correct line, since the script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4296Basics of Scripting2009-07-14T19:55:23Z<p>Googlebotti: /* How-to make a trainer script? */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make a explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
Just paste the script and edit the options. :)<br />
<br />
== How-to make a trainer script? ==<br />
Loads of people have been asking about this, it is rather simple. All you need is:<br />
* a keyhook<br />
* an entity (like a sprite)<br />
and here it is:<br />
function OnLoad()<br />
Game.SetKeyHook("1","trainer1") -- create the keyhook on load of the level<br />
return true -- without this x-moto crashes<br />
end<br />
<br />
function trainer1()<br />
x,y=Game.GetEntityPos("entity1")<br />
Game.SetPlayerPosition(x,y,0) -- the 0 can be set to 1 if you want the player to face right after teleport<br />
end<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''', that is how you should be able to find the correct line, since the script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4295Basics of Scripting2009-07-14T19:55:09Z<p>Googlebotti: /* How-to make a teleport-to-entity script? */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make a explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
Just paste the script and edit the options. :)<br />
<br />
== How-to make a trainer script? ==<br />
Loads of people have been asking about this, it is rather simple. All you need is:<br />
* a keyhook<br />
* an entity (like a sprite)<br />
and here it is:<br />
function OnLoad()<br />
Game.SetKeyHook("1","trainer1") -- create the keyhook on load of the level<br />
return true -- without this x-moto crashes<br />
end<br />
<br />
function trainer1()<br />
x,y=Game.GetEntityPos("entity1")<br />
Game.SetPlayerPosition(x,y,0) -- the 0 can be set to 1 if you want the player to face right after teleport<br />
end<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''', that is how you should be able to find the correct line, since the script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4294Basics of Scripting2009-07-14T19:51:09Z<p>Googlebotti: /* How-to make an explore script? */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make a explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
Just paste the script and edit the options. :)<br />
<br />
== How-to make a teleport-to-entity script? ==<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''', that is how you should be able to find the correct line, since the script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4293Basics of Scripting2009-07-14T19:51:00Z<p>Googlebotti: /* How-to make an explore script? */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make an explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
Just paste the script and edit the options. :)<br />
== How-to make a teleport-to-entity script? ==<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''', that is how you should be able to find the correct line, since the script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Wiki_Contributors&diff=4256Wiki Contributors2009-06-24T20:21:59Z<p>Googlebotti: </p>
<hr />
<div>This Wiki can't exist without its contributors:<br />
<br />
* [[User:Googlebotti|tuhoojabotti or googlebotti]] : Multiple wikies for newbies and other tutorials + patches :)<br />
* [[User:Bat de Base-ball|Bat de Base-ball]]<br />
* [[User:Dalai|Dalai]]<br />
* [[User:Elbeem|Elbeem]] : Norwegian translation<br />
* [[User:Flo|Flo]] : German translation (Deutsche Übersetzung)<br />
* [[User:Forquare|Forquare]]<br />
* [[User:Gaivota|Gaivota]]<br />
* [[User:Jacky J|Jacky J]]<br />
* [[User:Jeferson|Jeferson]] : Portuguese translation (Versão em Português)<br />
* [[User:Kiplantt|Kiplantt]]<br />
* [[User:Kudster|Kudster]] : Spanish translation<br />
* [[User:Lapinot|Lapinot]]<br />
* [[User:Lazyass|Lazyass]]<br />
* [[User:Monsieuryaya|Monsieuryaya]]<br />
* [[User:MpJin|MpJin]] : Wiki theme<br />
* [[User:Nadenislamarre|Nadenislamarre]] : Many pages<br />
* [[User:Neckelmann|Neckelmann]]<br />
* [[User:Npmad|Npmad]]<br />
* [[User:Nx|Nx]]<br />
* [[User:Shepard62700FR|Shepard62700FR]] : French translation and keep French part of the wiki updated<br />
* [[User:The only dude|The only dude]] : Inkscape page<br />
* [[User:Trullo|Trullo]] : Catalan and Spanish translation<br />
* [[User:Valentin|Valentin]]<br />
* [[User:YAK|YAK]]<br />
* [[User:Cigam|Cigam]]</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=User:Googlebotti&diff=4255User:Googlebotti2009-06-24T20:21:03Z<p>Googlebotti: /* GoogleBotti */</p>
<hr />
<div>=GoogleBotti=<br />
List of Contributions:<br />
* [http://wiki.xmoto.tuxfamily.org/index.php?title=Jointed_Line Jointed Line (inksmoto)]<br />
* [http://wiki.xmoto.tuxfamily.org/index.php?title=LTS_-_Learn_To_Script_Series LTS - Learn To Script Series]<br />
* [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripted_levels#Timers Script Timers]<br />
* [http://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting Basics of Scripting]<br />
* [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripted_levels#GetPlayerVelocity.28player.29 Game.GetPlayerAngle/Velocity/Speed(player)]<br />
* [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Scripting Dictionary]<br />
* Lots of scripts made for other people.<br />
<br />
See my [http://wiki.xmoto.tuxfamily.org/index.php?title=Special:Contributions/Googlebotti contribution log].</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Scripted_levels&diff=4254Scripted levels2009-06-24T19:52:44Z<p>Googlebotti: /* Functions called by XMoto */</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 />
=== Script Example ===<br />
timer={} --declare the timer<br />
function OnLoad()<br />
Game.StartTimer("timer",100,0) --create the timer<br />
Game.StartTimer("timer") -- is equal to the one above because defaults are 100 and 0<br />
- delay - 100 is equal to 1 second 1000 = 10 seconds and so on<br />
- loops - 0 means infinite more means that amount of loops is done and then the timer is deleted<br />
Game.StopTimer("timer") --now we stop the timer<br />
Game.StartTimer("timer") --now the timer is restarted, but not re-created.<br />
Game.StartTimer("timer",200,2) --now we reset the timer to delay of 2s and only to make 2 loops <br />
return true<br />
end<br />
--once the timer is created x-moto will update it and call this function<br />
-- name.Tick(loops) every time the delay has passed, loops=amount of loops<br />
-- done so far<br />
function timer.Tick(loops) <br />
if loops==1 then Game.Message("first loop!") end<br />
if loops==2 then Game.KillPlayer() end -- after 4 seconds (delay 200 and 2 loops) we kill the player!<br />
end<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 />
== 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>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4253Basics of Scripting2009-06-22T11:22:40Z<p>Googlebotti: /* How-to make an explore script? */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make an explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
Just paste the script and edit the options. :)<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''', that is how you should be able to find the correct line, since the script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4252Basics of Scripting2009-06-22T11:22:11Z<p>Googlebotti: /* How-to make an explore script? */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make an explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
Just edit the options and paste the script. :)<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''', that is how you should be able to find the correct line, since the script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4251Basics of Scripting2009-06-22T11:21:31Z<p>Googlebotti: /* How-to make an explore script? */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make an explore script? ==<br />
I found this script from aeRo - Crazy Elevator. This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aeRo<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''', that is how you should be able to find the correct line, since the script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4250Basics of Scripting2009-06-22T11:19:10Z<p>Googlebotti: /* How-To Section */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
<br />
== How-to make an explore script? ==<br />
This is pretty easy, just need:<br />
* Zone called 'zone_explore'<br />
* few variables:<br />
**canexplore = false<br />
**isexploring = false<br />
**explored_x = 0<br />
**explored_y = 0<br />
**move_step = 5<br />
**limit_right = 20<br />
**limit_left = 0<br />
**limit_up = 3<br />
**limit_down = 2<br />
**explore_zoom=0.15<br />
Here is the script:<br />
--EXPLORE SCRIPT<br />
--original script by aero<br />
--wikied + options added by tuhoojabotti 22.06.2009<br />
--BASE<br />
zone_explore = {}<br />
--states<br />
canexplore = false<br />
isexploring = false<br />
--position<br />
explored_x = 0<br />
explored_y = 0<br />
--OPTIONS<br />
--how much to move on single stroke<br />
move_step = 5<br />
--how many times u can move to x direction<br />
limit_right = 67<br />
limit_left = 0<br />
limit_up = 3<br />
limit_down = 2<br />
--zoom in explore mode<br />
explore_zoom=0.15<br />
<br />
function OnLoad()<br />
Game.SetKeyHook("E", "explore")<br />
Game.SetKeyHook("A", "explore_left")<br />
Game.SetKeyHook("S", "explore_down")<br />
Game.SetKeyHook("D", "explore_right")<br />
Game.SetKeyHook("W", "explore_up") <br />
return true<br />
end<br />
--EXPLORE ZONE<br />
function zone_explore.OnEnter()<br />
Game.Message("Press E to explore the level.")<br />
canexplore = true<br />
end<br />
function zone_explore.OnLeave()<br />
cancel_explore()<br />
canexplore = false<br />
end<br />
function explore()<br />
if canexplore == true and isexploring == false then<br />
explored_x = 0<br />
explored_y = 0<br />
isexploring = true<br />
Game.CameraZoom(-explore_zoom)<br />
Game.ClearMessages()<br />
Game.Message("Press W,A,S,D to explore.")<br />
Game.Message("E again to cancel.")<br />
elseif isexploring == true then<br />
cancel_explore()<br />
end<br />
end<br />
function cancel_explore()<br />
if isexploring == true then<br />
isexploring = false<br />
Game.ClearMessages()<br />
Game.CameraMove(-explored_x, -explored_y)<br />
Game.CameraZoom(explore_zoom)<br />
end<br />
end<br />
--MOVING EXPLORE<br />
function explore_left()<br />
if isexploring == true and explored_x ~= limit_left*move_step then<br />
Game.CameraMove(-move_step, 0)<br />
explored_x = explored_x - move_step<br />
end<br />
end<br />
function explore_right()<br />
if isexploring == true and explored_x ~= limit_right*move_step then<br />
Game.CameraMove(move_step, 0)<br />
explored_x = explored_x + move_step<br />
end<br />
end<br />
function explore_up()<br />
if isexploring == true and explored_y ~= limit_up*move_step then<br />
Game.CameraMove(0, move_step)<br />
explored_y = explored_y + move_step<br />
end<br />
end<br />
function explore_down()<br />
if isexploring == true and explored_y ~= -limit_down*move_step then<br />
Game.CameraMove(0, -move_step)<br />
explored_y = explored_y - move_step<br />
end<br />
end<br />
<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''', that is how you should be able to find the correct line, since the script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebottihttps://wiki.xmoto.tuxfamily.org/index.php?title=Basics_of_Scripting&diff=4249Basics of Scripting2009-06-22T10:59:39Z<p>Googlebotti: /* General */</p>
<hr />
<div>= Introduction =<br />
This tutorial explains how to write clean script and how to make some things. Please see the [http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary Dictionary] for more information about each keywords.<br />
<br />
= Clean Script =<br />
I've seen horrible scripts. So I decided to make a style guideline here.<br />
== Indent ==<br />
Indenting your script makes it '''much more readable'''. Compare the following scripts:<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
and<br />
function lol()<br />
if wut==1 then<br />
if lolwut==2 then<br />
Game.KillPlayer()<br />
end<br />
end<br />
end<br />
<br />
Makes it easier to see if you forget an end for example. ;-)<br />
== Comments ==<br />
You should comment your script so that someone who could be interested how this is done could understand the script, but don't comment too much because that makes the script messy.<br />
...<br />
if somevar==2 then -- here we see if the player plaaplaaplaa...<br />
...<br />
<br />
== Other ==<br />
=== You can use ";" to join lines without linechange ===<br />
This is okay:<br />
zone1={};visited1=0"<br />
But do not connect too many lines.<br />
<br />
=== Please, do not put if and then on separate lines ===<br />
if somevar!=something<br />
then<br />
...<br />
Instead:<br />
if lol==1 then<br />
...<br />
Using the () in the if is optional:<br />
if(lol==1)then<br />
...<br />
<br />
= How-To Section =<br />
Here we collect how to scripts. like "How-to make an elevator?" or "How-to make a jump button?"<br />
<br><br><br />
You can't download example levels because this wiki doesn't allow me to upload .lvl files anymore: "This file contains HTML or script code that may be erroneously be interpreted by a web browser.". I know it sucks. It's just xml with some lua.<br />
<br />
== How-to make an elevator? ==<br />
What we need:<br />
* a dynamic block<br />
* the block id must be "blockele1"<br />
* a zone, id "zoneele1"<br />
<br />
The Script:<br />
zoneele1={}<br />
function zoneele1.OnEnter() -- when we enter the zoneele it starts the elevator.<br />
h=10 --height (how much up we go)<br />
speed=2000 -- how long it takes to go there (speed depends on the h)<br />
wait=200 -- how long to wait before starting the elevator (200=2s)<br />
Game.SetDynamicBlockTranslation("blockele1",0,h,speed,wait,wait+(speed/2))<br />
end<br />
<br />
You can edit the ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variables]'' to fit your needs.<br />
Here you can download an example level: [[Media:elevator.lvl]]<br />
<br />
== How-to make a jump key? ==<br />
This is easy, it can be done purely with script.<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
With that script the player can cheat and jump even when on air. We want the player only to be allowed to jump when on ground again. So we need a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to see if the player has jumped already:<br />
hasjumped=true --you can use 1 as well<br />
function OnLoad()<br />
Game.SetKeyHook("J","Jump") -- bind the J key to the Jump function below<br />
return true<br />
end<br />
function Jump()<br />
if hasjumped==false then<br />
hasjumped=true<br />
Game.AddForceToPlayer(0,10000,0,10,0)<br />
end<br />
end<br />
function OnWheel2Touchs(bStatus) --rearwheel<br />
if bStatus==1 then -- only when touching not when leaving the ground<br />
hasjumped=false --we touch the ground so we must be jumped.<br />
end<br />
end<br />
Here you can download an example level: [[Media:jump.lvl]]<br />
== How-to make zoom buttons? ==<br />
Zooming is somewhat easy, but it recuires some script to do, I have this old piece of script I got from Lothar's level, I've changed it to be more configurable. You can use it as it is, just remember to leave the comments about the creators of the script there :)<br />
--original script by Lothar<br />
--upgraded by Tuhoojabotti 18.12.2008<br />
<br />
--settings<br />
zoomlevel = 1 --default zoom<br />
blockzoom = 0 --enable/disable zoom 0=enabled<br />
zoominbutton="I" <br />
zoomoutbutton="O"<br />
maxzoomout=4 --strokes<br />
maxzoomin=0 --strokes<br />
step=0.05 --amount of zoom per stroke<br />
<br />
function OnLoad()<br />
Game.Message("Press "..zoominbutton.." to zoom in")<br />
Game.Message("Press "..zoomoutbutton.." to zoom out")<br />
Game.SetKeyHook(zoominbutton, "ZoomIn")<br />
Game.SetKeyHook(zoomoutbutton, "ZoomOut")<br />
return true<br />
end<br />
<br />
function ZoomIn()<br />
if zoomlevel==maxzoomin then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom in any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(step)<br />
zoomlevel = zoomlevel-1<br />
end<br />
end<br />
end<br />
<br />
function ZoomOut()<br />
if zoomlevel==maxzoomout then<br />
Game.ClearMessages()<br />
Game.Message("Can't zoom out any further.")<br />
else<br />
if blockzoom==0 then<br />
Game.CameraZoom(-step)<br />
zoomlevel = zoomlevel+1<br />
end<br />
end<br />
end<br />
<br />
== How-to make readable signs? ==<br />
You need:<br />
* Entities, like: sign1, sign2, sign3, ...<br />
* Zones, like: signz1, signz2, signz3, ...<br />
* a ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Variable variable]'' to hold the sign texts; SignText=""<br />
* and a keyhook for the Read function<br />
'''Zones:'''<br />
SignText="No signs here..."<br />
signz1={}--;signz2={};signz3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all zones...<br />
function signz1.OnEnter()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
function signz1.OnLeave() --this is optional<br />
SignText="No signs here..."<br />
end<br />
--end repeat block<br />
<br />
Somewhat easier way is to use Entity.Touch() ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]'', which doesn't have leave support, but then you can dump the zones.<br />
<br>'''Entities:'''<br />
SignText="No signs here..."<br />
sign1={}--;sign2={};sign3={};...<br />
<br />
function OnLoad()<br />
Game.Message("Hello, you can read signs with 'R' key.")<br />
Game.SetKeyHook("R","Read")<br />
return true<br />
end<br />
<br />
function Read() --read teh sign<br />
Game.Message(SignText)<br />
end<br />
<br />
--repeat this for all entities...<br />
function sign1.Touch()<br />
SignText="This is the Sign1 it says: plaaplaaplaplapal..."<br />
end<br />
--end repeat block<br />
= Debugging =<br />
== General ==<br />
Basically debugging means figuring out what makes the script behave unwanted ways or fix crashing. It is a good way to comment lines which you think makes the script crash and then start uncommenting then line by line till you find the crash spot, then try to figure out what is wrong:<br />
* typo (spelling error)<br />
* invalid ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Parameter parameter]'' in ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Function function]'' call<br />
* block not existing<br />
* block not dynamic<br />
* dynamic block in wrong layer<br />
<br />
If some action doens't work but doesn't crash either try using Game.Message("debug") to see if the script is ever even executed. In X-Moto scripts the '''script must be in an ''[http://wiki.xmoto.tuxfamily.org/index.php?title=Scripting_Dictionary#Event event]''''' otherwise the script is never executed.<br />
<br />
If you get an error with '''line number''' then to find the exact line, '''count''' the script's lines '''ignoring all empty lines''', that is how you should be able to find the correct line, since the script parser removes empty lines before executing the script.<br />
<br />
== Err. SetDynamicBlockTranslation crashes ==<br />
Check that blocks all blocks are '''dynamic''' and in the '''main layer'''. Also look for '''typos''' in script. If the level has 2 or more main layers then the block must be in the '''original main layer'''.<br />
<br />
== Err. Zone.OnEnter fails ==<br />
Is the zone '''defined''' at the start of the level like: Zone={}? X-Moto don't know to call the OnEnter function if you haven't defined it.</div>Googlebotti