lists and stuff

This commit is contained in:
kevinz000
2017-05-13 11:26:07 -07:00
parent e9a35b03f6
commit 9e0866871e
4 changed files with 59 additions and 0 deletions
@@ -7,6 +7,14 @@
#define DROP_TO_FLOOR 0
#define LOADING_TO_HUMAN 1
/proc/handle_roundstart_items(mob/living/M)
if(!M.ckey || !istype(M))
return FALSE
var/list/items = parse_custom_items_by_key(M.ckey)
if(isnull(items))
return FALSE
load_itemlist_to_mob(M, items, TRUE, TRUE, FALSE)
//Just incase there's extra mob selections in the future.....
/proc/load_itemlist_to_mob(mob/living/L, list/itemlist, drop_on_floor_if_full = TRUE, load_to_all_slots = TRUE, replace_slots = FALSE)
if(!istype(L) || !islist(itemlist))
@@ -0,0 +1,50 @@
#define CUSTOM_ITEM_LIST_FILE 'config/custom_items.txt'
GLOBAL_LIST(custom_item_list) //Assoc list in form of ckey = delimited paramlist.
//File should be in the format of Ckey|things, where things is in the form of itempath1=amount;itempath2=amount;itempath3=amount
//Each ckey should be on a different line!!
/proc/reload_custom_item_list(custom_filelist)
if(!custom_filelist)
custom_filelist = CUSTOM_ITEM_LIST_FILE
GLOB.custom_item_list = list()
var/list/file_lines = world.file2list(custom_filelist)
for(var/line in file_lines)
var/list/key_separation = splittext(line, "|")
var/key = key_separation[1]
var/items = key_separation[2]
if(!key)
continue
if(!items)
GLOB.custom_item_list[key] = "ERROR"
continue
GLOB.custom_item_list[key] = list()
var/list/item_separation = splittext(items, ";")
for(var/item_string in item_separation)
var/list/amount_separation = splittext(item_string, "=")
var/path_to_item = amount_separation[1]
if(!ispath(path_to_item))
GLOB.custom_item_list[key] += "ERROR"
var/amount_of_item = amount_separation[2]
if(!amount_of_item)
GLOB.custom_item_list[key][path_to_item] = "ERROR"
var/amount_of_item_num = 0
if(isnum(amount_of_item))
amount_of_item_num = amount_of_item
else
amount_of_item_num = text2num(amount_of_item)
if(!isnum(amount_of_item) || (amount_of_item < 1))
GLOB.custom_item_list[key][path_to_item] = "ERROR"
GLOB.custom_item_list[key][path_to_item] = amount_of_item_num
return GLOB.custom_item_list
/proc/parse_custom_items_by_key(ckey)
if(!ckey || !GLOB.custom_item_list[ckey])
return null
var/list/items = GLOB.custom_item_list[ckey]
for(var/I in items)
if(items[I] == "ERROR")
items -= I
continue
return items
View File
+1
View File
@@ -169,6 +169,7 @@
#include "code\citadel\dogborgstuff.dm"
#include "code\citadel\custom_loadout\custom_items.dm"
#include "code\citadel\custom_loadout\load_to_mob.dm"
#include "code\citadel\custom_loadout\read_from_file.dm"
#include "code\citadel\organs\breasts.dm"
#include "code\citadel\organs\eggsack.dm"
#include "code\citadel\organs\genitals.dm"