Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Dualnames on Thu 21/02/2019 09:04:34

Title: Plugin Commands Issue (here we are again!) SOLVED
Post by: Dualnames on Thu 21/02/2019 09:04:34
Code (AGS) Select

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
Title: Re: Plugin Commands Issue (here we are again!)
Post by: Crimson Wizard on Thu 21/02/2019 09:52:05
First of all

Code (cpp) Select
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) Select

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) Select

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?
Title: Re: Plugin Commands Issue (here we are again!)
Post by: Dualnames on Sat 23/02/2019 00:28:52
The GetPathToFile is perfect <3 Forgot to reply here!
Title: Re: Plugin Commands Issue (here we are again!)
Post by: 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?
Title: Re: Plugin Commands Issue (here we are again!)
Post by: Crimson Wizard on Sat 23/02/2019 01:56:30
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.