Skip to content

Commit

Permalink
Add a config that allows for overriding ruin template variables (#1867)
Browse files Browse the repository at this point in the history
* Add a config that allows for overriding ruin template variables

* Use full typepath
  • Loading branch information
Absolucy authored Jun 6, 2024
1 parent a5c2603 commit 8e6666f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
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 @@ -5720,6 +5720,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

0 comments on commit 8e6666f

Please sign in to comment.