Skip to main content

News

Topic: How to get to the Sphere root? (Read 5365 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
How to get to the Sphere root?
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.

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: How to get to the Sphere root?
Reply #1
Try:

~/icon.png

or

../icon.png
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • DaVince
  • [*][*][*][*][*]
  • Administrator
  • Used Sphere for, like, half my life
Re: How to get to the Sphere root?
Reply #2
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.
  • Last Edit: June 22, 2013, 08:51:28 pm by DaVince

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: How to get to the Sphere root?
Reply #3
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.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here