Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Arguments

I'm making a map editor much alike RMXP's in Ruby, but with native integration of my own scripts. What I'm trying to do is be able to go Right Click > Open With > Editor.bat and have it open my application.

Passing "ruby editor.rb maps/map.gmp" works okay.

I've tried "ruby editor.rb %~f1" and many other variants in batch but they all don't work - it pretty much ignores the ruby line completely, ending at the trailing pause. I inserted a snippit of code at the first line of my editor.rb to print the contents of ARGV to a file, but that doesn't even make the file. If I run the batch normally, it opens the new project screen fine, but when I open a file with the editor.bat it just crashes and doesn't run any Ruby at all.

How do I pass batch arguments to script arguments?
 
As far as I know. When dealing with batch scripts in windows you pass command line arguments to them in %1,%2, ..., %9 and then you use those in batch to form a command so contents of your editor.bat should be:

ruby editor.rb %1

But you should make sure to include a full path (because current working directory changes as you move around in Windows Explorer) to script location like this:

ruby "c:\path to your script\editor.rb" %1

Make sure you use "" since you probably have folders with spaces in their name in full path.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top