Difference between revisions of "Simple Garage"

From Stunts Wiki
 
(3 intermediate revisions by the same user not shown)
Line 15: Line 15:
  
 
* '''addto''' ''<group>'' ''<car(s)>'' - Adds cars to a group
 
* '''addto''' ''<group>'' ''<car(s)>'' - Adds cars to a group
* '''bring''' ''<car(s)>'' - Brings cars out of the garage and to Stunts
+
* '''bring''' ''<car(s)>'' [[from] ''<garage>''] - Brings cars out of the garage and to Stunts
 
* '''car''' ''<car ID>'' - Retrieves information about a specific car
 
* '''car''' ''<car ID>'' - Retrieves information about a specific car
 
* '''cars''' - Returns the count of cars in Stunts and the garage
 
* '''cars''' - Returns the count of cars in Stunts and the garage
Line 21: Line 21:
 
* '''dirs''' - Outputs the currently set Stunts and garage directory paths
 
* '''dirs''' - Outputs the currently set Stunts and garage directory paths
 
* '''exit''' - Exits the command line interface
 
* '''exit''' - Exits the command line interface
 +
* '''garagedir''' [''<garage>''] ''<directory>'' - Sets the directory for a garage
 +
* '''garagename''' ''<garage>'' [''<new_name>''] - Sets a garage name
 +
* '''gdir''' - Short for '''garagedir'''
 +
* '''gname''' - Short for '''garagename'''
 
* '''groups''' - Lists all groups
 
* '''groups''' - Lists all groups
 
* '''groupthese''' ''<group>'' - Creates a group out of the cars currently in Stunts
 
* '''groupthese''' ''<group>'' - Creates a group out of the cars currently in Stunts
Line 29: Line 33:
 
* '''lg''' ''<car(s)>'' - Lists cars in the garage
 
* '''lg''' ''<car(s)>'' - Lists cars in the garage
 
* '''list''' ''<car(s)>'' - Lists all cars both in Stunts and the garage
 
* '''list''' ''<car(s)>'' - Lists all cars both in Stunts and the garage
 +
* '''lj''' ''<car(s)>'' - List cars in junkyard, if there is one
 
* '''lock''' ''<car ID>'' - Locks a car so that it won't move when other commands are executed
 
* '''lock''' ''<car ID>'' - Locks a car so that it won't move when other commands are executed
 
* '''locked''' - Lists currently locked cars
 
* '''locked''' - Lists currently locked cars
Line 34: Line 39:
 
* '''ls''' ''<car(s)>'' - Lists cars in Stunts
 
* '''ls''' ''<car(s)>'' - Lists cars in Stunts
 
* '''only''' ''<group>'' - Brings every car in the given group to Stunts and moves every other to the garage
 
* '''only''' ''<group>'' - Brings every car in the given group to Stunts and moves every other to the garage
* '''park''' ''<car(s)>'' - Moves cars to the garage
+
* '''park''' ''<car(s)>'' [''<garage>''] - Moves cars to a garage
 
* '''quit''' - Same as '''exit'''
 
* '''quit''' - Same as '''exit'''
 
* '''removefrom''' ''<group>'' ''<car(s)>'' - Removes cars from a group
 
* '''removefrom''' ''<group>'' ''<car(s)>'' - Removes cars from a group
 
* '''retrieve''' ''<car(s)>'' - Same as '''bring'''
 
* '''retrieve''' ''<car(s)>'' - Same as '''bring'''
 
* '''rf''' ''<group>'' ''<car(s)>'' - Short for '''removefrom'''
 
* '''rf''' ''<group>'' ''<car(s)>'' - Short for '''removefrom'''
 +
* '''rmg''' - Short for '''rmgarage'''
 +
* '''rmgarage''' ''<garage>'' - Removes a garage
 
* '''rmgroup''' ''<group>'' - Same as '''delgroup'''
 
* '''rmgroup''' ''<group>'' - Same as '''delgroup'''
 +
* '''stunts''' ''<directory>'' - Sets the directory where Stunts is located
 
* '''unlock''' ''<car ID>'' - Unlocks a car so that it can be freely moved by other commands
 
* '''unlock''' ''<car ID>'' - Unlocks a car so that it can be freely moved by other commands
 
* '''version''' - Displays the current program version
 
* '''version''' - Displays the current program version
  
 
So for example, you could create a group of fast cars by using filters by running ''addto fast pmin,jagu,p962,Melange''. Notice how you can use both car IDs and parts of the car names. You can also specify if it's the beginning or end of the name you're filtering, such as for creating a group of all Porsche cars: ''addto Porsche Porsche*''. If you consider that all Porsche cars are fast, you may want to add them all to the "fast" group: ''addto fast #Porsche''. A group is automatically created when you add the first car and automatically removed when you delete the last one. A word preceded by a pound sign will be understood as an actual group; otherwise, if it's four characters long, it'll be assumed to be a car ID. In any other case, it will be taken for a filter. A filter without an asterisk is the same as if it had astersisks at both ends, that is, ''March'' will target the Porsch March Indy, just like ''*March*'' would. Please note that filtering is case insensitive. Filters and car lists can be combined. Thus, ''ls fgto,#Porsche,Lambo'' will list the Ferrari GTO, all cars in the Porsche group and all Lamborghinis as long as they're currently in Stunts (not in the garage).
 
So for example, you could create a group of fast cars by using filters by running ''addto fast pmin,jagu,p962,Melange''. Notice how you can use both car IDs and parts of the car names. You can also specify if it's the beginning or end of the name you're filtering, such as for creating a group of all Porsche cars: ''addto Porsche Porsche*''. If you consider that all Porsche cars are fast, you may want to add them all to the "fast" group: ''addto fast #Porsche''. A group is automatically created when you add the first car and automatically removed when you delete the last one. A word preceded by a pound sign will be understood as an actual group; otherwise, if it's four characters long, it'll be assumed to be a car ID. In any other case, it will be taken for a filter. A filter without an asterisk is the same as if it had astersisks at both ends, that is, ''March'' will target the Porsch March Indy, just like ''*March*'' would. Please note that filtering is case insensitive. Filters and car lists can be combined. Thus, ''ls fgto,#Porsche,Lambo'' will list the Ferrari GTO, all cars in the Porsche group and all Lamborghinis as long as they're currently in Stunts (not in the garage).
 +
 +
== External command execution and scripting ==
 +
If a command line is specified when calling Simple Garage from the console (in any platform) an individual command can be executed and the output will be thrown in the console instead of the interface. This means that one can execute:
 +
 +
''sgar park pmin''
 +
 +
Which will cause the Porsche March Indy to be parked (as long as it is not locked) and will immediately return to the console. This can be exploited to create scripts and front-end garage programs. However, there is an issue regarding some special characters. Simple Garage has been made in FreeBasic, which is a multi-platform compiler. Under GNU/Linux, the bash console normally expands asterisks and replaces them with a list of files in the current directory before passing the result to the running program. Pound signs are also taken as comments and the rest of the line is not passed. While DOS and Windows do not exhibit this behaviour themselves, in order for FreeBasic programs to work transparently across different platforms, the compiler mimmicks this same strategy in those OSs as well. For this reason, to execute a command containing an asterisk and/or a pound sign, quotes must be added:
 +
 +
''sgar "bring Lambo*,#fast"''
 +
 +
As an alternative, and ''only'' when calling commands externally, a percent sign can replace an asterisk and an at sign can replace the pound sign. So this same command could be written this way:
 +
 +
''sgar bring lambo%,@fast''
 +
 +
Again, these character replacements will not be accepted within the GUI interface.
  
 
[[Category:Modding]]
 
[[Category:Modding]]
 +
[[Category:Tools]]

Latest revision as of 03:15, 9 January 2023

Simple Garage, also known as sgar for its command line program file name, is a garage managing tool created by Cas. It has the particular characteristic of being command line based. Simple Garage features its own command line interpreter, but can also be called to perform individual commands, opening the door for external scripting. It can run in GNU/Linux as well as in DOS and Windows.

Configuration

Simple Garage operates by managing two directories: Stunts directory and a garage directory. When run, it looks for a configuration file called sgar.cfg, where each line contains a configuration item, followed by an equals sign and its value. The following configuration items can be found:

  • stunts - The directory where Stunts can be found
  • garage - The directory that will be used for parking cars (putting away from Stunts)
  • locked - A list of car IDs separated by commas that should not be moved
  • group - A list of car IDs preceded by a group name followed by a colon. There can be many groups

For Simple Garage to work, all you need is to specify the two directories. The rest can be set up within the program environment. Commands can be used to list cars and move them back and forth between Stunts and the garage, creating and deleting groups, assigning cars to them, etc.

Calling commands

Commands consist of a command name and often one or more parameters, separated by spaces. Where a parameter represents a car, it can also be a group of cars. Actual groups are specified with an identifier preceeded by a pound sign (#), whereas ad-hoc groups can be issued by giving a list of car IDs separated by commas. In place of any car ID, a filter can be used, that is, a part of the car name. Following is a list of the commands available in Simple Garage:

  • addto <group> <car(s)> - Adds cars to a group
  • bring <car(s)> [[from] <garage>] - Brings cars out of the garage and to Stunts
  • car <car ID> - Retrieves information about a specific car
  • cars - Returns the count of cars in Stunts and the garage
  • delgroup <group> - Deletes a group
  • dirs - Outputs the currently set Stunts and garage directory paths
  • exit - Exits the command line interface
  • garagedir [<garage>] <directory> - Sets the directory for a garage
  • garagename <garage> [<new_name>] - Sets a garage name
  • gdir - Short for garagedir
  • gname - Short for garagename
  • groups - Lists all groups
  • groupthese <group> - Creates a group out of the cars currently in Stunts
  • gs - Short for groups
  • gt <group> - Short for groupthese
  • help [filters] - Shows help
  • l <car(s)> - Short for list
  • lg <car(s)> - Lists cars in the garage
  • list <car(s)> - Lists all cars both in Stunts and the garage
  • lj <car(s)> - List cars in junkyard, if there is one
  • lock <car ID> - Locks a car so that it won't move when other commands are executed
  • locked - Lists currently locked cars
  • lp <car(s)> - Stands for "list parked", same as lg
  • ls <car(s)> - Lists cars in Stunts
  • only <group> - Brings every car in the given group to Stunts and moves every other to the garage
  • park <car(s)> [<garage>] - Moves cars to a garage
  • quit - Same as exit
  • removefrom <group> <car(s)> - Removes cars from a group
  • retrieve <car(s)> - Same as bring
  • rf <group> <car(s)> - Short for removefrom
  • rmg - Short for rmgarage
  • rmgarage <garage> - Removes a garage
  • rmgroup <group> - Same as delgroup
  • stunts <directory> - Sets the directory where Stunts is located
  • unlock <car ID> - Unlocks a car so that it can be freely moved by other commands
  • version - Displays the current program version

So for example, you could create a group of fast cars by using filters by running addto fast pmin,jagu,p962,Melange. Notice how you can use both car IDs and parts of the car names. You can also specify if it's the beginning or end of the name you're filtering, such as for creating a group of all Porsche cars: addto Porsche Porsche*. If you consider that all Porsche cars are fast, you may want to add them all to the "fast" group: addto fast #Porsche. A group is automatically created when you add the first car and automatically removed when you delete the last one. A word preceded by a pound sign will be understood as an actual group; otherwise, if it's four characters long, it'll be assumed to be a car ID. In any other case, it will be taken for a filter. A filter without an asterisk is the same as if it had astersisks at both ends, that is, March will target the Porsch March Indy, just like *March* would. Please note that filtering is case insensitive. Filters and car lists can be combined. Thus, ls fgto,#Porsche,Lambo will list the Ferrari GTO, all cars in the Porsche group and all Lamborghinis as long as they're currently in Stunts (not in the garage).

External command execution and scripting

If a command line is specified when calling Simple Garage from the console (in any platform) an individual command can be executed and the output will be thrown in the console instead of the interface. This means that one can execute:

sgar park pmin

Which will cause the Porsche March Indy to be parked (as long as it is not locked) and will immediately return to the console. This can be exploited to create scripts and front-end garage programs. However, there is an issue regarding some special characters. Simple Garage has been made in FreeBasic, which is a multi-platform compiler. Under GNU/Linux, the bash console normally expands asterisks and replaces them with a list of files in the current directory before passing the result to the running program. Pound signs are also taken as comments and the rest of the line is not passed. While DOS and Windows do not exhibit this behaviour themselves, in order for FreeBasic programs to work transparently across different platforms, the compiler mimmicks this same strategy in those OSs as well. For this reason, to execute a command containing an asterisk and/or a pound sign, quotes must be added:

sgar "bring Lambo*,#fast"

As an alternative, and only when calling commands externally, a percent sign can replace an asterisk and an at sign can replace the pound sign. So this same command could be written this way:

sgar bring lambo%,@fast

Again, these character replacements will not be accepted within the GUI interface.