SRL Archive - General

Types


Freddy1990

2006-05-24 01:46:19

Ok, it has come to my attention that we don't use scar at it's full potential, so for those who don't know, here's a lesson.
Most of you have propably already heard about the TPoint sometime…
It is a variable that can contain an X and Y value.
Now, we can make our own variable types!
Most propably dunno this so watch carefully…
It works somewhat as defining variables…
You have ur script:
program New;
begin
end.
Now we can add underneath program "var …" but in this case we are going to add "type":
program New;
type

begin
end.
Now we will create a variable with X1, Y1, X2, Y2. We'll call it TBox.
It has to be done like this:
program New;
type
TBox = record
X1, Y1, X2, Y2: Integer;
end;

begin
end.
Now what if we want to use an array of our variable? Well you could write "array of TBox" every time, but you can do it another way as well, We create a TBoxArray like this:
program New;
type
TBox = record
X1, Y1, X2, Y2: Integer;
end;
TBoxArray = array of TBox;

begin
end.

And finally we can create closed arrays:
program New;
type
TBox = record
X1, Y1, X2, Y2: Integer;
end;
TBoxArray = array of TBox;
TBoxClosedArray = array[1..5] of Integer;

begin
end.

Now, this is just a part of the possibilitys, but i hoped everyone who read this learned something…

XxKanexX

2006-05-24 02:43:30

We know how to use type, and it is used in SRL..

WhiteShadow

2006-05-24 02:46:32

<3 PlayerArrays. :) good read!

Pyro

2006-05-24 02:55:38

From: XxKanexX
We know how to use type, and it is used in SRL..


Ahhh so you know it……..What about the people who dont know it?

XxKanexX

2006-05-24 02:57:55

He was implying that know one knew what it meant. By "We" i meant most of the Developers.

The Prince of Randomness?

2006-05-24 03:21:37

I learnt quite a bit freddy, thanks.

Freddy1990

2006-05-24 06:24:27

I wasen't talking about everyone, kane -_-"
Most srl devs know an incredible load of scar stuff, this is more for the people who aren't devs, c?
There are people who think playerarrays are standard scar stuff, let alone how to make types

XxKanexX

2006-05-24 07:21:05

I mis-understood. By the first line i meant we don't use such in SRL. ;) Sorry.