Spherical forums

Sphere Development => Sphere Support => Script Support => Topic started by: DaVince on June 22, 2013, 08:25:05 pm

Title: How to get to the Sphere root?
Post by: DaVince on June 22, 2013, 08:25:05 pm
I could have sworn that / would get you the root directory, but GetFileList() doesn't seem to like it (in both 1.5 and 1.6)... It'll just say this:

Code: [Select]
Invalid path: '/'


Doing some tricks with ../../ etc. gives me the same issues. Anyone know how to get there? I'm trying to make a new startup game that loads icon.png files from game dirs, but I just can't seem to get to the files... I even looked at the old Sphere 1.1 startup game and it didn't help whatsoever.
Title: Re: How to get to the Sphere root?
Post by: Radnen on June 22, 2013, 08:33:44 pm
Try:

~/icon.png

or

../icon.png
Title: Re: How to get to the Sphere root?
Post by: DaVince on June 22, 2013, 08:35:42 pm
That's only if you want the icon.png from the path of the game currently running, though. Once you try a path like /games/someothergame/icon.png, or ../../someothergame/icon.png... it just fails spectacularly. I remember some really old startup games using a png icon of some kind, but I can't find any of them...

Edit: after some experimenting, I found that GetFileList can escape out of its game directory. However, LoadImage cannot (when adding an extra ../ to escape out of the game's dir, Sphere aborts with an "invalid path" error). This is a problem.

Edit 2: oh no... OpenRawFile() is the same... I'm sure it used to not be like this - after all, the startup game in old versions of Sphere opened files in other game dirs entirely. What happened, here?

So in the end, I find out that I cannot make the kickass new startup game I planned to make, or at least, not with info.txt and icon.png reading support. Ah, well. Maybe it's time for a different kind of game launcher, anyway.
Title: Re: How to get to the Sphere root?
Post by: Radnen on June 23, 2013, 12:35:27 am
Have you tried rooting the path?

Code: (javascript) [Select]

Math.sqrt("../");


:P

I don't think you can access other peoples files. It was supposed to be a sandboxed engine.