[Question]NPC Dialogue from Ini

09/11/2010 08:49 Arcо#16
Quote:
Originally Posted by -Fáng- View Post
Kinda like what I did with the SaveCharacter problem I guess.
Well I'll look into it more I guess as an option. Thanks =]
And my response to that?
FileShare.Read
Learn it.
09/11/2010 09:23 Ian*#17
MySQL works fine to read it, actually any method really works just fine.

p4n's .npc files assuming it's just plain text he's parsing, so it's pretty much the equivalent to an ini file.

As long as you read it once and store it in a variable somewhere they're all the same.
Don't read it each time the npc is accessed :P
09/11/2010 14:15 _tao4229_#18
Quote:
Originally Posted by Ian* View Post
MySQL works fine to read it, actually any method really works just fine.

p4n's .npc files assuming it's just plain text he's parsing, so it's pretty much the equivalent to an ini file.

As long as you read it once and store it in a variable somewhere they're all the same.
Don't read it each time the npc is accessed :P
Defeats an advantage of having an inline system (modify scripts while running).

You need some way to check whether the script has been modified before you reload it (or just have a command to manually reload the script into said variable).
09/11/2010 23:12 _DreadNought_#19
Quote:
Originally Posted by pro4never View Post
My server is using full C# syntax stored as .npc files which are debugged and executed at runtime when requested (that way if there are errors it's not executed which would cause crashing/issues)
I'm using the .npc file idea :) I will have it like 12111.npc 12111 = npc id
the structure inside is just
Code:
case 0:
{
Text("Testing..");
Link("Hi", 255);
break;
}
Then I still need to write the hardest part which is read the npc dialog for now I will have npc dialog in database as follows:
Code:
case 12111:
{
switch(npcRequest.optionID)
{
File.FindAndRead(12111);
}
break;
}
then eventually ill change the whole system so all of it is in the .npc file.
so when clicking an npc it does
Code:
File.FindAndRead(npcrequest.ID);
=]
However I need abit of help in the FindAndRead void :) will post problems later.

btw .npc is just text file.
#edit
Need help! :)
So my void is as follows
Code:
public static void FindAndRead(uint NpcID, GameState client)
        {
            Console.WriteLine("NPC Being accessed: {0}", NpcID);
            string DialogPath = Constants.NpcDialogs + NpcID;
            if (File.Exists(DialogPath))
            {
                Dialogs dialog = new Dialogs();
                dialog.Client = client;
                dialog.Replies = new List<NpcReply>();

                File.Open(DialogPath, FileMode.Open);
                string[] Dialog = File.ReadAllLines(DialogPath);
                if (Dialog.Contains("case 0:"))
                {
                }
            }
        }
But have NO idea how to read a file like this:
Code:
switch(NpcRequest.OptionID)
{
case 0:
{
Text("Testing..");
Link("Hi", 255);
break;
}
}
I just need to read a line and take action
Code:
File.ReadLine("switch(Npcrequest.optionID))
{" { ((Npc.Add "switch(Npcrequest.optionID))"{)) 
int case;
if case = 0 { if File.Contains("case " + case") Npc.Add "case 0:");
something like that but have no idea. ;s
09/12/2010 01:00 Ian*#20
Quote:
Originally Posted by _tao4229_ View Post
Defeats an advantage of having an inline system (modify scripts while running).

You need some way to check whether the script has been modified before you reload it (or just have a command to manually reload the script into said variable).
Yeah, could just make a reload button on your server gui ;P