Contributors - lucaswhitaker22/bash_cafe GitHub Wiki
IMPORTANT: Feel free to contribute to this page, if you see anything missing, feel free to add it.
Contents:
General Rules for Contributors
- Feel free to ask for help or if you are confused
- Give feedback!
File Organization
The main script is called bash_cafe.sh, which will be refereed to as the master script. This includes the main loop which loops once per day in game. This script should also include all global variables with comments explaining when, where and how they are used.
You will see that bash_cafe.sh refers to a number of other function libraries. These libraries (with exceptions) are in /scripts/functions . Currently, the scripts are as follows:
- menu_functions.sh
- save_load_functions.sh (in /saves)
- upgrade_functions.sh
- weather_functions.sh
- calculation_functions.sh
Menu Functions
Despite its name, this library has more then just menu functions. It also includes any functions that handles some user-interface stuff (ex. center() centers the cursor and text in the middle of the terminal) while other user-interface stuff is handled in the master script. It also includes some functions that perform the task of a menu (ex. handle_menu)
Save/Load Functions
This library is in /saves not /library. save_load_functions.sh handles anything related to save and loading game sessions. Games are saved by writing data to a text file in the /saves file.
Upgrade Functions
Empty for now, is a work in progress
Weather Functions
Empty for now, is a work in progress
Calculation Functions
This function library should include any functions that perform arithmetic operations. For example:
- Calculation profit
- Calculating sale multiplier
In conclusion, if you create new functions, add them to the suitable library. If there is no suitable library, create a new one in the "functions" folder. Make sure to source it to any other scripts that may use it.
Loading Libraries
To use the libraries in a script, make sure to load them at the top of the script like so:
#!/usr/bin/env bash
. saves/save_load_functions.sh
. functions/menu_functions.sh
. functions/calculation_functions.sh
. functions/weather_functions.sh
. functions/upgrade_functions.sh
Reading Comments:
In both the master script and function scripts, you may see functions that are not declared in that script itself, but in one of the function libraries. This will be indicated by a comment following this format:
#<whatever the function does> (in <the function library>)
for example:
#centers cursor and outputs text in middle of terminal (in menu_functions)
Other comments may describe commands and statements. In theory, basically everything should have a comment so anyone will be able to understand what is going on.
The comments are still a work in progress. If you add code, add necessary comments. If you see code that may be confusing to newcomers, add comments to help them out.