Animation-CobLuaDifferences

From Spring
Jump to navigationJump to search

Overview of differences between COB unit scripts and Lua unit scripts

  • Units of measurement: Lua uses elmos and radians consistently.
  • Coordinate system: In Lua, coordinate system is same as world coordinate system, with all rotations right-handed. In COB, the moves along the x-axis and rotations around the z-axis have a different sign.
  • In Lua, Killed gets recentDamage and maxHealth as separate arguments. In COB, you get only the ratio recentDamage/maxHealth*100.
  • Where COB uses SetMaxReloadTime, Lua uses GetMaxReloadTime.
  • Where COB uses QueryLandingPadCount and QueryLandingPad, Lua uses QueryLandingPads
  • The x and z arguments to HitByWeapon, HitByWeaponId and RockUnit are given in (x, z) order in Lua, and the opposite order in COB.
  • BeginTransport and EndTransport take the height of the unit in COB and the unitID in Lua. (Use 'local height = Spring.GetUnitHeight(unitID)' to get the height.)
  • TransportDrop gets PACKXZ(x,z) in COB; in Lua, it gets the entire vector (x, y, z) as three arguments.
  • Where COB uses SetSpeed and SetDirection, Lua uses WindChanged and ExtractionRateChanged.
  • Lua does not have Go (this is called for activated extractors immediately after each SetSpeed call.)

Hints

  • COB & LUS (LuaUnitScripts) can be reloaded ingame via /reloadcob %unitdefname, also LUS get reloaded with /luarules reload, too.