Editing MG/Lua

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 140: Line 140:
 
'''unitID''' - The ID of the unit to give the kills to.<br />
 
'''unitID''' - The ID of the unit to give the kills to.<br />
 
'''amount''' - The number of kills given.
 
'''amount''' - The number of kills given.
 
===getUnitProperty(unitId,typeId)===
 
Returns the value of the type of the unit.
 
The type can be a number between 1 and 5.
 
1=hp
 
2=ep
 
3=level
 
4=field
 
5=skill
 
 
getUnitProperty is dedicated for hp,ep and field. For skill and level see getUnitPropertyName(unitId,typeId).
 
 
===getUnitPropertyName(unitId,typeId)===
 
Returns the name of the type of the unit.
 
The type can be a number between 1 and 5.
 
1=hp
 
2=ep
 
3=level
 
4=field
 
5=skill
 
 
getUnitPropertyName is dedicated for skill and level. For hp,ep and field see getUnitProperty(unitId,typeId).
 
  
 
===selectUnit(unitID)===
 
===selectUnit(unitID)===
Line 216: Line 194:
 
Parameters:<br />
 
Parameters:<br />
 
'''pos''' - an array of two elements, specifying the co-ordinates {x,y}.
 
'''pos''' - an array of two elements, specifying the co-ordinates {x,y}.
 
=== shakeCamera(intensity, duration) ===
 
Causes the camera to shake.
 
 
Parameters:<br />
 
'''intensity''' - Intensity of the shaking effect<br />
 
'''duration''' - Duration of the shaking effect in update frames (40 equals one second)
 
 
=== shakeCameraOnUnit(intensity, duration, unitId) ===
 
Same as above, but the shake intensity is affected by the distance between camera and unit.
 
Useful if the camera should only shake, when the unit is in sight.
 
 
Parameters:<br />
 
'''intensity''' - Intensity of the shaking effect<br />
 
'''duration''' - Duration of the shaking effect in update frames (40 equals one second)<br />
 
'''unitId''' - Unit ID of the unit, which should influence the shake intensity
 
  
 
===togglePauseGame(pauseStatus)===
 
===togglePauseGame(pauseStatus)===
Line 265: Line 227:
  
 
===getIsDayTime()===
 
===getIsDayTime()===
Returns if it is day ingame. ( 1 is day and 0 is night )
+
Returns if it is day. ( 1 is day and 0 is night )
 
 
===getIsNightTime()===
 
Returns if it is night ingame. ( 1 is night and 0 is day )
 
 
 
===getTimeOfDay()===
 
Returns the ingame time of the day.
 
  
 
=== storeSaveGameDate(key, value) ===
 
=== storeSaveGameDate(key, value) ===
Line 424: Line 380:
 
</dayNightTriggerEvent>
 
</dayNightTriggerEvent>
 
</syntaxhighlight>
 
</syntaxhighlight>
 
===unregisterDayNightEvent()===
 
Disables the Day/Night Event.
 
  
 
===triggeredEventAreaEntryUnitId()===
 
===triggeredEventAreaEntryUnitId()===
Line 433: Line 386:
 
===triggeredEventAreaExitUnitId()===
 
===triggeredEventAreaExitUnitId()===
 
Returns the unit ID of the unit who exited a registered cell area trigger event.
 
Returns the unit ID of the unit who exited a registered cell area trigger event.
 
===lastUnitTriggerEventUnit()===
 
Returns the ID of the Unit which triggered the UnitTriggerEvent.
 
 
===lastUnitTriggerEventType()===
 
Returns the ID of property which changed.
 
1=hp
 
2=ep
 
3=level
 
4=field
 
5=skill
 
  
 
===getCellTriggerEventCount(eventID)===
 
===getCellTriggerEventCount(eventID)===
Line 459: Line 401:
 
Parameters:<br />
 
Parameters:<br />
 
'''eventID''' - the ID of a previously registered event.
 
'''eventID''' - the ID of a previously registered event.
 
===registerUnitTriggerEvent(unitId)===
 
Registers a unit trigger event for a unit which will be triggered if one of his properties changes.
 
 
Example:
 
<syntaxhighlight lang="lua">
 
<startup>
 
    createUnit('battle_machine', 1, startLocation(1))
 
 
    player2_battlemachine= lastCreatedUnit()
 
    registerUnitTriggerEvent(player2_battlemachine)
 
</startup>
 
<unitTriggerEvent>
 
    if player2_battlemachine == lastUnitTriggerEventUnit() then
 
                       
 
        if lastUnitTriggerEventType() == 1 then -- hp changed
 
            print('Unit hp is now: ' .. getUnitProperty(lastUnitTriggerEventUnit(),lastUnitTriggerEventType()))
 
        elseif lastUnitTriggerEventType() == 2 then -- ep changed
 
            print('Unit ep is now: ' .. getUnitProperty(lastUnitTriggerEventUnit(),lastUnitTriggerEventType()))
 
        elseif lastUnitTriggerEventType() == 3 then -- level changed
 
            print('Unit level is now: ' .. getUnitPropertyName(lastUnitTriggerEventUnit(),lastUnitTriggerEventType()))
 
        elseif lastUnitTriggerEventType() == 4 then -- field changed
 
            print('Unit field is now: ' .. getUnitProperty(lastUnitTriggerEventUnit(),lastUnitTriggerEventType()))
 
        elseif lastUnitTriggerEventType() == 5 then -- skill changed
 
            print('Unit skill is now: ' .. getUnitPropertyName(lastUnitTriggerEventUnit(),lastUnitTriggerEventType()))
 
        end
 
    end
 
</unitTriggerEvent>
 
</syntaxhighlight>
 
 
===unregisterUnitTriggerEvent(unitId)===
 
Unregisters the unit trigger event for a unit.
 
  
 
===startTimerEvent()===
 
===startTimerEvent()===
Line 719: Line 629:
 
Code here will be executed whenever the scenario is started.
 
Code here will be executed whenever the scenario is started.
 
-->
 
-->
</global>
+
<global>
 
<onSave>
 
<onSave>
 
<!--
 
<!--
 
Code here will be executed when the game is about to save.
 
Code here will be executed when the game is about to save.
 
-->
 
-->
</onSave>
+
<onSave>
 
<onLoad>
 
<onLoad>
 
<!--
 
<!--
 
Code here will be executed when the savegame got loaded.
 
Code here will be executed when the savegame got loaded.
 
-->
 
-->
</onLoad>
+
<onLoad>
 
<startup>
 
<startup>
 
<!--
 
<!--
 
Code here will be executed once on startup.
 
Code here will be executed once on startup.
 
-->
 
-->
</startup>
+
<startup>
 
<unitCreatedOfType type="unitname">
 
<unitCreatedOfType type="unitname">
 
<!--
 
<!--
Line 790: Line 700:
 
[[Category:Scenarios]]
 
[[Category:Scenarios]]
 
[[Category:Lua]]
 
[[Category:Lua]]
[[Category:XMLs]]
 

Please note that all contributions to MegaGlest are considered to be released under the Creative Commons Attribution Share Alike (see MegaGlest:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)