Simple Command Line Plugin - UPDATED: 11/25 v0.91

This forum is currently in read-only mode.
From the Asset Store
Space Station SFX
$4 USD
50% off
Space Station SFX contains 91 sounds and 64 tracks of which 36 are seamless loops.
  • Well, I was bored this afternoon and I realized that a command line plugin could be pretty helpful, so I hammered one out over the course of the day, and this is what I have to show for it.

    Command Line Plugin - v0.91

    Download Now(no example) - 101KB

    Unfortunately, there's no example to go with the plugin because, honestly, it's pretty tough showing off a plugin like this. So, hopefully this is simple enough for anybody to pick up and figure out. I'll try to explain things as best as I can.

    First of all, this plugin allows you to retrieve any command line arguments that were passed to your application/game at execution. These could include various options or a file to load upon start of the program. There's also an action to execute an external program with command line arguments.

    Here's a list of the various conditions/actions/expressions, which should help when figuring out how to use the plugin:

    Conditions:

    For each argument - Loop through each command line argument sequentially. There are various expressions to retrieve information about the currently iterated argument.

    Actions:

    Execute file - Execute an external program and supply command line parameters for it to use. This could be used, for example, in the case of a level editor and game. The level editor could execute the game program with command line arguments telling the game what level to load. In this way, levels could be tested directly through the level editor.

    Expressions:

    Argument count - Get the amount of arguments that were passed to your application.

    Get argument - Get the argument at the specified index(1-indexed).

    Get argument name - Get the name of the argument at the specified index. In the following example -- arg=value -- "arg" is the name of the argument.

    Get argument value - Get the value of the argument at the specified index. In the following example -- arg=value -- "value" is the value of the argument. If the argument does not contain a value, the return value will be the string "NULL".

    Current argument - Used in conjunction with "For each argument". This gets the current argument in the loop.

    Current argument index - Used in conjunction with "For each argument". This gets the current index of the loop.

    Current argument name - Used in conjunction with "For each argument". This gets the name of the current argument. In the following example -- arg=value -- "arg" is the name of the argument.

    Current argument value - Used in conjunction with "For each argument". This gets the value of the current argument. In the following example -- arg=value -- "value" is the name of the argument.

    Hopefully that tells everybody most of what they need to know. It should be pretty easy to figure out.

    Just a note about when you use this to load a file at the start of the program -- whether by dragging an a file onto the EXE or opening a file through it -- the file will always be the first argument. Also, to check that this is actually a file, you should use the "File" object to check that a file at that location with that name exists.

    Well, that's it. I hope that somebody can find a use for this and that it's easy to understand. Be sure to leave any comments or suggestions you have.

    Have fun.

    EDIT: Forgot to mention that arguments are separated by spaces. If you want a single argument with spaces in it, put it in quotes.

  • sweet

  • Simple Command Line Plugin

    I love you D:

  • Thanks, guys.

    New version with added feature and a change:

    Command Line Plugin - v0.91

    Download Now(no example) - 101KB

    Adds/Changes/Fixes:

    [ADD] - "Start arguments" and "Use start arguments" property added to the edittime properties section. These allow you to specify starting arguments which will be passed to the application. This is useful during testing so that you don't have to build the app/game to test it with command line arguments. However, I suggest using this only for internal testing.

    [CHANGE] - The plugin should now be fully quicksave/quickload compliant, meaning that arguments will no longer be lost after using quickload.

    Once again, be sure to leave comments, suggestions, and any bug reports.

  • Linkman can you read minds?

    Just these days I was thinking about having a command line feature in Construct. And then it really happens.

    I can think of many cool ways to abuse this plugin already. Construct is more complete thx to you again linkman!!!

  • You're welcome.

    I've got another new version which brings a new feature, fix, and change:

    Command Line Plugin - v0.92

    Download Now(no example) - 101KB

    Adds/Changes/Fixes:

    [ADD] - "Get program path" expression added. This gets the path of the program, including the program name. This is usually the first command line argument, but has been absent from the arguments list. Now you can access it with this expression.

    [CHANGE] - The "Get argument", "Get argument name", and "Get argument value" expressions have been changed. Before, entering an index lower than 1 or higher than the greatest index would return "NULL". Now the first and last arguments will be returned, respectively.

    [FIX] - Inputting an index of "1" in the "Get argument", "Get argument name", and "Get argument value" expressions would return "NULL".

  • I guess it's very interesting and useful one! Keep up good work!

  • I love you. This is the one important thing my application was missing.

  • Brilliant. Thank you for making this. It is working for me so far.

  • Thanks, guys. I'm glad some of you have found it useful.

    I'm deeming this plugin complete, as I've found no bugs and have hit a rock wall in terms of features to add. I will now direct everyone to the thread in the completed addons section.

    [PLUGIN]Command Line (in: Completed addons)

    If you have any questions or comments, leave them there. I now invite the Bacon Fairy to lock this thread.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you, linkman!

    And your wish is the Bacon Fairy's command

    <img src="http://i49.tinypic.com/zxqo3n.jpg">

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)