How To Make Your Own Includes
By Richard
In this tutorial, I am going to show you how to make your very own includes...Yes, just like the SRL includes. Sound difficult? Well read on and see what you think then!
Yesterday, I was experimenting around with SCAR, as I do. I ended up wondering whether I could shorten a command, let's say to something like ...So I gave it a shot.
When you are making a script, you normally include But do you know what it actually is? It's made up of many different commands:
SCAR Code:
procedure SetupSRL;
begin
MouseSpeed := 15;
CheckHPFirst := True;
Reincarnate := False;
TalkAfterRandoms := False;
RoadColor := 0;
WaterColor := 0;
BankColor := 0;
LampSkill := 'mining';
SetUpSRLReport;
LoadCosineArrays;
SymbolAccuracy:= 0.8;
LoadNPCArray;
LoadSRLBitMaps;
SolveChatRandoms := True;
SetupSRLAutoResponder;
UseFindMod := True;
LogoutOnMod := True;
UseFindTrade := True;
Screenshots := False;
InitializeSRLLogFile;
Writeln ('SRL Compiled in '+ IntToStr(GetTimeRunning) + ' msec');
end;
To do this, however, you need to add an include. Which one to be exact? The one that you see in most scripts: If you open that file, you will see that SetupSRL is in there as a procedure. Getting the hang of it now?
To make your own, you will need to do something like the above. To start you off, let's keep it simple.
In this example, I am going to do what I said above; simplify Open up a new SCAR window. All you'll see right now is this:
You don't needso change it toIf you don't do the above, it won't work. I hope you can see where I'm getting now.
In this procedure, add So now we have:
THE PICTURE DOESN'T WORK ANYMORE AND I CBA TO MAKE ANOTHER ONE. SORRY!
You can add something else, like
SCAR Code:
WriteLn('Woo! Richard rules!');
aboveI suggest you do something like that so that you can see it works. Save it as in the includes folder. This is your own include!
Now open up another SCAR window. Because we have to include includes (duh!), below of the new SCAR, we add
SCAR Code:
{.include TestInclude.scar}
Now just add in between andNow we have our second script as:
Press and see what happens!
I'll give a quick run down of what just happened, and how it works.
You named a procedure "TS" in your include script, which is how you call upon it in your other script. You saved it as "TestInclude", in your includes folder, which is how you include it in your script.
It really is as simple as that!
Of course, in the file where you saved TS, you could have many more procedures and functions, to make it much more useful. If you are not sure what I mean, open up a .scar in the includes folder, and see what I mean.
Please give feedback on how you think this tutorial is, and how it could be improved. Thanks!