Results 1 to 29 of 29
  1. #1
    MSgt. Shooter Person
    Join Date
    Apr 2009
    Posts
    102

    Default File Read/Write 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?

  2. #2
    Veteran
    Join Date
    Sep 2006
    Location
    Newcastle, UK
    Posts
    6,971
    Gamer IDs

    Gamertag: ambershee

    Default

    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.

  3. #3
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,556

    Default

    http://forums.epicgames.com/showthread.php?t=705640

    A pay for implementation will be available within the next few weeks from Digital Confectioners.

  4. #4

    Default

    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.

  5. #5
    MSgt. Shooter Person
    Join Date
    Apr 2009
    Posts
    102

    Default

    Dynamic data. I think he is looking to do some adaptive skill level stuff.

  6. #6
    MSgt. Shooter Person
    Join Date
    Apr 2009
    Posts
    102

    Default

    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.

  7. #7
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    341

    Default

    It'd be more efficient than nothing, which is what supposedly is built-in at the moment.

  8. #8
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,556

    Default

    That's an interesting find, I will have to experiment with this.

  9. #9
    MSgt. Shooter Person
    Join Date
    Apr 2009
    Posts
    102

    Default

    There are a couple of other classes with a similar function, but this one seems like the best to use.

  10. #10

    Default

    maybe just use config-files? (for simple actions)

  11. #11
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,556

    Default

    There are a few problems with using config files in UE3.

  12. #12
    Veteran
    Join Date
    May 2007
    Location
    Above KillZ, Below StallZ
    Posts
    9,953

    Default

    Quote Originally Posted by fritzmonkey View Post
    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?
    I concur with Solid Snake, that is interesting. But is there a function to write somewhere?

  13. #13
    Redeemer
    Join Date
    Nov 2007
    Posts
    1,207

    Default

    Quote Originally Posted by Blade[UG] View Post
    I concur with Solid Snake, that is interesting. But is there a function to write somewhere?
    FileWriter, obviously. :P
    Nightblade, a stealth based total conversion for UT3

  14. #14
    Redeemer
    Join Date
    May 2000
    Location
    between the monitor and chair
    Posts
    1,523

    Default

    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

  15. #15
    Redeemer
    Join Date
    Sep 2002
    Location
    Ireland
    Posts
    1,146

    Default

    You can't use OnlineTitleFileDownloadMcp for files on a users hard drive, it seems; it uses http.

  16. #16
    MSgt. Shooter Person
    Join Date
    Apr 2009
    Posts
    102

    Default

    Were you able to test this? I would hate to give up on it before it has been tested.

  17. #17
    Redeemer
    Join Date
    Nov 2007
    Posts
    1,207

    Default

    Quote Originally Posted by elmuerte View Post
    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.
    He didn't ask about reading anything though. :P

    Quote Originally Posted by Shambler
    You can't use OnlineTitleFileDownloadMcp for files on a users hard drive, it seems; it uses http.
    http or urls? If it is the latter you could try the file:// protocol. But you've probably tried that. :/
    Last edited by immortius; 11-13-2009 at 05:28 AM.
    Nightblade, a stealth based total conversion for UT3

  18. #18
    Redeemer
    Join Date
    Sep 2002
    Location
    Ireland
    Posts
    1,146

    Default

    Well, I haven't tried it out directly, just gathered from hints in the .uc.

  19. #19
    Redeemer
    Join Date
    May 2000
    Location
    between the monitor and chair
    Posts
    1,523

    Default

    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

  20. #20
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,556

    Default

    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.
    Not sure what you mean here elmuerte, I tried it and it just wrote strings like I expected it to.

    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.

  21. #21
    Redeemer
    Join Date
    May 2000
    Location
    between the monitor and chair
    Posts
    1,523

    Default

    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

  22. #22
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,556

    Default

    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.

  23. #23
    MSgt. Shooter Person
    Join Date
    Apr 2009
    Posts
    102

    Default

    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.

  24. #24
    MSgt. Shooter Person
    Join Date
    Apr 2009
    Posts
    102

    Default

    Bumping so that people know the code is here. I forgot that editing doesn't bump the thread.

  25. #25
    Palace Guard

    Join Date
    Jun 2007
    Location
    Christchurch
    Posts
    3,556

    Default

    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.

  26. #26
    MSgt. Shooter Person
    Join Date
    Apr 2009
    Posts
    102

    Default

    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.

  27. #27
    MSgt. Shooter Person
    Join Date
    Nov 2009
    Posts
    171
    Gamer IDs

    Gamertag: xXTheSpaceManXx

    Default

    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.

  28. #28
    MSgt. Shooter Person
    Join Date
    Apr 2009
    Posts
    102

    Default

    I don't understand what you are saying.

  29. #29
    Redeemer
    Join Date
    Nov 2007
    Posts
    1,207

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.