Is there certain MonkeyX2 file types?

About Monkey 2 Forums Monkey 2 Programming Help Is there certain MonkeyX2 file types?

This topic contains 8 replies, has 3 voices, and was last updated by  EdzUp 1 year, 4 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #11831

    EdzUp
    Participant

    I’m asking as I’ve tried loading a .bytes file and a .text file but to no avail.

    Firstly I import it with:

    #Import “Data/Mapping/Galaxy.txt”

    after that I open it with a filestream using:

    MyHandle = FileStream.Open ( “asset::Galaxy.txt” )

    but it doesn’t allow me to open it. Is there a certain set of file types like MX1?

    #11834

    Hezkore
    Participant

    FileStream.Open has been acting weird for me too.
    It seems it doesn’t accept “asset::”

    So what you can do is just:
    MyHandle = FileStream.Open ( AssetsDir()+“Galaxy.txt”, “r” )

    OR possibly just use Stream instead:
    MyHandle:Stream = Stream.Open( “asset::Galaxy.txt”, “r” )

    OR use LoadString for simple text stuff:
    LoadString( “asset::Galaxy.txt” )

    #11835

    Mark Sibly
    Keymaster

    > It seems it doesn’t accept “asset::”

    Oops, bug, fixed in develop.

    #11840

    EdzUp
    Participant

    thanks Hezkore will try those after downloading and a rebuild 🙂

    #11846

    Mark Sibly
    Keymaster

    Actually, you shouldn’t really use FileStream for opening assets, instead use Stream.Open(…).

    This is because assets are not necessarily files (eg: on android) so FileStream.Open( “asset::….” ) will NOT work everywhere, but Stream.Open( “asset::…” ) WILL.

    I also added filesystem support for asset::, desktop:: etc so people could go FileType( “asset::blah…” ) but I now think this was a mistake, because “asset::” and co. are really nothing to do with any native filesystems at all, they are purely monkey2 constructs.

    #11848

    EdzUp
    Participant

    Allow me to offer this “Aaaaaarrrggghhhhh” I will rewrite my file handler now to incorporate streams 🙂

    #11852

    Hezkore
    Participant

    Good info Mark!

    You say Stream will work everywhere, will LoadString also work everywhere?

    This kind of stuff should be in the Docs 🙂

    What kind of situations you’d use the class in, what platforms it supports.
    And also why you’d want to use one thing over the other if there a other similar things (like FileStream & Stream)

    #11870

    Mark Sibly
    Keymaster

    will LoadString also work everywhere?

    Yes, because it uses Stream itself – well, it uses DataBuffer.Load which uses Stream.

    There should be no real reason to use FileStream directly. Stream.Open will return a FileStream when appropriate but you shouldn’t need to ‘know’ this.

    #11876

    EdzUp
    Participant

    ah coming from MX1 and converting code over didn’t make this apparent but now I know I will use Stream as it ha’s cross the board compatibility 🙂

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.