Lua_Notes

If you have CommandWalkers in your mission, you usually have to do something like this:

ClearWalkers()

AddWalkerType(2, <count>)

SetMemoryPoolSize("CommandWalker", <count>)

This creates an unnecessary walker slot which never gets used, wasting memory.

Well, you can be clever:

ClearWalkers()

SetMemoryPoolSize("EntityWalker", -<count>)

AddWalkerType(2, <count>)

SetMemoryPoolSize("CommandWalker", <count>)

(Note the "-" in the EntityWalker pool)

This will eliminate those unused slots.

I've added a setting to the lua mission scripts that tells the AI the mission is urban. This allows the AI to change some combat behaviors to be more suitable to an urban environment (for example, ATST will not move as much around during combat, since in a tight urban setting they will collide with walls too much).

I've added the setting to all current lua files, so you will only need to add it to any new lua mission files you create:

SetUrbanEnvironment("true")

or

SetUrbanEnvironment("false")

I've renamed the script function, "SetUrbanEnvironment" to "SetDenseEnvironment" since I realized with Endor that I wanted the AI vehicles to behave in the same way in forested environments as in city environments. The new function name generalizes the environment type better. I've updated all the lua scripts with this new function name.

A useful console command is "setcontrols 0" to disable player movement. This way you can fly around in freecam whilst keeping the player stationary.

"setcontrols 1" will turn player control back on

Map.displayall 1 will make the map display info for all teams (e.g. displays all units)

(Map.displayall 0 will turn it back off)

Not sure if I mentioned this new keyboard command to you....

ai.showhints 1 will display hint nodes in game

I've added a couple of new lua commands:

SetPlayerTeamDifficulty( value )

SetEnemyTeamDifficulty( value )

where value can be between 1 (dumbest) and 20 (smartest)

I've added support for the Historical campaign lua commands:

SetPlayerTeamDifficultyEasy

SetEnemyTeamDifficultyEasy

SetPlayerTeamDifficultyMedium

SetEnemyTeamDifficultyMedium

SetPlayerTeamDifficultyHard

SetEnemyTeamDifficultyHard

Note that Lua DOES NOT accept the "+" sign, so do not do:

SetPlayerTeamDifficultyEasy(+5)

Instead, do

SetPlayerTeamDifficultyEasy(5)

Of course, you can use the "-" sign,

SetPlayerTeamDifficultyEasy(-5)

Screen fade info:

I added the screen fade for the uta lua scripting, like this:

BeginScreenTransition(0, 0.4, 0.5, 0.7, "FADE", "FADE")

The numbers for this are: (in order)

viewport (0) - should be 0 for single player mode

Fade in time (0.4) - the time it takes to fade from normal to fully black

Fade hold time (0.5) - the time it stays at full black

Fade out time (0.7) - the time to fade from black back to normal

Fade in effect ("FADE") - "FADE" is all that works now. (Xbox has "SWIPE_RAND" also)

Fade out effect ("FADE")

So the example above will fade from normal to black in 0.4 seconds, stay there for 0.5 seconds, then fade back to normal in 0.7 seconds.