Is that game perhaps Elite or Elite2?? Spent countless of hours playing both of them.. Now to the questions:
Originally Posted by gcarreno
Sounds like using an embedded script language might overshoot the target, could you perhaps settle for some basic database instead? I used Json for something similar (not in pascal, but the principles are the same)
Json makes it easy to store key/value pairs, and it also has (limited) support for conditional branching.
Provided that you're using OPascal, you can then fairly easy map each Json-entry to an object, which you then can store away in an array or linked list.
"name": "Basic FTL drive systems",
"prereq": ["playtime", 1],
"name": "Wormhole Navigation for Dummies",
"prereq": ["playtime", 2],
"name": "Advanced Wormhole Navigation",
"prereq": ["wormhole_1", "hyperdrive_1"],
I would parse the file like this (in pseudo-code)
This would also make it easy to serialize all the data for saving and loading purposes, the memory footprint of the json-object isn't an issue as long as you're running on anything else then a C64, or a Casio pocket calculator. When you've researched a technology, change the "researched"-field of that object to true, and at the end of the game write the modified Json-file back to disk. Then the next time you load the game you will start from where you left instead of having to research all techs all over again.
Get Json-object count
Make place for them (I've got a sweet spot for dynamic arrays)
For each Json object do
for each req in prereq
if prereq-field contains "playtime" then parse next field member as integer
else add TechID;s to list of prerequisits.