LuaGuide.wiki
changeset 32 5f66adfa478c
parent 31 e713a5d2a7f9
child 35 532bb2509f0b
equal deleted inserted replaced
31:e713a5d2a7f9 32:5f66adfa478c
     7 == What is a Lua script ==
     7 == What is a Lua script ==
     8 
     8 
     9 A Lua script is used to make the game behave different by giving the Hedgewars engine different command. The script gets called by the engine on different events and the script tells the engine what to do.
     9 A Lua script is used to make the game behave different by giving the Hedgewars engine different command. The script gets called by the engine on different events and the script tells the engine what to do.
    10 
    10 
    11 Missions and Training are the parts of Hedgewars that are scripted. Try them out and get a feel of what scripted maps is.
    11 Missions and Training are the parts of Hedgewars that are scripted. Try them out and get a feel of what scripted maps is.
       
    12 
       
    13 == The basic structure ==
       
    14 
       
    15 Dependent on what type of script you want to write the requirements are a bit different, but before we go into that we must first create the .lua file.
       
    16 
       
    17 If you want to make a Mission for multi player you create a map and create a new file map.lua in the map's folder.
       
    18 
       
    19 If you want to make a Training or Campaign (coming) then you create a new .lua file in the appropriate folder under Missions in the Data folder.
       
    20 
       
    21 The .lua file should be structured like this:
       
    22 {{{
       
    23 function onGameInit()
       
    24 end
       
    25 
       
    26 function onAmmoStoreInit()
       
    27 end
       
    28 
       
    29 function onGameStart()
       
    30 end
       
    31 
       
    32 function onGameTick()
       
    33 end
       
    34 
       
    35 function onGearAdd(gear)
       
    36 end
       
    37 
       
    38 function onGearDelete(gear)
       
    39 end
       
    40 }}}