Plugin Commands Issue (here we are again!) SOLVED

Started by Dualnames, Thu 21/02/2019 09:04:34

Previous topic - Next topic

Dualnames

Code: AGS

char getName[1000];
engine->GetPathToFileInCompiledFolder("",getName);//Strangeland.exe
Mix_LoadMUS(getname+"ffv6.mp3");


So, this is throwing a compile error, I'm looking to use a code, that grabs the folder in which the game is being executed from (which can vary of course depending on where the user/player is installing the thing)
And from that directory (let's say it's C:/Strangeland) set a path name for an mp3.

Right now, I've been able to run my code perfectly setting specific paths of course, but I wanna set a relative path!
I have no absolute clue how 'GetPathToFileInCompiledFolder' works and what it returns. Mix_LoadMUS takes a char as an argument.


EDIT:

char* path;
_get_pgmptr(&path);
const char * getv = (const char *)path;
engine->AbortGame(getv);

This will print the absolute path + the exe
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Crimson Wizard

#1
First of all

Code: cpp
Mix_LoadMUS(getname+"ffv6.mp3");


This is wrong in C/C++ because you are trying to sum char* pointers rather than concatenate the string (the result of + is a memory address).
To combine arrays of chars you may use something like snprintf.

Formal example:
Code: cpp

char getDir[1000];
char fullPath[1000];
engine->GetPathToFileInCompiledFolder("",getDir);
snprintf(fullPath, sizeof(fullPath), "%s/%s", getDir, "ffv6.mp3");
Mix_LoadMUS(fullPath);


On the other hand, GetPathToFileInCompiledFolder is supposed to do this for you:
Code: cpp

char fullPath[1000];
engine->GetPathToFileInCompiledFolder("ffv6.mp3", fullPath);
Mix_LoadMUS(fullPath);



EDIT: But what bothers me, is that GetPathToFileInCompiledFolder may return relative path (relative to current working directory). Is it necessary for you to have absolute path instead?

Dualnames

The GetPathToFile is perfect <3 Forgot to reply here!
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Dualnames

Irrelevant question, does

Character_GetX = (SCAPI_CHARACTER_GETX)engine->GetScriptFunctionAddress("Character::get_X");

return screen coordinates or room coordinates?
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Crimson Wizard

Quote from: Dualnames on Sat 23/02/2019 01:01:07
Irrelevant question, does

Character_GetX = (SCAPI_CHARACTER_GETX)engine->GetScriptFunctionAddress("Character::get_X");

return screen coordinates or room coordinates?

Room coordinates, you are getting Character.X script property.

SMF spam blocked by CleanTalk