This is a problem I faced several times in my development practice. Some distinction must be drawn.
Yes, there's a limit in the order size but there isn't any limit in order number: you can put how many orders you need.
My development approach is changed. Until the backInTheDark project I used to script different orders to have different functions, tied as rings in a chain. This was a serial approach. Sometimes it can be useful but scripts become larger and larger and difficult to read and develop.
Now, instead, I'm following another method and only now I feel like I'm really using the scripting engine. Now I have only one Main order and, inside this one, I call the functions I need, scripted like standalone orders.
This is a net approach.
for example: you want to display a text on the screen. You should use the ShowText command. Instead I script another method containing the ShowText command.
In the Main order I call the DisplayText(); command, and i add a DisplayText order containing the command.
Code: Select all
{
Main[()
{
DisplayText();
}]
DisplayText[()
{
ShowText(1, "", "", "GoodNight", ...);
}]
}
Now it can seem useless but imagine you have draw a background, play a sound, start an animation, activate a trigger all in the same time, and disable tem all at a later time. In this way all become easier.
Code: Select all
{
Main[()
{
if(DoIt=true)
{
DisplayText();
}
else
{
HideText();
}
}]
DisplayText[()
{
//turn the lights on
ShowText(1, "", "", "GoodNight", ...);
PlaySound(...);
ShowHudPicture(true,...);
// several other commands...
}]
HideText[()
{
//turn the lights off
RemoveText(1);
PlaySound(...);
ShowHudPicture(false,...)
// several other commands...
}]
}
next, you can pass some variables to the functions you script.
Code: Select all
TextNumber [0]
TextToShow [string]
DisplayText[(TextNumber, TextToShow)
{
//turn the lights on
ShowText(TextNumber, "", "", TextToShow, ...);
PlaySound(...);
ShowHudPicture(true,...);
// several other commands...
}]
for example, you want to activate the text number 12 using a "GoodMorning" string, you can call this function this way: : DisplayText(12, "GoodMorning");
Two final things to remember:
1) you can call a function inside one another
2) you can call a function inside another object, for example another pawn, using his EntityName.OrderName();
For example, suppose the line above are contained in a script called example1.s used by a Pawn which szEntityName is MY_FIRST_PAWN, and you need to call the text displayer function from another script running for another Pawn. You just have to call it using MY_FIRST_PAWN.DisplayText(12, "Good Morning"); Every function or pawn command can be called using this formal convention.