Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Directory Problems...

Author
Message
Jachan19
15
Years of Service
User Offline
Joined: 1st May 2011
Location:
Posted: 1st May 2011 10:39
I do have a hardbook to guide me how to... but there is just one thing I don't understand... (including try to test those commands as well). I know it's kinda like a beginner question but please, help me and it will relieve me too much to learn, so that my friends from other towns can receive all of my required files to load through the game program (to play without the Darkbasic Program)...
how can you write the commands that will search and SET the path toward to the folder of that directory? I use G:\ (just because I could lose the datas whenever my computer gets a chance to die) but when I would email them with attachments, it will be a big chance that they use C:\ but you should realize that you will NEVER know what folder would they create or put under different folder, others than "My Document" (just in any case)... so... yeah... how can you write the commands like that?
Thank to the person, who is willing to help me, so much!

P.S.: If you need an example to fill, like the file to look, it would be like OOORedCombo.png and OOOBlueCombo.png and OOOGreenCombo.png (there are MORE files but those three are just good example though)
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st May 2011 12:35
If you install my plug-ins (link in my signature), then you have a whole set of functions that provide the locations of various window directories.

Randomness 128
19
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 1st May 2011 20:35
You can use relative path names to load files no matter where they're saved, as long as they're always in the same place relative to the .exe file.

For example, if your exe file is "G:\Game\Game.exe" and you had an image that's "G:\Game\Media\Images\OOORedCombo.png" the relative path would be "Media\Images\OOORedCombo.png". If you use that path to load the image, it won't matter where the files are, as long as they're all together.

If, for example, someone put the game somewhere else, so perhaps the exe file is now "C:\Program Files\Jachan19\Game\Game.exe" and the image is now "C:\Program Files\Jachan19\Game\Media\Images\OOORedCombo.png", the path of the image relative to the .exe is still "Media\Images\OOORedCombo.png".

Security features included with Windows Vista and 7 will not let software save files to certain directories, although you can still load from them. If your game is installed to such a directory, you can load everything properly, but will not be able to save anything there. Therefore, if there's anything you want your game to save, it's best to save to the documents folder. IanM's post can help you with this.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 1st May 2011 20:54
Ah, that's what he meant!

Ok, then more specifically, the location of the running program can be retrieved using the DIR EXE() function from that help page.

Using Randomness 128's example, DIR EXE() will return a value of "G:\Game".

In addition, there are the PUSH DIR and POP DIR commands from my file plug-in - the PUSH DIR changes your current directory while remembering the previous directory, and POP DIR returns you to that previous directory.

Jachan19
15
Years of Service
User Offline
Joined: 1st May 2011
Location:
Posted: 1st May 2011 21:37
To Randomness 128... When I write like "KamenRiders\" (that's the ONLY one i have written in directory in hard drive or USB [G:\] either) in SET DIR, it won't work because I did tried... So are you saying that I need add one or two extra directories in that to make it work? Or must it be "#:\" to start with? "Media\Images\OOORedCombo.png" seem fine with me as long as it's pretty good to look around on someone else's computer... but as you already knew that, his/hers and mine are really different (i use G:\ and he/she use C:\ )... in other word, my path will be like this, G:\KamenRiders\OOORedCombo.png"... and his/her path would be too longer directory than that... How can I do that? I am sorry if it's already an answer you posted... I never tried to test it with two computers (i don't have any extra one)...

to IanM... okay, i will remember that with the link... but will it works on the someone-else computer that does not have plug-in?
Randomness 128
19
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 2nd May 2011 00:52
Just include the path to the file you want relative to the .exe.

If your .exe is "G:\KamenRiders\KamenRiders.exe" and your image is "G:\KamenRiders\OOORedCombo.png", you can just do this:

load image "OOORedCombo.png", 1

If your .exe is "G:\KamenRiders\KamenRiders.exe" and your image is "G:\KamenRiders\Media\Images\OOORedCombo.png", you can just do this:

load image "Media\Images\OOORedCombo.png", 1

It won't matter where the user puts your game, as long as they keep all of its files together.


Quote: "to IanM... okay, i will remember that with the link... but will it works on the someone-else computer that does not have plug-in?"

When you use the plug-in, it'll be included in your .exe file automatically.

Login to post a reply

Server time is: 2026-07-11 13:58:27
Your offset time is: 2026-07-11 13:58:27