ReadConfigFile or Datafile.

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Damien
Adept Poster
Posts: 82
Joined: Sat Apr 15, 2006 11:50 am

ReadConfigFile or Datafile.

Post by Damien »

Hail :D

Im currently working on a recreating of my questsystem and in lack of intelligence I wish to get some help! :)
While I was sitting here trying to figure how to improve the structure of my questsystem I figured out that everytime you finish a quest, your name will be added to an .cfg file.
Also when you start a quest the script should check thru the .cfg and see if you have already made the quest, if not it should jump over to quest nr.2

I've been looking thru TSSE scripts for some help, i can find some help partly but Austin is an amazing scripter and he makes my brain get on fire.
So i beg you to give me an tiny example of how to use "ReadConfigFile".

Oh! And one more thing, could someone explain for me what the difference between "ReadConfigFile" and "ReadFile" is, thanks! :D

Edit: OldnGrey and aveik told me Datafiles could be a better option, problem is, I never worked with datafiles before..
So please give me an tiny example of how to use datafiles! :D
Or can I read about it somewhere? Thanks! :)
Last edited by Damien on Wed Oct 31, 2007 5:04 am, edited 1 time in total.
User avatar
itec
Novice Poster
Posts: 42
Joined: Thu Feb 09, 2006 11:48 pm

Post by itec »

You could use datafiles, but since they need little more hassle to work with, I suggest using cprops if you lack the experience. You can only read and write config files, deleting is not allowed so it's not fit for this kind of job. And ReadFile() is only good for printing text files to player.

A simple way would be just to mark in the players cprop the quest-progress, example follows.

var progress := Cint(GetObjProperty(player, "Quest"));

if (!progress)
// Quest 1 here..
elseif (progress == 1)
// Quest 2 here..
endif


When quest is completed, this adds the quest value by one:

var progress := Cint(GetObjProperty(player, "Quest"));
SetObjProperty(player, "Quest", progress + 1);


That's really basic cprop usage, and the easiest way to go with this.
Damien
Adept Poster
Posts: 82
Joined: Sat Apr 15, 2006 11:50 am

Post by Damien »

Hello itec, and thanks for your reply!

I understand your example, and that is acctually how my script is written right now! But the problem is, there are so many different types of quests on one single NPC, which leads to that i have to create so many different Properties! And thats my main problem, so I wanted to improve the structure of the script using datafiles! :)

But people had trouble with my explanation of what i really tried to do, so i tried to make 2 different -scripts- which will show you more detailed how i ment! here we go:
use uo;
use os;

program_Quest(who)

OpenDataFile(::Mariaquest) ///The .cfg OR datafile
If(If you can't see +charname1+)
StartQuest(who, "Mariaquest1");
elseif
(You can see +charname1+)
StartQuest(who, "Mariaquest2");
elseif
(You can see (+charname1+ || +charname2+))
StartQuest(who, "Mariaquest3);
elseif
(You can see (+charname1+ || +charname2+ || +charname3+))
SendSysMessage(who, "Hi there dear fellow, have a good day! 3, ,50);
endif


////////////////////////////////////////
use uo;
use os;

program_mariaquest1(who)

SendSysMessage(who, "hi, bring me 100 gold",3 ,50);
CheckBackPack(who)
If(There is 100gp in backpack)
SendSysMessage(who, "Thank you, you have finished the quest" ,3 ,50);
ADD +CHARNAME1+ TO DATA/.CFG FILE MARIAQUEST! <------
elseif(There isn't 100gp in backpack)
SendSysMessage(who, "You don't got 100gp in your backpack, go get them pl0x!" ,3 ,50);
endif


EXPLANATION:
If you do the first quest you will get the number 1 after your name, and since i don't know
how to script that yet, i added an lousy example "+charname->1<-+" so thats why there is a number 1 after charname ;)
also notify these sentences:
ADD +CHARNAME1+ TO DATA/.CFG FILE MARIAQUEST! <------

Thats the whole point.. How to add the charname in the file.
The whole first script is checking what type of quest it's going to be started.

Please help, thanks! :D
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post by MuadDib »

DataFile all the way

There is still a few memory leaks with cfg file handling (I think it's in Append but can't remember, shini is workin on them). And besides, I love datafiles :)
User avatar
itec
Novice Poster
Posts: 42
Joined: Thu Feb 09, 2006 11:48 pm

Post by itec »

The example I described above let's you create linear one quest after another progress in one cprop. If you want to have non-linear approach to quests, you should use dictionaries = player can complete the quests in any order they want. The cprop is saved to player, so you don't have to save the character name.

Note that prop name is different from the value, you only need one Quest prop and it's enough.

SetObjProperty(player, "Quest", 1); // Quest 1 completed
SetObjProperty(player, "Quest", 2); // Quest 2 completed
SetObjProperty(player, "Quest", 3); // Quest 3 completed
SetObjProperty(player, "Quest", 4); // Quest 4 completed


Datafiles are just one way to save data, which are much better in big databases, but if I understood your explanition, cprops will work just fine for what you need. If you still want to use datafiles, read out core documentation about them.
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post by MuadDib »

Sounds to me like it's sort of the same as the WoW quest system.

Using a Previous Quest/Next Quest format, that can help you out some. If Prev Quest not complete, blah blah.

if (! (Prev_Quest in Quests_Complete)

Where Quests_Complete is an array

With using a Prev_Quest entry for quests that are part of a chain, you can ensure they are going in order. Quest chain for example, 10-12


Quest 10
{
Prev_Quest 0
Item_Info <blah blah>
NPC_Kill <blah blah>
}

Quest 11
{
Prev_Quest 10
Item_Info <blah blah>
NPC_Kill <blah blah>
}

Quest 12
{
Prev_Quest 11
Item_Info <blah blah>
NPC_Kill <blah blah>
}
Post Reply