📁 A not-so-true-to-life implementation of .env (dot env) for gmod

Overview

gmsv_dot_env

A not-so-true-to-life implementation of a .env file for gmod. Place a .env at ./garrysmod/.env and any variables set in it will be accessible from within Lua through the env() function. The file will require you to run require("dot_env") at the top of a config file.

This does not respect ENVIRONMENT_VARIABLES defined outside of the .env. My intentions were (And always will be) to keep the context of the variables tight and strict, so they are only creatable through the .env file.

Also, this will only work on server side. So if you require it inside a shared file, make sure to account for that.

Also, idk wtf I'm doing with Rust and this is probably a low key mess

Install

  1. Place the dll in ./garrysmod/lua/bin.
  2. Create a .env file at ./garrysmod/.env.
  3. Populate the .env file with an appropriate config.
  4. Go to a config file and require the DLL at the top of the file: if SERVER then require('dot_env') end
  5. Set the config value using the env() function: MyAddon.Config.SQL.Password = env('MY_ADDON_SQL_PASSWORD') or "password".
  6. If you are using this in a shared context, you may need to account for that like so: MyAddon.Config.SharedValue = SERVER and (env('MY_ADDON_SHARED_VAL') or "Fallback") or "Client Fallback", but it is unlikely you would be using this in a shared context.

Credits

  • WilliamVenner - Making gmod-rs. Digging through his endless Gmod Rust DLL repos in order to understand how gmod-rs works. I also stole his build action, sue me.
  • dotenv-parser - Parsing the .env file. Because why make something yourself when someone has already done it better?
You might also like...
ESP32 implementation of RustZX Spectrum emulator for ESP32-USB-OTG

RustZX for ESP32 - experimental version Goal of the project: Run ZX Spectrum on ESP32 HW: ESP32 OTG USB with ST7789 display References Rust code for E

An implementation of Olm and Megolm in pure Rust.

A Rust implementation of Olm and Megolm vodozemac is a Rust implementation of libolm, a cryptographic library used for end-to-end encryption in Matrix

Pure Rust Implementation of secp256k1.

SECP256K1 implementation in pure Rust Cargo Documentation SECP256K1 implementation with no_std support. Currently we have implementation for: Convert

A Rust implementation of generic prefix tree (trie) map with wildcard capture support

prefix_tree_map A Rust implementation of generic prefix tree (trie) map with wildcard capture support. Design Trie is a good data structure for storin

fast rust implementation of online nonnegative matrix factorization as laid out in the paper "detect and track latent factors with online nonnegative matrix factorization"

ONMF status: early work in progress. still figuring this out. code still somewhat messy. api still in flux. fast rust implementation of online nonnega

An implementation of a predicative polymorphic language with bidirectional type inference and algebraic data types

Vinilla Lang Vanilla is a pure functional programming language based on System F, a classic but powerful type system. Merits Simple as it is, Vanilla

An implementation of Ngo et al's GenericJoin in timely dataflow.

dataflow-join A streaming implementation of Ngo et al's GenericJoin in timely dataflow. Ngo et al presented a very cool join algorithm, some details o

A modular implementation of timely dataflow in Rust

Timely Dataflow Timely dataflow is a low-latency cyclic dataflow computational model, introduced in the paper Naiad: a timely dataflow system. This pr

A radix tree implementation for router, and provides CRUD operations.

radixtree A radix tree implementation for router, and provides CRUD operations. Radixtree is part of treemux, on top of which updates and removes are

Owner
Owain
An ambitious developer, eager to learn!
Owain
A framebuffer that takes a `&[bool]` slice and returns 2x4 dot (pixel) braille `char`s

A framebuffer that takes a &[bool] slice and returns 2x4 "dot" (pixel) braille chars.

Odin Dutton 3 Mar 28, 2022
Control your .env like a boss

envctl ?? Take full control over your .env environment variables usage $ envctl --help Environment Variable Control Usage: envctl <COMMAND> Commands

Yuichiro Luke Smith 4 Apr 18, 2023
Additional Rust collections not found in std::collections

More collections Rust crate with additional collections not found in std::collections. Multimaps Completion Name Behaves like ?? ?? ?? ⬜️ ⬜️ HashSetMu

Rinde van Lon 4 Dec 21, 2022
A special rope, designed to work with any data type that is not String

AnyRope AnyRope is an arbitrary data type rope for Rust, designed for similar operations that a rope would do, but targeted at data types that are not

ahoyiski 27 Mar 22, 2023
Rust libraries for Bluesky's AT Protocol services. NOT STABLE (yet)

ATrium ATrium is a collection of Rust libraries designed to work with the AT Protocol, providing a versatile and coherent ecosystem for developers. Th

Yoshihiro Sugi 43 Jun 25, 2023
Indeed, an ORM library, not a framework, written in Rust

Ormlib Indeed, an ORM library, not a framework, written in Rust Features The main idea that I put into my ORM library is a minimum of stupid code and

Evgeny Igumnov 5 Sep 4, 2023
Rust Vector for large amounts of data, that does not copy when growing, by using full `mmap`'d pages.

Large Vector Rust Vector for large amounts of data, that does not copy when growing, by using full mmap'd pages. Maturity I made ths to learn about mm

Wonko der Verständige 21 Apr 23, 2024
Experimental Quantum Computer Simulator + Quantum Chess Implementation

Quantum Chess A somewhat hacky implementation of this paper (made in a week over a holiday). It's not heavily tested and probably has some bugs still

null 19 Jan 21, 2022
Ray Tracing: The Next Week implementation in Rust

rttnw Ray Tracing: The Next Week implementation in Rust How to run Install Rust: Link here. Run project git clone https://github.com/luliic2/rttnw cd

null 20 Apr 26, 2022
Rust implementation of µKanren, a featherweight relational programming language.

µKanren-rs This is a Rust implementation of µKanren, a featherweight relational programming language. See the original Scheme implementation here for

Eric Zhang 99 Dec 8, 2022