logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Load New Module

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules
View previous topic :: View next topic  
Author Message
onomat



Joined: 05 Jun 2010
Posts: 2

PostPosted: Sat Jun 05, 2010 22:33    Post subject: Load New Module Reply with quote

Greetings. I'm trying to write, at least what I thought would be simple, script. The situation is I am not located in the same place as my nwn1 server. It is a windows box (not sure what version) set up by someone else. I can load my files via ftp, and then they start it. After that I am on my own.

What I'd like to do is have a script that would be able to parse my modules folder, and tell me via a conversation with an NPC (I'm logged on as a DM) what modules are available. Then set it to shutdown the current module and load a new one, all from in game.

I'm thinking StartNewModule() wouldn't work in this situation. If I used that, and it crashed, wouldn't nwnx2 just load the original module?

I guess maybe a simpler way would be to be able to edit nwnx.ini from in game, and then just restart via "NWNX!RESETPLUGIN!SHUTDOWN". Is that possible?
Back to top
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Sun Jun 06, 2010 1:04    Post subject: Reply with quote

I'd suggest negotiating with the host to try and get VNC or RDP access. RDP is more responsive but only allows one user at a time, logging off anyone who was on before. VNC is less responsive but that's because it allows you to share the screen itself, not just interact with a remote desktop session. Both are good options.

If you absolutely can't do that, what are you using to scan the modules directory?
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Fri Jun 11, 2010 20:51    Post subject: I had this Reply with quote

I had this situation before I moved to vnc.


The way I worked it, was keeping the nwnx.ini static, and then uploading the module, overwriting the old module, and then trigger a reset via resetplugin.

It works as a last resort, because the module runs from the CurrentGame directory, allowing you write access to the module in the module directory too.

But yes... I recommend vnc or Remote Desktop.

Note - I recently began messing around with virtual machines, there is absolutely no reason you cannot get your host to set you up with a VM, and then hav Remote Desktop Privilages over the VM, therefore not disrupting the hosts own activities on the machine.

I recommend VirtualBox its easy, simple, and seems good enough. The only issue though, is if you allocate alot of ram to the virtual machine, and the host is using that physical ram, it 'can' cause your virtual machine to get 'Paused' until the ram becomes available.


Which means your host, or the host machine at least, shouldnt be running Adobe Products or anything thats a ram whore.


Note 2 - Just read your original post completely.

There is a nwnx plugin out there, not sure its name, but it grants file writing, reading commands.
Think this is it
http://nwvault.ign.com/View.php?view=Other.Detail&id=1383

Because the commands it uses, are external to nwn (eg - it does not write files in nwn, it writes them in windows) then it should still work. It should never need updating, unless its being made for windows 7 or something, but it probably already works for windows 7.

Quote:

int FileExists(string filename, string path=""); // Does file exist
int FileDeleteFile(string filename, string path=""); // Returns true if file was deleted
int FileDeleteDirectory(string dirname, string path=""); // returns true if directory was deleted.
string FileMD5(string filename, string path=""); //gets md5 of a file
int FileClose(); // close a file
int FileWrite(string sString); //write text into a file
int FileSize(string filename, string path=""); //get file size of a file
int FileOpen(string filename, string path="", int nMode = FILE_OPEN_MODE_FOR_READING); //open a file for editing/or reading
int FileCopy(string filename, string path, string newpath, string newname="", int rewrite_if_exists=FALSE); // copy file from one place to another
string FileRead(); //returns the contents of a file only 256 characters or a line.
struct time FileTime(string filename, string path="", int nTime=FILE_TIME_OF_WRITE); // time of the file last edit??
int FileCreateFile(string filename, string path=""); //create new file
int FileCreateDirectory(string dirname, string path=""); //create new directory
string FileGetFirst(string path="", string filter="*", int mode=FILE_SEARCH_FOR_FILES); //get first file in directory
string FileGetNext(string path="", string filter="*", int mode=FILE_SEARCH_FOR_FILES); // get next file in directory, use with above for loops



I can already see a solution with these methods.
Code:


void ChangeModuleName(string NewModuleName = "")
{
int iOpen = FileOpen("nwnx.ini", "c:\path\to\nwn",FILE_OPEN_MODE_FOR_WRITING); //I assume that writing will allow reading too.

if(!iOpen)
   return;
//Opened the nwnx.ini
string sLine = FileRead();
string sContents = "";

//we need to do a loop to get the whole contents of the nwnx.ini
while (sLine != "")
  {
      if(FindSubString(sLine,"ModuleName")!= -1)
          {
              //We have found the line with the ModuleName on it, replace with new name
             sLine = "ModuleName= "+NewModuleName;
           }
      sContents += sLine+"\n";  // I think the \n will preserve new lines.
      sLine = FileRead();
  }


FileWrite(sContents);
DelayCommand(1.00,FileClose());

}





This function, in theory, should allow you to edit your nwnx ini file from within the game, however, I have never used the methods mentioned above, I am unsure if the FileWrite method will write the over the contents of the file, or append to the end.

Usually File Open Methods will indicate a Open for reading/writing/append sorta thing, so in the absense of append, I will assume it will overwrite.

Make sure you back up your nwnx.ini file first, you will need to set the path to your nwn directory too.
Back to top
View user's profile Send private message
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Sat Jun 12, 2010 1:08    Post subject: Reply with quote

Code:
//Writes or changes an existing string in sFile
//Note: the parameters may not be more then 255 characters long
void NWNX_WriteStringToINI( string sSection, string sKey, string sValue, string sFile );


Code:
NWNX_WriteStringToINI( "NWNX", "ModuleName", "new module name", "./NWNX.INI" );


Got a plugin with ini writing/reading capabilities here.
_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
onomat



Joined: 05 Jun 2010
Posts: 2

PostPosted: Sat Jun 12, 2010 19:13    Post subject: Reply with quote

You guys are all unbelievably awesome. Of course, I've thrown new problems (not nwnx related) in my way, so I'm working on those. But I am bookmarking this thread so I can implement these at a later date. My ultimate plan is to pretty much be able to do as much administration from the DM Client as possible (except uploads of new modules).
Back to top
View user's profile Send private message
ShaDoOoW



Joined: 20 Aug 2005
Posts: 584

PostPosted: Tue Jul 06, 2010 16:09    Post subject: Reply with quote

BTW I have bad feeling that current NWNX build don't reload ini setting when nwserver is shutdown.

I ran NWNX which ran module001, so I changed the module name in NWNX.ini to module002, but after shutting the nwserver down, NWNX loaded 001 again...

I should be using NWNX Core 2.7-b4
_________________
Community Patch / NWNX Patch / NWNX Files / NWNX Connect
Back to top
View user's profile Send private message
Baaleos



Joined: 02 Sep 2007
Posts: 830

PostPosted: Tue Jul 06, 2010 21:43    Post subject: always been like that Reply with quote

As far as I know,
nwnx has always been like that in my experience.

It loads the settings from the ini on loadup of 'nwnx' and these settings remain static, until nwnx is reset.


When I was with a particular server host, because I had no remote desktop connection to the server, I had to improvise.

I used ftp to upload a module, with the same name, to replace the old one.

Then use reset plugin, to reset the server.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Scripts and Modules All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group