SRL Archive - OSR Help

Data Types


HarryJames

2011-03-17 20:15:38

Hey :)

Is it possible to make my own data type?
Instead of having lots of messy arrays, I'd like to create an object/data type for a Dungeoneering bot. It will contain each rooms data, such as doors, locked doors, spawn point, cleared, etc etc.

(A class would do, if Simba supports classes).

NewDataType Room
{
id: integer;
doors: integer;
doorLocations: TPointArray;
isSpawn: boolean;
}

Then say we have three rooms as objects/data types (whatever), searching through them for something for example, what room is the spawn. (I could have a seperate variable for that (in global vars), but it's just an example.)

Gu3st...

2011-03-17 20:25:28

Yes it it! :)

type
THarryJames = record
Age : Integer;
Location : String;
end;

begin
end.
I just made a HarryJames type!

HarryJames

2011-03-17 20:27:21

Usage is as follows, correct?


var
Myself : THarryJames;
Begin
Myself.Age := 16;
Myself.Location := "Narnia";

writeln(Myself.Age);
end;

i luffs yeww

2011-03-17 20:27:49

http://villavu.com/forum/showthread.php?t=40661

HarryJames

2011-03-17 20:43:44

Thanks :)

Would I be better off making a few variables in the TRoom record, or making another record for doors. You have to know their location, colour, shape, locked/unlocked. (That's it I think, for doors).

i luffs yeww

2011-03-17 23:53:47

Doesn't really matter.. The purpose of making a new type is really just to keep things more organized and less confusing.