PDA

View Full Version : Need answers to a few questions :)



Semtex
03-07-2012, 12:03 AM
Hey folks, i got some questions i would love to get an answer to.
atm i'm trying to write a script that mines coal ore's south of draynor's village.
I followed Kyle Defined's guide to scripting and changed some of it, but i was wandering what the following parts actually do
This at the top of the script, what does the {$IFDEF SMART} and {$ENDIF} actually do?
{$IFDEF SMART}
{$i srl/srl/misc/paintsmart.simba}
{$ENDIF}

Its also at the bottom
begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
MainLoop();
end.

mostly in other scripts its different, then its more like this
begin
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;

SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
MainLoop();

Best regards Semtex

Daniel
03-07-2012, 08:20 AM
Think of the {$ifDef} and {$endIf} as IF..THEN statements. The {$ in front symbolises that it is to be run if certain compiler conditions are met. Once these conditions are set, they can not be changed at script run time (while the script is running).

Example:


if SayHello then
writeln('hello');

is the same as (kinda):


{$ifDef SayHello}
Writeln('hello');
{$endIf}


You will notice that up the top of SRL\SRL\misc\Smart.simba there is a {$Define SMART}. This is essentially the same as setting the SMART variable to True. SRL will then check if it is defined beforehand, and check if it's included, and if it isn't it will include SMART, and then set it up. It has to use compiler directives, otherwise it wouldn't be as easy (you can't include a file at run time).

Semtex
03-07-2012, 10:49 AM
Thanks alot mate :) made sense