Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a config that allows for overriding ruin template variables #1867

Merged
merged 5 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/monkestation/ruins.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
["/datum/map_template/ruin/space/oldstation"]
always_place = true
32 changes: 32 additions & 0 deletions monkestation/code/datums/ruins.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
GLOBAL_LIST_INIT(ruin_config, load_ruin_config())
#define RUIN_CONFIG_FILE "config/monkestation/ruins.toml"

/datum/map_template/ruin/New()
. = ..()
var/list/this_ruin_config = GLOB.ruin_config[type]
if(this_ruin_config)
var/overrides = 0
for(var/variable in this_ruin_config)
if(!(variable in vars))
stack_trace("Invalid ruin configuration variable [variable] in ruin ([type]) variable changes.")
continue
vars[variable] = this_ruin_config[variable]
overrides += 1
log_config("Applied [overrides] var overrides for [type] from ruin config.")

/proc/load_ruin_config()
. = list()
if(!fexists(RUIN_CONFIG_FILE))
log_config("No ruin config file found, using empty config.")
return
var/list/ruin_config = rustg_read_toml_file(RUIN_CONFIG_FILE)
if(!length(ruin_config))
log_config("ruin token config file is empty, using empty config.")
return
for(var/ruin_config_id in ruin_config)
var/ruin_path = text2path(ruin_config_id)
if(!ispath(ruin_path, /datum/map_template/ruin))
continue
.[ruin_path] = ruin_config[ruin_config_id]

#undef RUIN_CONFIG_FILE
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5717,6 +5717,7 @@
#include "monkestation\code\datums\interaction_particle.dm"
#include "monkestation\code\datums\meta_tokens.dm"
#include "monkestation\code\datums\patreon_data.dm"
#include "monkestation\code\datums\ruins.dm"
#include "monkestation\code\datums\stamina_container.dm"
#include "monkestation\code\datums\twitch_data.dm"
#include "monkestation\code\datums\achievements\misc_achievements.dm"
Expand Down
Loading