Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Author Topic: command line parameteres when running a game  (Read 4702 times)

0 Members and 1 Guest are viewing this topic.

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
command line parameteres when running a game
« on: January 06, 2009, 06:46:59 AM »

Hey -
is there any way to pass some command line parameters to game.exe and read it from inside the WME script ?

Oded
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: command line parameteres when running a game
« Reply #1 on: January 06, 2009, 08:32:10 AM »

Not natively. You'd need to use the GetCommandLine Windows API function.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Re: command line parameteres when running a game
« Reply #2 on: January 06, 2009, 04:49:26 PM »

can you give me an example of how to use it within the WME code ?
I never used it, i'm used to just getting an array or ARGC ARGV... :)

Oded
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: command line parameteres when running a game
« Reply #3 on: January 06, 2009, 06:40:55 PM »

Hm, on second thoughts, I can see the function actually returns a pointer to the string containing command line (unlike filling a supplied buffer like most of the other functions do). I'm afraid there's no way for WME script to grab a string passed this way. Plugin is the only way in this case, I think.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re: command line parameteres when running a game
« Reply #4 on: January 06, 2009, 08:14:21 PM »

Plugin is the only way in this case, I think.

This should do the trick: http://wme.jerrot.de/wme_commandlinehelper.zip

Unzip the plugin into your WME program folder and use it like this from your script:

Code: WME Script
  1. var HelperObject = new CommandLineHelper();
  2. var params = HelperObject.Parameters;

This only returns a string, so you'll have to care yourself about splitting the string according to your needs with WME's String class.

If you want the C++ code to implement it in your own plugin or whatever, simply add this to your plugin's "GetProperty" method:

Code: C
  1.         if({FNAMEL}.html">strcmp(Name, "Parameters")==0)
  2.         {
  3.                 this->m_Parameters = GetCommandLine();
  4.                 Value->SetVal(m_Parameters);
  5.                 return true;
  6.         }
  7.  
« Last Edit: January 06, 2009, 08:29:45 PM by Jyujinkai »
Logged
Mooh!

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Re: command line parameteres when running a game
« Reply #5 on: January 06, 2009, 09:37:06 PM »

i'll check it out

Logged

SoundGuy

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Posts: 196
    • View Profile
Re: command line parameteres when running a game
« Reply #6 on: February 26, 2009, 04:42:38 PM »

it works! thanks.
Logged
 

Page created in 0.061 seconds with 38 queries.