Pages: 1
Author Topic: [SOLVED]load files path relative to game folder  (38,401 Views)
Offline (Unknown gender) gra

Member
Joined: Feb 2013
Posts: 147
View profile
Posted on: March 07, 2013, 07:36:45 PM
how can do this?
i have try with clipboard_get_string at start for give path variable
and save game ,
but not is good becouse:
1 the function not go
2 not is professional  :D

ok i have environment_get_variable, in linux this can be used?
and i can set a enviroment variable at start of game?

i try with open ini to save variable of dir , but not go  >:(
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #1 Posted on: March 07, 2013, 09:08:29 PM
Try working_directory + "\file"
Offline (Unknown gender) gra

Member
Joined: Feb 2013
Posts: 147
View profile
Reply #2 Posted on: March 07, 2013, 09:38:16 PM
mm i have draw text on working_directory variable, but this variable is static , save the path of game, but only the path of folder game compiled, if i move file of game , the working path not modify, not good
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #3 Posted on: March 07, 2013, 09:42:20 PM
1. Where are you from gra? Your grammar seems very peculiar.
2. Some time ago paths were hardcoded to the compile dir. So it ended up being static. Currently this should be fixed and compiled games should show working directory.
Offline (Unknown gender) gra

Member
Joined: Feb 2013
Posts: 147
View profile
Reply #4 Posted on: March 07, 2013, 10:09:16 PM
Quote1. Where are you from gra? Your grammar seems very peculiar.
;D i'm italian sorry, my english stopped ten years ago, to school
Offline (Unknown gender) gra

Member
Joined: Feb 2013
Posts: 147
View profile
Reply #5 Posted on: March 08, 2013, 06:14:27 AM
Quote2. Some time ago paths were hardcoded to the compile dir. So it ended up being static. Currently this should be fixed and compiled games should show working directory.
anyway working_directory have another problem under linux becouse,
in linux is /file/path/
working directory write \file\path
but the real problem is how store in variable the actual position of game folder?
i have see get_working_directory but not go

environment_get_variable can be used ??
if yes in linux this not go
environment_get_variable("0")
my brother say that 0 release the path if game executable in linux enviroment variables
Offline (Unknown gender) gra

Member
Joined: Feb 2013
Posts: 147
View profile
Reply #6 Posted on: March 08, 2013, 03:32:00 PM
great news i have solved with c++
Quotegetenv("HOME")
wuuuwuuu lets go with external resource
Offline (Unknown gender) gra

Member
Joined: Feb 2013
Posts: 147
View profile
Reply #7 Posted on: March 27, 2013, 07:20:50 AM
in a script that execute a bash script i have found this
Quotecd ${0%/*}
this load in a folder of script , i have write
Quotegetenv("{0%/*}")
but not go ,any idea (for load in a folder of program)?
Offline (Unknown gender) Ideka

Member
Joined: Apr 2011
Posts: 85
View profile
Reply #8 Posted on: March 28, 2013, 06:07:14 AM
This will work. Maybe.
dir = parameter_string(0);
dir = string_copy(dir, 1, string_find(dir, "/"));
Offline (Unknown gender) gra

Member
Joined: Feb 2013
Posts: 147
View profile
Reply #9 Posted on: March 29, 2013, 07:00:38 AM
not work , string_find not is know by enigma
EDIT
good i have find
getenv("PWD")
this give a directory of executed bash script, for this fact:
GOOD
-this environment variable give full path of folders in linux
NOT GOOD
-this can't be view directly by enigma becouse the environment variable give a folder of enigma, for view, place the file of game in folder and execute
EDIT2
under windows the variable is CD,but i don'know why the program not start , wine problem or other
i try under windows if i switch  :D
getenv("CD")
for the explanation
linux
PWD print working directory
windows
CD current directory
Offline (Unknown gender) polygone

Contributor
Joined: Mar 2009
Posts: 794
View profile
Reply #10 Posted on: March 29, 2013, 04:27:02 PM
Hmm, maybe we should write a function in enigma to help with this.

file_in_game_directory(string filename)

It's not something I can write just myself through as I can't test cross-platform.
Offline (Unknown gender) gra

Member
Joined: Feb 2013
Posts: 147
View profile
Reply #11 Posted on: March 29, 2013, 05:53:42 PM
QuoteHmm, maybe we should write a function in enigma to help with this.
good idea, but the path is different in two system, for example
working_directory
have only the windows path (\with\this\bars) and is static in relation to compiled file  :(
The windows CD environment variable not go, anyway  >:(
EDIT
linux path have different bar /
Pages: 1