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

New releases and general discussions.

Post » Wed Nov 25, 2009 3:51 am

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.

[size=150:342o22u8]Command Line Plugin - v0.91[/size:342o22u8]
[size=125:342o22u8]Download Now(no example) - 101KB[/size:342o22u8]

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.
Moderator
B
97
S
36
G
19
Posts: 1,584
Reputation: 17,692

Post » Wed Nov 25, 2009 5:31 am

sweet
B
2
S
1
G
3
Posts: 59
Reputation: 1,118

Post » Wed Nov 25, 2009 9:22 am

[quote="linkman2004":1ynkjxqx]Simple Command Line Plugin[/quote:1ynkjxqx]

I love you D:
B
2
S
1
G
3
Posts: 118
Reputation: 1,336

Post » Wed Nov 25, 2009 10:38 pm

Thanks, guys. :)

New version with added feature and a change:

[size=150:1oezd1gr]Command Line Plugin - v0.91[/size:1oezd1gr]
[size=125:1oezd1gr]Download Now(no example) - 101KB[/size:1oezd1gr]

[size=115:1oezd1gr]Adds/Changes/Fixes:[/size:1oezd1gr]
[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.
Moderator
B
97
S
36
G
19
Posts: 1,584
Reputation: 17,692

Post » Wed Nov 25, 2009 10:47 pm

Linkman can you read minds?

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

I can think of many cool ways to abuse this plugin already. Construct is more complete thx to you again linkman!!! 8)
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Thu Nov 26, 2009 4:38 pm

You're welcome. :)

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

[size=150:1vl7nuke]Command Line Plugin - v0.92[/size:1vl7nuke]
[size=125:1vl7nuke]Download Now(no example) - 101KB[/size:1vl7nuke]

[size=115:1vl7nuke]Adds/Changes/Fixes:[/size:1vl7nuke]
[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".
Moderator
B
97
S
36
G
19
Posts: 1,584
Reputation: 17,692

Post » Sat Nov 28, 2009 12:41 pm

I guess it's very interesting and useful one! Keep up good work!
B
3
G
3
Posts: 29
Reputation: 933

Post » Mon Nov 30, 2009 5:20 pm

I love you. This is the one important thing my application was missing.
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Mon Nov 30, 2009 6:21 pm

Brilliant. Thank you for making this. It is working for me so far. :)
B
3
S
1
G
3
Posts: 82
Reputation: 1,189

Post » Sun Jan 24, 2010 5:49 am

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.
Moderator
B
97
S
36
G
19
Posts: 1,584
Reputation: 17,692

Next

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 1 guest