When I was first learning to code, Garry's Mod LUA scripting served as my teacher. My most notable project was the creation of a Capture the Flag gamemode, which consisted of two-phase gameplay: A construction phase, and a combat phase. During the first phase, players would join teams, and the captain of each team would choose a location. Once chosen, the players were given an allotted amount of time and a restricted amount of space to place their flag and construct defenses and weapons using the standard Garry's Mod physics tools and addons. At the end of the allotted time, the players were released to capture the enemy's flag using only the resources they could build for themselves in the first phase.
Although I built this gamemode when I was first learning to code, I recently returned to it and refactored it into a much more stable and balanced product, even uploading it to the Steam Workshop so that friends could easily download and play it.
The main script of the gamemode is set up to manage the two phases of gameplay. During the first phase, the players are allowed access to all the tools and weapons needed for classic GMod construction, however, players are invulnerable, and cannot leave the spheres that mark their base. Once both bases are placed, a timer begins. Once the timer hits zero, the game immediately resets the players, removes the spheres, makes players vulnerable, and locks the players from using the toolgun or the physics gun. The timer at the top of the screen also gets replaced with a score tracker, and the game continues until one side hits the target capture count, which is definable by the game host.
To control the flow of the game, blocks of code had to be placed in "hooks" or delegates that are added to many core functions of GMod, sometimes overriding default functionality, such as destroying restricted weapons whenever they're picked up by a player or relocating the player to their team's spawn point whenever they respawn. Many of these hooks were configured to take into account the different needs for the two phases of gameplay.
To further help control the flow of the game, several special entities had to be constructed. These include a weapon that is used to select an initial location, a sphere that controls the construction zone, a platform for teammates to spawn on, a base to hold the flag, and the flag itself.
Near the end of my college career, I found some friends who played Garry's Mod, and it led me to revisit this project. I took the opportunity to cleanup, reorganize, and dramatically improve the stability of the gamemode, much of which by migrating large sections of code from the gamemode global script into the entities and objects that the features of that code belonged to. The improvements to encapsulation also made it much easier to implement new features, such as victory conditions, and to improve balance.
With the new content and better balance, I finally uploaded my gamemode to the Steam Workshop, the place to download user content for games on the Steam platform, and made it available for others to download. I'd consider that a win!