Pages: 1
  Print  
Author Topic: [SOLVED]load files path relative to game folder  (Read 26512 times)
Offline (Unknown gender) gra
Posted on: March 07, 2013, 02:36:45 pm

Member
Joined: Feb 2013
Posts: 147

View Profile
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  >:(
« Last Edit: March 08, 2013, 10:33:06 am by gra » Logged
Offline (Male) polygone
Reply #1 Posted on: March 07, 2013, 04:08:29 pm

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
Try working_directory + "\file"
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) gra
Reply #2 Posted on: March 07, 2013, 04:38:16 pm

Member
Joined: Feb 2013
Posts: 147

View Profile
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
Logged
Offline (Unknown gender) TheExDeus
Reply #3 Posted on: March 07, 2013, 04:42:20 pm

Developer
Joined: Apr 2008
Posts: 1860

View Profile
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.
Logged
Offline (Unknown gender) gra
Reply #4 Posted on: March 07, 2013, 05:09:16 pm

Member
Joined: Feb 2013
Posts: 147

View Profile
Quote
1. Where are you from gra? Your grammar seems very peculiar.
;D i'm italian sorry, my english stopped ten years ago, to school
Logged
Offline (Unknown gender) gra
Reply #5 Posted on: March 08, 2013, 01:14:27 am

Member
Joined: Feb 2013
Posts: 147

View Profile
Quote
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.
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
Code: [Select]
environment_get_variable("0")my brother say that 0 release the path if game executable in linux enviroment variables
« Last Edit: March 08, 2013, 05:39:23 am by gra » Logged
Offline (Unknown gender) gra
Reply #6 Posted on: March 08, 2013, 10:32:00 am

Member
Joined: Feb 2013
Posts: 147

View Profile
great news i have solved with c++
Quote
getenv("HOME")
wuuuwuuu lets go with external resource
Logged
Offline (Unknown gender) gra
Reply #7 Posted on: March 27, 2013, 02:20:50 am

Member
Joined: Feb 2013
Posts: 147

View Profile
in a script that execute a bash script i have found this
Quote
cd ${0%/*}
this load in a folder of script , i have write
Quote
getenv("{0%/*}")
but not go ,any idea (for load in a folder of program)?
Logged
Offline (Unknown gender) Ideka
Reply #8 Posted on: March 28, 2013, 01:07:14 am

Member
Joined: Apr 2011
Posts: 85

View Profile
This will work. Maybe.
Code: [Select]
dir = parameter_string(0);
dir = string_copy(dir, 1, string_find(dir, "/"));
Logged
Offline (Unknown gender) gra
Reply #9 Posted on: March 29, 2013, 02:00:38 am

Member
Joined: Feb 2013
Posts: 147

View Profile
not work , string_find not is know by enigma
EDIT
good i have find
Code: [Select]
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
Code: [Select]
getenv("CD")for the explanation
linux
PWD print working directory
windows
CD current directory
« Last Edit: March 29, 2013, 03:10:45 am by gra » Logged
Offline (Male) polygone
Reply #10 Posted on: March 29, 2013, 11:27:02 am

Contributor
Location: England
Joined: Mar 2009
Posts: 794

View Profile
Hmm, maybe we should write a function in enigma to help with this.

Code: [Select]
file_in_game_directory(string filename)
It's not something I can write just myself through as I can't test cross-platform.
« Last Edit: March 29, 2013, 04:28:23 pm by polygone » Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) gra
Reply #11 Posted on: March 29, 2013, 12:53:42 pm

Member
Joined: Feb 2013
Posts: 147

View Profile
Quote
Hmm, maybe we should write a function in enigma to help with this.
good idea, but the path is different in two system, for example
Code: [Select]
working_directoryhave 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 /
Logged
Pages: 1
  Print