What types of variables are used in Turbo Pascal?
What about constants?
How do you define arrays?
How do you define a record?
What is Locking and NetFileP?
What is ELOG?
How do you use ELOG?
Is there anything I should change in ELOG.PAS?
What is an example of the savegame routine?
What types of variables are used in Turbo Pascal?
You can find a detailed explanation of Pascal: here
These are the common variables used on this site:
var
charLoc: integer;
credits: longint;
outputString: string;
checkKeypress: boolean;
Year, Month, Day, Hour: word;
Integer, string, and boolean are self-explanatory, but a word is an integer that has a range of 0 to 65535. It's great for storing the current date when running maintenance for a game.
What about constants?
Constant variables do not change during the program's execution. They make for great placeholders, making the code readable.
const
{ player rank }
rankRecruit = 1;
rankPrivate = 2;
rankCorporal = 3;
How do you define arrays?
Arrays store a collection of elements in one variable. This allows us to store the total data needed in an array. One array, TP for all the players in the game, will contain the information needed to save the game. Arrays start out like this:
var
months: array[1..12] of string;
month_days: array[1..12] of integer;
How do you define a record?
Records hold several data types. This allows you to store all the variables associated with one object. Something like this:
type
TotalData = record
handle: string[64];
name: string[16];
turns: integer;
etc....
end;
var
TP: array[1..50] of TotalData;
In this example, the array TP holds 50 records of TotalData - for 50 players total in the game.
What is Locking and NetFileP?
File locking deals with multi-user capabilities, having more than one person play your game at a time. I'm not doing this. I'm locking players out if someone is in the game. I'm doing it through the BBS itself. But NETFILEP.PAS is a dependency of ELOG.PAS, and it's located in the locking.zip file. Covering NETFILEP.PAS is beyond the scoop of this site.
What is ELOG?
ELOG is a file that reports errors when the player crashes out of the game. It's also used to save a game, even when properly closing the program. ELOG becomes a powerful file that sits at the base of your game.
How do you use ELOG?
The docs are in ELOG.DOC and lightly cover how the TPU is used. The program that we are setting up must start with these lines of code:
BEGIN (*** M A I N ***)
SaveExitProc:=Exitproc; <------ Must have this first to make it work
ExitProc:=@MyExit1; <------ Must have this second to make it work
INITDOORDRIVER('SKEL.CTL');
PROGNAME:='Skeleton Game Framework';
etc....
Is there anything I should change in ELOG.PAS?
You should change two things in ELOG.PAS. The first is the game name, so you'll know which one is throwing an error. And you'll need to put your save game routine in place of:
SaveGame(Player,PlayerFile,TempP,Country,CountryFile,Map1,MapFile);
{Replace Skeleton Game Framework with the name of your program}
ProductName='Skeleton Game Framework';
{Replace the next line with the name of YOUR save procedure}
{This ones save my game information should something go wrong}
{I have left it so you see what I did, although it IS commented out}
{SaveGame(Player,PlayerFile,TempP,Country,CountryFile,Map1,MapFile);}
saveGame;
What is an example of the savegame routine?
The saveGame routine is in COMMFUN.PAS and is called by ERROLOG.PAS
procedure saveGame;
var
F: text;
i: integer;
outputString: string;
begin
if charLoc<>0 then
begin
TP[charLoc].handle:= CP.handle;
TP[charLoc].name:= CP.name;
Str(CP.turns,outputString);
TP[charLoc].turns:= outputString;
ect...
assign(F,'SKEL.PLR');
rewrite(F);
for i:=1 to gIndex do
begin
writeln(F,TP[i].handle+','
+TP[i].name+','
ect...
+TP[i].turns+',999');
end;
close(F);
end
end;