external file with OBSE

Post » Tue Aug 25, 2009 11:15 pm

Okay, Im looking to store a heap of mesh paths in an external file so thati can access them, add to them and compare them in a script.

The idea is that using a script I can compare the mesh path of an item to all those in this file, if it returns true i want set set a variable as true for another part of the script. However, i also want to be able to script in a way to add more mesh paths to this file via a script. lastly, i want to be maunally add in hundreds of pre-written paths to the file...so it would help if it was human editable.

Ive looked around but cannot find any info on making such a file, i know people can....but im stumped on what to do.
User avatar
Tikarma Vodicka-McPherson
 
Posts: 3426
Joined: Fri Feb 02, 2007 9:15 am

Post » Wed Aug 26, 2009 4:26 am

Pluggy has a bunch of http://cs.elderscrolls.com/constwiki/index.php/Category:File_Functions_%28Pluggy%29 that woud do it
User avatar
Bethany Short
 
Posts: 3450
Joined: Fri Jul 14, 2006 11:47 am

Post » Tue Aug 25, 2009 9:21 pm

can anyone write this for me...i have no clue... :shrug:
User avatar
Zoe Ratcliffe
 
Posts: 3370
Joined: Mon Feb 19, 2007 12:45 am

Post » Wed Aug 26, 2009 6:39 am

bump, anyone at all. ive tried looking through the introduction to these function but frankly im stumped.

From what I see they act more like a script anyway, which doesnt really help me...
User avatar
Steeeph
 
Posts: 3443
Joined: Wed Apr 04, 2007 8:28 am

Post » Wed Aug 26, 2009 2:37 am

anyone?
User avatar
Camden Unglesbee
 
Posts: 3467
Joined: Wed Aug 15, 2007 8:30 am

Post » Tue Aug 25, 2009 9:16 pm

I suppose the functions you need are FileToString and StringToTxtFile.

I understand that they write and read a whole text file.

So, you could create a text file with notepad, read it with FileToString, and search the string to check if a given path is present.

You could also append new Paths to the string and write the new, expanded text to the file.

I've never used any of the above, but I did use the INI file functions.


With the INI handling functions, you could create a file like this:
[MyPaths]Clutter\Books\Book01=1Clutter\Books\Book02=1Clutter\Books\Book03=1




And check the existence of a given path with this OBSE user function
scn zzzPathExistsstring_var sPathfloat vRetCodelong psFile 		;===Pluggy===long psSection  	;===Pluggy===long psKey 		;===Pluggy===begin Function {sPath}	let psFile := createstring -1 "MyFile.ini"  1 1	let psSection := createstring -1 "MyPaths" 1 1	let psKey := createstring -1 0 1 1	setString psKey $sPath	let vRetCode := IniKeyExists psFile psSection psKey 	SetFunctionValue vRetCode	DestroyString psFile 	DestroyString psSection 	DestroyString psKey 	sv_destruct sPathend



But this solution is not elegant. I think the first one is better.
User avatar
sally coker
 
Posts: 3349
Joined: Wed Jul 26, 2006 7:51 pm

Post » Wed Aug 26, 2009 10:53 am

the trouble with FileToString is though that is doesnt read line by line, it will grab everything and put it all in one string.

If some could show me how to make it only read one line at a time I think i might be able to get it from there, but that bit stumps me.


EDIT: Or show me a way to script it so that the mesh path will go through and compare my mesh path with each mesh path in that one string.
User avatar
Josephine Gowing
 
Posts: 3545
Joined: Fri Jun 30, 2006 12:41 pm

Post » Wed Aug 26, 2009 5:28 am

I think you could read the text file to memory and use http://cs.elderscrolls.com/constwiki/index.php/StringPos to check if the path you are looking for is anywhere in the file. No need to parse the file into separate lines.
But you would need to be careful with possible false positives, like "AA/BB/CC" returning true because there is a "AA/BB/CC/DD" in the file

But I've never actually used Pluggy string functions, so I don't have any code to help you.
User avatar
Victoria Bartel
 
Posts: 3325
Joined: Tue Apr 10, 2007 10:20 am

Post » Wed Aug 26, 2009 1:19 am

StringPos should do it....though putting all on one line will be a bit messy, oh well.

Last i checked getting the mesh path got the entire thing down to the .nif so that shouldnt be a probelm with false positives.

do i put a space or tab between each path?


User avatar
Olga Xx
 
Posts: 3437
Joined: Tue Jul 11, 2006 8:31 pm

Post » Wed Aug 26, 2009 10:24 am

On the file itself, do as normal: one path per line.
In memory, there will be a couple of characters (line-feed and carriage return, I suppose) between paths, but you don't have to worry about them.

If you append new paths to the file and if you want the new paths to be in different lines when the file is open in Notepad, you may add the same characters between paths.
User avatar
Bigze Stacks
 
Posts: 3309
Joined: Sun May 20, 2007 5:07 pm

Post » Wed Aug 26, 2009 3:04 am

ahh so it doesnt have a problem with the newline character.

thats good :)
User avatar
OTTO
 
Posts: 3367
Joined: Thu May 17, 2007 6:22 pm

Post » Wed Aug 26, 2009 7:56 am

hmmm.....almost working

i dont think its reading the file right, this is what i have for that bit:


let FileMale := "\DMRaces\Male.txt"...let path := getbipedmodelpath 0 upperbodyreftemplet upperbodystep := stringpos path FileMale


any help? did i put in the file directory wrong? (located at \Documents\My Games\Oblivion\Pluggy\User Files\DMRaces\male.txt)

or is it something else?


User avatar
Amy Melissa
 
Posts: 3390
Joined: Fri Jun 23, 2006 2:35 pm


Return to IV - Oblivion