
Posts: 3822
Joined: 16 Sep 2007, 22:00
KaM Skill Level: Skilled
ICQ: 269127056
Website: http://lewin.hodgman.id.au
Yahoo Messenger: lewinlewinhodgman
Location: Australia
Script changes in RC3
RC3 will see some major changes to the dynamic scripting system, and seeing as lots of people are trying out scripting and making their own missions I thought I should explain the changes. At the moment we're still in beta so we feel it's okay to make changes like this which require everyone to fix their scripts, but for official releases we'll try to keep the backwards compatibility a bit better.
Text and translations
We've changed the way you fetch text from the LIBX translation files. Instead of using States.Text and States.TextFormatted you now use "markup" to fetch strings: If you've set text ID 1 to 'Translated Message' then that command will display to player 5:
'Some text before my translated bit Translated Message some text after'
So each <$123> gets replaced with the corresponding text from the LIBX file (text ID 123 in that case).
Why did we do this? Because it's a bad idea to let the script access text directly from the translations. It could cause errors in multiplayer because the code could run differently depending on your language (for example "if States.Text(1) = 'something' then"). That was also the reason why strings weren't allowed as global variables in the past, because they would cause save files to become inconsistent.
The text related commands have changed because of this:
- Removed: States.Text and States.TextFormatted
- Renamed: Actions.SetOverlayText to Actions.OverlayTextSet
- Added: Actions.OverlayTextSetFormatted
- Added: Actions.OverlayTextAppend
- Added: Actions.OverlayTextAppendFormatted
- Added: Actions.ShowMsgFormatted
New types allowed as global variables
You can now use the follow types as global variables:
- Enumerations
- Sets
- Records (like struct from C)
- Dynamic arrays (non-fixed length)
- Strings
- Multi-dimensional arrays
- Code:
type TDay = (dMon, dTue, dWed, dThu, dFri, dSat, dSun); TMyFancyRecord = record BusyDays: set of TDay; MyName: string; FavouriteDay: TDay; end; var AllTheThings: array of array of TMyFancyRecord; procedure OnMissionStart; var I: Integer; begin //Allocate space in arrays //After these lines the maximum element you can access would be: AllTheThings[2][5] SetLength(AllTheThings, 3); for I:=0 to 2 do SetLength(AllTheThings[I], 6); AllTheThings[0][0].MyName := 'Lewin'; AllTheThings[0][0].FavouriteDay := dTue; AllTheThings[0][0].BusyDays := [dMon, dThu, dSat, dSun]; end; procedure OnTick; begin if dSun in AllTheThings[0][0].BusyDays then Actions.OverlayTextSet(-1, AllTheThings[0][0].MyName + ' is busy on Sunday'); end;
New commands
- States.UnitDirection
- States.HouseSchoolQueue
- States.HouseWeaponsOrdered
- States.GetAllUnits
- States.GetAllHouses
- States.GetAllGroups
- States.GroupColumnCount
- States.HouseIsComplete
- States.IsFieldAt
- States.IsWinefieldAt
- States.IsRoadAt
- States.PlayerWareDistribution
- Actions.HouseWeaponsOrderSet
- Actions.HouseSchoolQueueRemove
- Actions.GiveWeapons
- Actions.PlayerAddDefaultGoals
- Actions.PlayWAV
- Actions.PlayWAVAtLocation
- Actions.PlayerWareDistribution
- Actions.PlayerShareFog
- Actions.PlanRemove
- Actions.HouseDisableUnoccupiedMessage
- Actions.AIRecruitLimit
- Added parameter "Silent" to Actions.HouseDestroy
- -1 can be used to mean "all players" in the following commands:
- States.IsFieldAt
- States.IsWinefieldAt
- States.IsRoadAt
- Actions.OverlayTextSet
- Actions.OverlayTextSetFormatted
- Actions.OverlayTextAppend
- Actions.OverlayTextAppendFormatted
- Actions.ShowMsg
- Actions.ShowMsgFormatted
- Actions.PlayWAV
- Actions.PlayWAVAtLocation
Questions/comments are welcome

Cheers,
Lewin.