Posted by Data in Cortex Command - April 3rd, 2009

Contrary to what some have feared, we have been working (albeit slowly) on Cortex Command during and after the GDC madness. The biggest new feature for Build 23 is the ability to attach Lua scripts to not only the Missions, but any MovableObject in the game!

In the ini definition of any Preset in the game, an optional line can be added to make any object of that Preset load and use a script file:

AddAmmo = AEmitter
  PresetName = Destroyer Cannon Shot
  ScriptPath = Dummy.rte/Devices/Weapons/Launchers/Destroyer.lua

The test script file Destroyer.lua looks like this – try to figure out what it does to the projectile:

function Create(self)
  print("CREATED: " .. self.PresetName);
  self.testTimer = Timer();

function Destroy(self)
  print("DESTROYED: " .. self.PresetName);

function Update(self)
  if self.testTimer:IsPastSimMS(1500) then
    self.Vel = self.Vel + Vector(0, 1);

That simple! You can attach any data or timers or whatever you wish to the object, and since almost the entire C++ engine is exposed to the Lua state, modders will have a LOT of power to play with! You will be able to come up with completely new, custom logic for how anything and everything should behave. Want homing bullets? Custom AI behavior? Crazy special effects? No problem!

Next up is to get get the documentation for all the Lua bindings in the engine made. It’s all about scraping the C++ source for the thorough documentation and spitting it out to legible files, but we’re not far off.

You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.

159 Responses to “Script Everything!”

  1. Luiz Fernando - # April 27th, 2009 at 5:54 pm

    So, now will I be able to create my Portal gun?

    AWESOME! 😀

  2. guiguito - # April 28th, 2009 at 9:35 am

    Holy shit data,at least put some preview.

  3. Reed1000 - # April 28th, 2009 at 2:03 pm

    I understand this would take along time but I think it would make everybody happy to know at least a guess to when it might be out even if it’s wrong/a lie it gives us something to look forward to and keeps everybody’s mouth shut

  4. Octyl - # April 28th, 2009 at 4:11 pm

    Devlog should be more like this.

  5. Reed1000 - # April 28th, 2009 at 10:48 pm

    Yes and Yes

  6. Warman - # April 29th, 2009 at 5:56 am

    I don’t even think Data is reading beyond the first 15 comments.

  7. gismo - # April 29th, 2009 at 10:30 am

    lets drop da napalm the we giggle and watch (not realy we would cry for our fellow humen well they would die anyway…)

  8. gismo - # April 29th, 2009 at 10:31 am

    sorry fow the last post all mexicans 😛

  9. Bremze - # April 29th, 2009 at 11:52 am

    And I would too, if I liked the leftovers of my sanity.