Script file size restriction?

Topics regarding Scripting with Reality Factory
Post Reply
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Script file size restriction?

Post by Jay »

Is there a restriction on the script file size?
Or a maximum amount of orders or something?

Because my player script is getting larger and larger, it just went 68KB and i get errors i don't understand...

EDIT: Ok i found out that the errors were my fault, but the question still remains: is there a limit somehow?
Everyone can see the difficult, but only the wise can see the simple.
-----
User avatar
federico
RF Dev Team
Posts: 443
Joined: Tue Jul 05, 2005 3:14 pm
Contact:

Post by federico »

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.
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

yes i know of this restriction it starts with about 500 lines of code in one order, and am already using your approach since i began with this script, but is there any other limitation?

ps: this is exactly the way i write my scripts :wink:
Everyone can see the difficult, but only the wise can see the simple.
-----
User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA

Post by darksmaster923 »

theres a 500 line code restriction?
Herp derp.
User avatar
federico
RF Dev Team
Posts: 443
Joined: Tue Jul 05, 2005 3:14 pm
Contact:

Post by federico »

good for you, Jay. I wasted much of my time in the past using a different approach.
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

@darksmaster:

yes there seems to be something like that in LowLevel - when i went over a specific amount of lines in one order i always got a parse error... i think it was about 500 or so
Everyone can see the difficult, but only the wise can see the simple.
-----
Post Reply