Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Ocra Path isn't found
- By ? Date 2009-11-29 20:45
Hey, a question of me again x)

I put a game into an executable with Ocra.
The file seems to contain all files (from its filesize) but when I start it the cmd window says me that the path C:\...\src\file cannot be found. It doesn't seem to have problems with libraries, just with images and maybe other additional files (like music)
- By banister Date 2009-11-29 21:36
just a tip...you really should create a gosu forum account name :))
- By Trebor777 Date 2009-11-29 22:31
Ocra doesn't embed the ressource the program uses, only the libraries needs to execute+the ruby interpreter.
you still need to provide the images/sound/whatever file with you .exe
- By Wurstinator Date 2009-11-30 11:22
@banister: Done.

@ Trebor777: But in the documentation it says:
"Additional files and resources

You can add additional files to the OCRA executable (for example images) by appending them to the command line. They should be placed in the source directory with your main script (or a subdirectory).

   ocra.rb mainscript.rb someimage.jpeg docs/document.txt

This will create the following layout in the temporary directory when your program is executed:

   src/mainscript.rb
   src/someimage.jpeg
   src/docs/document.txt

Paths on the command line can include ** globs to include a hierachy of files, for example: “ocra script.rb assets/*/.png”. "
- By jlnr (dev) Date 2009-11-30 14:04
Maybe this is something for the Ocra issue tracker? I don't see why the EXE should not be able to directly see resource files.
- By Wurstinator Date 2009-11-30 16:16
Never heard of the issue tracker. Where can I get it?
- By jlnr (dev) Date 2009-11-30 16:22 Edited 2009-11-30 16:53
Ouch, I didn't know there were github projects without a tracker, but ocra is one. I found this one, but it doesn't seem active:

http://rubyforge.org/tracker/?group_id=8185

Given that his RubyForge page doesn't even list any contact info, I don't know if he just doesn't want to be contacted about it. Weird?!

Edit: Oh, ippa just thankfully mailed him :) #gosu powah!
- By ippa Date 2009-11-30 16:54
I've mailed the Ocra-author about if the packed exe could change into the tmp directory it creates before executing the ruby-script.. I think this might solve some common problems.

My solution has always been using full paths in my games... File.join(ROOT, "gfx", "player.png") bla bla
- By Wurstinator Date 2009-11-30 17:15
ippa:

> My solution has always been using full paths in my
> games... File.join(ROOT, "gfx", "player.png") bla
> bla


I think you mean __FILE__ not ROOT.
With this it works now ... nearly :)
My images and sounds are included but not fmod.dll :/
- By jlnr (dev) Date 2009-11-30 18:51
You can also try changing the current directory, I think it is Dir.cd(File.dirname(__FILE__)). With some luck it happens early enough to get Windows to find FMOD.dll in the right place.
- By ippa Date 2009-11-30 19:02
with ROOT I meant.. a constant string with the path to the game root :).. which I usually get with ROOT = File.dirname(File.expand_path($0))
- By Wurstinator Date 2009-11-30 19:45
Wooho, I did it now ^.^
My code is:
Dir.chdir(File.dirname(__FILE__))

thank you two
(well, until I'll get another problem with ocra x)
- By ippa Date 2009-11-30 21:20
ippa wrote:

> Hi again Lars,
>
> A question that's popped up on the gosu-forums and #gosu:
>
> Someone packs an EXE in the games rootdir and it works. Then he movse
> the EXE to c:\ for example and it stops working. I can only read this as
> a path-problem (He hasn't used full paths in your script).
>
> Now, is there any reason why Ocra doesn't change into the tmp directory
> it creates before executing?
>  


If you mean, chdir to the temp directory then yes, there is a good reason. Suppose someone creates a command line utility with ocra; they wouldn't want ocra to "magically" change the current working directory of the Ruby script, as you would expect it to be able to read/write files in the current directory, where the command is execute. Therefore, ocra leaves your current working directory alone. The current working directory can be set to all kinds of places, depending on how you launch your program (command line, explorer, file association, as a service, etc etc.), so its better to not assume anything.

You can get the temp directory this way: File.dirname(File.dirname($0))

BR,
Lars
- By ippa Date 2009-11-30 21:21
But since Dir.chdir-thingie works great we don't have a problem anymore :)
- By jlnr (dev) Date 2009-12-01 06:57
I understand his point, I guess just don't think in terms of command line utilities on Windows. Anyway, all the Gosu examples and games DO NOT do the chdir properly—so I'm still thinking if I should bake it in or just include it at the top of every Gosu game. Oh, I was so looking forward to being able to start out with just require 'gosu' as the only required boilerplate in Ruby 1.9. :(
- By ippa Date 2009-12-01 15:31
I guess by checking OCRA_EXECUTABLE env it would be possible to only chdir when gosu is required from within an Ocra-EXE.

Would gosu doing this inside the exe affect my cmdline if I launch the game from there?
- By jlnr (dev) Date 2009-12-01 18:13
Yes. Would you want to run the game from a different directory based on a different set of resources? Actually my use case is more often that I am lazy and just want to run some_dir/Main.rb and wish it would do the chdir by itself :)
- By ippa Date 2009-12-01 21:54
The resourcething.. mm.., I don't see ppl using it? At least I wont :).

On the other hand, that chdir isn't a biggie to add yourself if you're bent on packing a Win32 exe.
Up Topic Gosu / Gosu Exchange / Ocra Path isn't found

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill