I'm working with a team and our AI programmer is looking to save some special AI data and then load it back in to the game. Is there anyway to read/write to our own files through unrealscript?
I'm working with a team and our AI programmer is looking to save some special AI data and then load it back in to the game. Is there anyway to read/write to our own files through unrealscript?
Try looking at the FileWriter class. Loading it back in is an entirely different kettle of fish however. You may need an external application that networks (TCPLink) with the main application.

http://forums.epicgames.com/showthread.php?t=705640
A pay for implementation will be available within the next few weeks from Digital Confectioners.
By save AI data, are you talking dynamic data, or data that can be set in the map at design time? If it can be set at design time, I'd say create a placeable class that you add to the map and reference the data that way.
Dynamic data. I think he is looking to do some adaptive skill level stuff.
I was digging through the UDK reference UScript today and came across a function in OnlineTitleFileDownloadMcp called GetTitleFileContents. This function takes a string as an argument for the file name, and outputs an array of bytes for the contents of the file. Would it be possible to use this function to read a file from the users hard drive, and if so how efficient would it be?
Last edited by fritzmonkey; 11-12-2009 at 08:15 PM.
It'd be more efficient than nothing, which is what supposedly is built-in at the moment.

That's an interesting find, I will have to experiment with this.
There are a couple of other classes with a similar function, but this one seems like the best to use.
maybe just use config-files? (for simple actions)

There are a few problems with using config files in UE3.
Nightblade, a stealth based total conversion for UT3
FileWriter is pure unreadable output. You can not read the files you wrote. It is great for various logging (like stats logging) or HTML report generation.
Michiel 'El Muerte' Hendriks
Magicball Network - Little Big Adventure community
the Unreal Admin page - Unreal server administration
UnrealWiki - UnrealScript and UnrealEd wiki.
UnCodeX - powerful UnrealScript tool for programmers
You can't use OnlineTitleFileDownloadMcp for files on a users hard drive, it seems; it uses http.
Were you able to test this? I would hate to give up on it before it has been tested.
Last edited by immortius; 11-13-2009 at 05:28 AM.
Nightblade, a stealth based total conversion for UT3
Well, I haven't tried it out directly, just gathered from hints in the .uc.
It's http only, and very limited. I'm working on a full featured HTTP client in unrealscript that provides much much more functionality.
Michiel 'El Muerte' Hendriks
Magicball Network - Little Big Adventure community
the Unreal Admin page - Unreal server administration
UnrealWiki - UnrealScript and UnrealEd wiki.
UnCodeX - powerful UnrealScript tool for programmers

Not sure what you mean here elmuerte, I tried it and it just wrote strings like I expected it to.FileWriter is pure unreadable output. You can not read the files you wrote. It is great for various logging (like stats logging) or HTML report generation.
I'm still experimenting with this but it states that it links to a specific storage type. I'm unsure what this means at the moment. Thus far I'm not able to open up any kind of files with it at the moment and the current existing code suggests that it works but the config parts are all missing. I don't see it in UT3's code base at the moment as well so it may be quite new.
What I meant is that the data you write using FileWriter can not be read again from within the engine (unless you use an external redirect like a TCPlink).
Michiel 'El Muerte' Hendriks
Magicball Network - Little Big Adventure community
the Unreal Admin page - Unreal server administration
UnrealWiki - UnrealScript and UnrealEd wiki.
UnCodeX - powerful UnrealScript tool for programmers

I'm still messing around with the function above. I'm not quite sure where UDK actually looks for in a specified storage or if it just returns false because it actually hasn't been implemented. A little hard for me to tell at this point without further experimentation. So far, I'm trying to see if it is relative or absolute.
Would you mind posting what you've got?
EDIT
This is the code I've been playing around with so far. Still unable to read a file. I'm using the SystemInterface version of the function rather than the OnlineTitleFileDownloadMcp version. I know it isn't very elegant right now, but this is just for testing. Let me know if you have any ideas or questions.
Code:var transient OnlineSystemInterface SystemInterface; Simulated function PostBeginPlay() { local OnlineSubsystem OnlineSub; local FileWriter OutTest; local string FileName; local string OutString; local array<byte> FileData; local array<string> StringArray; local int i; super.PostBeginPlay(); OnlineSub = class'GameEngine'.static.GetOnlineSubsystem(); OutTest = spawn(class'Engine.FileWriter'); FileName = "TestFile"; if (OnlineSub != None) { SystemInterface = OnlineSub.SystemInterface; `Log("Created SI"); } if(OutTest != none) { OutTest.OpenFile(FileName,FWFT_User,".txt"); OutTest.Logf("TestLog"); `Log("TestLog"); OutTest.CloseFile(); } if(SystemInterface != None) { SystemInterface.ReadTitleFile(FileName$".txt"); if(SystemInterface.GetTitleFileContents(FileName$".txt",FileData)) { `Log("GetTitleFileContents true"); `Log("GetContents ="@FileData[0]); `Log("GetContents ="@FileData[1]); `Log("GetContents ="@FileData[2]); `Log("GetContents ="@FileData[3]); for(i=0;i<FileData.Length;i++) { StringArray[i] = string(FileData[i]); } JoinArray(StringArray,OutString); if(OutTest != none) { OutTest.OpenFile("OutFile",FWFT_User,".txt"); OutTest.Logf(OutString); } } else { `Log("GetTitleFileContents false"); } } }
Last edited by fritzmonkey; 11-14-2009 at 05:10 AM.
Bumping so that people know the code is here. I forgot that editing doesn't bump the thread.

It's possible that those functions are just stubs and that implementation may not actually exist for these functions. For example, I noticed that the Account Interface and the News Interface are also not present when you peek into the Online Subsystem.
I've decided to forgo the whole thing and I am now just using the config system to store data as serialized strings. I wrote a wrapper class which can de serialize the strings into objects again. I have also found a workaround for the missing config functions. This is probably the way I'll go.
I'll probably keep messing around with it for a few more days. The must frustrating thing about this is that I have no idea what is breaking. All I know is that the file read has failed. Not knowing why is what's killing me.
This is not related to the fact that the unreal engine runs on the xbox 360?
If i remember correctly it states you are not allowed to change files/profiles/paths/drives in runtime, each such change often result in a game restart.
It could be that allowed file access could be setup trough somekind of profile system that you only can change access to on start up.
I don't understand what you are saying.
From looking at the code, the file reading is asynchronous - that is you register a function to be called when the read is complete, then you set it going with ReadTitleFile().
Nightblade, a stealth based total conversion for UT3
Bookmarks