Aller au contenu

Photo

Access File System


  • Veuillez vous connecter pour répondre
8 réponses à ce sujet

#1
Celludriel

Celludriel
  • Members
  • 19 messages

Hey,

 

I'm wondering if it is possible to access the file system by scripting ?  I'm just wondering since NWNX is a nice addition with wrapping a server to access data on a DB.  But to me a DB is just a place to store data, so is the file system. You could just as easly put data in json or xml files.

 

I'm thinking for example at the legends plugin system, more in particular the one to make quests rapidly.  If you could store the data for those quests on the filesystem ... well then you could make a single player module with legends quests.

 

Considering the few data I could gather on the system though. I'm probably coming home from an empty trip, asking this, but hey who knows maybe someone does know a way.



#2
kevL

kevL
  • Members
  • 4 070 messages

I doubt it, its a huge security breach.



#3
Celludriel

Celludriel
  • Members
  • 19 messages

I doubt it, its a huge security breach.

 

yeah that was my first thought as well.  Maybe if there is a way to store json data and create a json parser in NWNScript, the legends plugin could save all the quest relevant data in a script.  But then there comes the question how many script files can a module have before performance ... well dies.   Or if there is a hardcore limit on the amount of scripts in a module



#4
kevL

kevL
  • Members
  • 4 070 messages

I don't think there's any limit on number of file-scripts -- the engine seems to load and unload them as needed.

 

Marshall ( legends author ) should/would know a lot more about what's possible



#5
Tchos

Tchos
  • Members
  • 5 072 messages

There's nothing specific to the scripts that requires the quest data to be stored on an external database rather than internal game data storage such as local or global variables.  They can be rewritten to use the latter.  The reason they're not that way is because of the special needs of persistent worlds and managing that data for multiple players.

 

I wouldn't know about switching them to a different external system.  But I believe if you were going to require players to install something special for it, then why not just have them install the same builder framework that Marshall uses to test the PW locally, and use the actual system?



#6
Kanis-Greataxe

Kanis-Greataxe
  • Members
  • 158 messages

Marshall does all his testing using a test pw I believe, as for most of his plugins nwnx4 and a MySQL database is required to run them. You can contact him through his web site which is  www.nwn2legends.com  for more info on his plugins, there is also a lot of info on them on his forums accessible through the same link.

 

Kanis



#7
Celludriel

Celludriel
  • Members
  • 19 messages

Marshall does all his testing using a test pw I believe, as for most of his plugins nwnx4 and a MySQL database is required to run them. You can contact him through his web site which is  www.nwn2legends.com  for more info on his plugins, there is also a lot of info on them on his forums accessible through the same link.

 

Kanis

Thanks, I've got an account on his forum as well.  This idea to take the created quests with the legends offline from a DB, just crawled in my head though.  It has a mental pin in it to pick it up once my current work is completed.

 

I'm rebuilding the TerrainImporter plugin from Cliff bit by bit.  I'm currently writing libraries in C# to access the L3DT file types, so I can move all the parsing Cliff put in the TerrainImporter plugin out of there and just read the L3DT files.  I'm wrapping up the libraries and then back to the TerrainImporter code, once that is finished I'm moving on to taking these quests offline instead of a DB :)

 

But thanks for the input, that it isn't exactly possible to access the file system thru NWNScript which was my primary idea on this anyhow



#8
rjshae

rjshae
  • Members
  • 4 505 messages

There is a WriteTimestampedLogEntry() command that will write a string to the log file. I haven't experimented with it, but possibly you could then extract that information via an external process and use it dynamically. It likely wouldn't be very efficient.



#9
Nighthirster

Nighthirster
  • Members
  • 32 messages

Yes, you can do that and much more -- if you have sufficient programming knowledge in C# or C++.

 

For one, you can most likely do it by writing a custom NWNX plugin. However, the easier way is to use Skywing's amazing NWScript Accelerator plugin: http://www.nwnx.org/...opic.php?t=1803 and then enable Managed Scripts (http://www.nwnx.org/...969220a96469db9).

 

This will allow you to write C# programs that run like NWScripts and can be called from nwn2, and have access to all nwn2 scripting functions. For example in my case, I track a ton of analytics data on Mixpanel using a small C# script I wrote which basically relays JSON data.

 

Here's the relevant part of my C# program:

        public Int32 ScriptMain([In] object[] ScriptParameters, [In] Int32 DefaultReturnCode)
        {
            if (GetIsObjectValid(OBJECT_SELF) == 1)
            {
                var publicKey = GetPCPublicCDKey(OBJECT_SELF);

                if (publicKey != "" && publicKey != null)
                {
                    var mixpanel = new Zirpl.Metrics.MixPanel.HttpApi.MixPanelApi("<my api key>");
                    var mEvent = mixpanel.CreatePersonSetEvent(publicKey);

                    mEvent.Properties.Add("$name", GetPCPlayerName(OBJECT_SELF));
                    mEvent.Properties.Add("Character", GetName(OBJECT_SELF));
                    mEvent.Properties.Add("Level", GetTotalLevels(OBJECT_SELF, 0));
                    mEvent.Properties.Add("$last_login", DateTime.Now);

                    mixpanel.Send(mEvent);

                    //Broadcast Event to DMs
                    //SendMessageToAllDMs("[TRACK PLAYER] " + GetName(OBJECT_SELF) + " : " + GetPCPlayerName(OBJECT_SELF));
                }
            }

            return DefaultReturnCode;
        }

As you'll no doubt notice, I'm basically just reading info about the calling object then sending that data to mixpanel (analytics platform) via an asynchronous web call. You can likely do the same thing with the filesystem.

 

Here is what my actual NWScript code looks like:

//Track information about a given player
//Calls a C# script which transfers people info to Mixpanel
void TrackPlayer(object oPlayer)
{
	ExecuteScriptEnhanced("MixpanelPeople",oPlayer,TRUE);
}

You can just as easily add parameters to be sent to the script as well using AddScriptParameter or by setting them as local variables on the object.

 

The sky is the limit, and it took me no time at all to get it working (Skywing documents his projects very nicely).

 

Hope this helps!


  • rjshae aime ceci