Community Forum

Problem with g_currentModDirectory

Forum Overview >> Farming Simulator 2009

CategoryFarming Simulator 2009
Created19.06.2010 21:04


Andreas GroƟschedl (unknown) 19.06.2010 21:10
Hello!

I have a problem with the correct path to an image (for the overlay function).
I take this script for example: (its the beginning)

print("mod loaded: siloamount");

siloamounts = {};

function siloamounts:loadMap(name)


self.info_hudPath = Utils.getFilename("info_hud.png", g_currentModDirectory);
print(siloamounts.baseDirectory);
print(baseDirectory);
print(self.info_hudPath);
print(g_currentModDirectory);
self.hud = Overlay:new("hud", self.info_hudPath, 0, 0, 1, 1);

self.loadedMap = name;

end;
-----------------------------------------
the output is:

print(siloamounts.baseDirectory) = ""
print(baseDirectory) = ""
print(g_currentModDirectory) = ""
print(self.info_hudPath) = "info_hud.png"

error: can't load Resource (info_hud.png)

I use the Gold Edition (update)

Thank you for your help.

Andreas

Heady Planet-ls (Headshot XXL) 23.06.2010 20:02
try this:

self.info_hudPath = g_currentModDirectory.."info_hud.png";

Stefan Geiger - GIANTS Software 25.06.2010 13:42
g_currentModDirectory is only valid while the LUA file is being loaded.

self.baseDirectory is only valid for Specializations.

The way to solve this, is to store the directory in your own variable, while the LUA file is loaded.

So the first lines could look like this:

siloamounts = {};
siloamounts.modDirectory = g_currentModDirectory


And later you can use:
self.info_hudPath = Utils.getFilename("info_hud.png", siloamounts.modDirectory);



Note: Log in to post. Create a new account here.