External Files and Pathing

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Can anyone explain in detail the best way to include external files in your application? I'm having weird, inconsistent results when I try to run my game on different computers. Recently I reinstalled Windows on a fresh hard drive, and parts of the game break depending on where I put the whole working directory.

    Here's the basic setup: I have my main application, DataJack.mfa. In the same MMF project, I have a separate .mfa application that is included in the main game as a sub-application; therefore it builds to a .ccn which I have to point to in the subapplication object properties while in the frame editor.

    Living in the same directory of the main .mfa files are several other directories which contain many .ini files that the game references in order to create missions or look up weapon stats, etc. To point to these, I reference them by path in the events editor. I.E., tell the ini object to load Appdrive$+Appdir$+"missions/m1.ini" and go from there.

    If I take my entire working directory and move it to, say, C:/, the inventory subapplication stops working.

    Part of the inventory subapplication uses the path variables to point to various .png files and load them into a Picture Object. When I move the game to a different computer, this completely ceases to work. No pictures are loaded.

    I've had the program spit out the path where it thinks the .png file is, and it looks correct in every way. Yet, for some reason, the picture object will not load the .png.

    I ran into a handful of other problems that seem to come and go at random. Loading .mp3s or .oggs sometimes seems to not work, again based on the path variables method. Not sure if this was an issue with the directshow object.

    So I have a few questions:


    1. Appdrive$ , Appdir$ , Apppath$ , AppTempPath$ : what exactly do these all refer to? Right now, I try to construct my path via Appdrive$+Appdir$ to get to the game's root directory, and then go from there. Is this right? Is there a simpler way? What is AppTempPath? Does this all refer to where the .mfa file lives, where the built .exe lives, or where MMF2 itself lives? What do these variables refer to when I use them in a subapplication?

    2. Because I actually use the subapplication object properties to point to inventory.ccn in MMF2 (instead of passing it a path variable at runtime,) it is included in the data elements "external files" list. I understand that this means it will be built into the installer? How does this differ from pointing to objects at runtime with path variables? Is one preferred over the other?


    Basically, I must be doing something fundamentally wrong and I don't have a consistent, working system in place. I'd like to understand the intricacies of relative pathing and external files in MMF2.

  • AppPath$ gives you the entire path to the folder of your application's working directory. This will work with network paths such as \\MyComputer\My Shared Folder\
    Appdrive$ gives you the Drive letter and a colon (may not work on network paths)
    Appdir$ gives you the rest of the path after the colon (may not work on network paths)
    AppTempPath$ gives you the path to a folder that Windows has allocated for you to temporarily put files.

    Normally, you never store information you plan to modify in your program's directory (as it is usually in the protected Program Files folder), but instead in either the All Users application data folder or the Application Data folder for the current user. The Application Data folder is, for example, at C:\Users\Your Username\Application Data\ and then you append Your Game or Software\ to the path and store your files there.

    However, you can keep files you need to access and not change in the same folder as your application and access them with just their name. For example, if you had a file called Image1.png in the same folder as your application, you could load it by the expression "Image1.png" with no AppPath$ or anything. If it is in a subfolder called Folder1, you could access it by "Folder1\Image1.png"

    Working as fast as I can on Fusion 3

  • AppPath$ gives you the entire path to the folder of your application's working directory. This will work with network paths such as \\MyComputer\My Shared Folder\
    Appdrive$ gives you the Drive letter and a colon (may not work on network paths)
    Appdir$ gives you the rest of the path after the colon (may not work on network paths)
    AppTempPath$ gives you the path to a folder that Windows has allocated for you to temporarily put files.

    Thanks so much! I've been looking for this straighforward, simple information for a while now. This is extremely helpful. I also didn't realize the last bit about relative pathing from the application directory, this changes everything.

    I'm still not sure why my game has trouble finding .pngs, especially since I'm 99% sure I have the path right... But now I can get down to serious testing.

  • Okay, I'm narrowing down my problem. As before, I have some .png files in a folder in the directory where the application builds. At runtime, I load these .pngs into an image object and they display.

    This works fine when I'm running in MMF2 Dev. When I build my application, leaving all else the same, it does not work: the images aren't displayed.

    I no longer think this is a pathing issue therefore, but I'm at a loss to explain it.

  • Okay, in case any else was wondering, I figured out the image issue.

    The image object (an "Active Picture" object) resides in a subapplication. It loaded images fine in MMF2, but when run as a .ccn from the larger, built application, would not.

    Just to test the pathing issue, I placed an Active Picture object in the frame of my main application, obnoxiously blocking most of the screen, and told it to load one of the images, just to see if it would work. When built and run, it did work- and so did the Active Picture objects in my subapplication, now.

    So now I've just included an Active Picture object in my main application, on the screen where most of this stuff takes place, and it doesn't load anything- it just sits there. Somehow, it makes the Active Picture objects in the subapplication work.

  • Yes, the main application will load extensions that it needs but sub applications rely on the extensions from the main application and does not try to load its own. You must have all extensions from the sub application in the main application too or the sub application won't be able to access them.

    Working as fast as I can on Fusion 3

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!