The Daily Click ::. Forums ::. Klik Coding Help ::. External files and pathing
 

Post Reply  Post Oekaki 
 

Posted By Message

Rick Shaw



Registered
  30/04/2008
Points
  158
8th April, 2012 at 08/04/2012 01:13:29 -

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. 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.

 
n/a

bernie[FA]



Registered
  17/10/2004
Points
  1898

Game of the Week Winner
8th April, 2012 at 08/04/2012 17:15:11 -

Apppath$ returns the absolute path to your application directory. If you want to point to a file, you go Apppath$+"myfile.txt" or Apppath$+"mydir\myfile.txt". The appdrive and appdir method seems needlessly complicated. The more complicated things are, the easier it is to bring errors in.

You could always see what each variable returns by making a string object display the current result. Then run your project from different locations and check what is returned to find what causes you problems.

 
n/a

Rick Shaw



Registered
  30/04/2008
Points
  158
8th April, 2012 at 08/04/2012 22:28:27 -

Thanks Bernie, I'll try that out. That might get me a little closer to fixing these bugs.

 
n/a

Rob Westbrook



Registered
  25/05/2007
Points
  193

360 OwnerVIP Member
10th April, 2012 at 10/04/2012 18:42:22 -

I use a relatively simple system using folders such as "images", "sfx", "music" in a main app folder, along with the .mfa (and .exe). Then use AppDir$ + "folder\file.whatever". As long as you distribute that whole app folder there shouldn't be any problems.

I like external files. I'd love to make a completely external file dependent engine using external images for everything graphical, and tying it all together with lua and ini/xml or something.

 
There are 10 types of people in the world: Those who understand binary and those who don't.

Rick Shaw



Registered
  30/04/2008
Points
  158
11th April, 2012 at 11/04/2012 01:14:18 -


Originally Posted by Rob Westbrook
I use a relatively simple system using folders such as "images", "sfx", "music" in a main app folder



What's your method for including music in your game? This is what I'm struggling with primarily at the moment.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click