From 3dfc20eebee93abcd91e37069535b0fb5b3a3cd1 Mon Sep 17 00:00:00 2001 From: Boop Date: Tue, 17 Jun 2014 16:29:37 +0100 Subject: [PATCH] Fix a runtime for Mloc (mloc is so lazy) Also makes custom item spawning a tiny bit nicer! file will only be loaded once, instead of every time someone spawns --- code/modules/customitems/item_spawning.dm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/code/modules/customitems/item_spawning.dm b/code/modules/customitems/item_spawning.dm index 8682f6f69e..38f50bf742 100644 --- a/code/modules/customitems/item_spawning.dm +++ b/code/modules/customitems/item_spawning.dm @@ -4,12 +4,15 @@ //for multiple items just add mutliple entries, unless i change it to be a listlistlist //yes, it has to be an item, you can't pick up nonitems -/proc/EquipCustomItems(mob/living/carbon/human/M) - // load lines - var/file = file2text("config/custom_items.txt") - var/lines = text2list(file, "\n") +/var/list/custom_items = list() - for(var/line in lines) +/hook/startup/proc/loadCustomItems() + var/custom_items_file = file2text("config/custom_items.txt") + custom_items = text2list(custom_items_file, "\n") + return 1 + +/proc/EquipCustomItems(mob/living/carbon/human/M) + for(var/line in custom_items) // split & clean up var/list/Entry = text2list(line, ":") for(var/i = 1 to Entry.len) @@ -24,6 +27,8 @@ var/ok = 0 // 1 if the item was placed successfully P = trim(P) var/path = text2path(P) + if(!path) continue + var/obj/item/Item = new path() if(istype(Item,/obj/item/weapon/card/id)) //id card needs to replace the original ID