PDA

View Full Version : [Tut]Making your OWN includes![Tut]



Rich
09-25-2008, 03:08 PM
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 TerminateScript;to something likeTS; ...So I gave it a shot.


When you are making a script, you normally includeSetupSRL; But do you know what it actually is? It's made up of many different commands: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:{.include SRL/SRL.scar} 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 TerminateScript;Open up a new SCAR window. All you'll see right now is this:

http://img267.imageshack.us/img267/3821/pic1hk4.png

You don't needprogram New;so change it toprocedure TS;If you don't do the above, it won't work. I hope you can see where I'm getting now.

In this procedure, add TerminateScript; So now we have:

THE PICTURE DOESN'T WORK ANYMORE AND I CBA TO MAKE ANOTHER ONE. SORRY!

You can add something else, likeWriteLn('Woo! Richard rules!'); aboveTerminateScript;I suggest you do something like that so that you can see it works. Save it as
TestIncludein the includes folder. This is your own include!

http://img354.imageshack.us/img354/9043/pic5zz6.png

Now open up another SCAR window. Because we have to include includes (duh!), below program New;of the new SCAR, we add{.include TestInclude.scar}Now just add TS;in between beginandend.Now we have our second script as:

http://img267.imageshack.us/img267/9104/pic3xv4.png

Press http://img354.imageshack.us/img354/9601/pic4cc1.png 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!

Heavenzeyez1
09-25-2008, 04:20 PM
Well explained, good.
~Eerik~

sirlaughsalot
09-25-2008, 04:23 PM
Good, but give final results so people can compare/contrast, and give a screenshot of where to save it :D

Rich
09-25-2008, 04:29 PM
Thanks for the feedback guys.

Sirlaughsalot, I have included some pictures of final scripts, but they weren't showing, so I changed the host and now they are. I'll add a picture of the file in a minute.

simple skill
09-25-2008, 08:15 PM
thanks for this it will help me when i get into scripting

footballjds
05-01-2009, 12:17 AM
and this:

program old;
procedure TS;
begin
TerminateScript;
end;
begin
TS;
end;

works ROFL!!! use that instead of including if all you wana do is make TerminateScript shorter... ROFL!!! :D