LUA scripting function-of-the-week


#1

I thought I might start a new thread so that we can ask the devs what some of the (so far) undocumented script functions do and how they work.

For starters, I’d like to ask about the addAxisAlignBox function.

It goes in level files, but I have no clue what it does. Can a dev please explain its purpose and usage? Thanks!


(BitVenom) #2

I can give you an quick ‘non-expert’ answer:

It does exactly what it says - adds an AAB to the scene. This named object can be used to level logic to check if things are inside of it - or I think to trigger if they leave/enter it - just like Sphere and such. You shouldn’t have any trouble taking the name you see from one being used and finding level script that makes reference to it.


#3

What are the three parameters it takes? The name of the volume, its center coordinates and its radius? Also I don’t understand what is being “aligned”. Is it used to point ships in a certain direction?


(BitVenom) #4

An AAB is a very literally named thing - a box aligned to the axis:

  • Name
  • Min XYZ
  • Max XYZ

So the box is ‘aligned’ to the axis XYZ - not rotated at all. A rectangular volume of space…


(Carmaster) #5

What this method does is create an imaginary bounding box aligned to the XYZ axes (0 pitch, 0 yaw and 0 roll), and it is used as a trigger to detect wheter is something inside it, like BitVenom pointed out.

The name is obvious and the other two parameters are the coordinates (3DVector) of the bottom left corner and top right corner of the box.


#6

The third parameter is not a vector, however. It’s a float.

addAxisAlignBox(“HighZone2”, {-26349.75, -2881.55, -12297.6}, 10150)


(BitVenom) #7

Weird, I didn’t write it (or use it) - lemme go see for ya, sorry!


(BitVenom) #8

Ah, yeah - the last float is ‘size’ - So you were pretty dead on…

  • Name
  • Center
  • Size

So for example:

addAxisAlignBox("Test", {500, 400, 300}, 50)

Makes a box from { 450, 350, 250 } -> { 550, 450, 350 }

Easy peasy!


#9

Thanks! I think I get it now.

I look forward to finding more scripts. It seems you guys added a lot!


#10

Today’s function is: SaveDetGame. It’s a UI function.

What is the difference between this function and SaveGame? Does “Det” mean “deterministic”? What parameters does it take?


#11

No response, so let’s look at another function today:

addDustCloudWithResources(name, type, position, ?, color, ?, ?, ?)

What are the parameters marked with a “?”?

The first one might be resource value. The second-to-last might be the radius. But I’m not sure.


(Christoph Timmermann) #12

Just thought I’d throw this in here:
(all of these are meant to be in .level files)

addAsteroid(string type, table position, float multiplier, float rotX, float rotY, float rotZ, float rotSpeed)
addPoint(string name, table position, table rotation)
addPebble(string type, table position, float rotX, float rotY, float rotZ)
addDustCloud(string name, string type, table position, table color, float spin, float radius)
addDustCloudWithResources(string name, string type, table position, float resources, table color, float spin, float radius, int refill)
addSquadron(string name, string type, table position, int player, table rotation, int shipCount, int inHyperspace)
addCloud(string name, string type, table position, table color, float spin, float radius)
addNebula(string name, string type, table position, table color, float spin, float radius)
addNebulaWithResources(string name, string type, table position, float resources, table color, float spin, float radius, int refill)
addSphere(string name, table position, float radius)
addCamera(string name, table position, table target)
addSalvage(string type, table position, float resources, float rotX, float rotY, float rotZ, float unknown)
addPath(string name, params string[] points)
addReactiveFleetSlot(string sobGroup, int player, int unknown, table position, float rotX, float rotY, float rotZ, string type)
addReactiveFleetResourceSlotDustCloud(string name, string type, table position, float red, float green, float blue)
addReactiveFleetResourceSlot(string type, table position, float rotX, float rotY, float rotZ)
addAxisAlignBox(string name, table position, float size)
addSensorsPlane(float distance, float factor, table color)

createSOBGroup(string name)
addToSOBGroup(string squadronName, string sobGroupName)

setObjectAttributes(float unknown, float unknown2)

setWorldBoundsInner(table center, table dimensions)
setWorldBoundsOuter(table center, table dimensions)

fogSetActive(int active)
fogSetStart(float start)
fogSetEnd(float end)
fogSetColour(float red, float green, float blue, float alpha)
fogSetType(string type)
fogSetDensity(float density)
fogAddInterpolator(string buffer, float duration, float target)

loadBackground(string name)
setSensorsManagerCameraDistances(float min, float max)
setDefaultMusic(string path)
setBattleMusic(string path)
setGlareIntensity(float intensity)
setLevelShadowColour(float red, float green, float blue, float alpha)
setDustCloudAmbient(table color)
setDustCloudColour(table color)
setNebulaAmbient(table color)

(Taiidan Republic Mod) #13

Nice answer, did it take you 4 years to work out :wink: