mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-12 15:45:25 +01:00
made custom items read from a config file
This commit is contained in:
@@ -3,29 +3,38 @@
|
||||
//gives item to specific people when they join if it can
|
||||
//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
|
||||
var/list/CustomItemList = list(
|
||||
// ckey real_name item path
|
||||
list("skymarshal", "Phillip Oswald", /obj/item/weapon/coin/silver), //Phillip likes to chew on cigars. Just unlit cigars, don't ask me why. Must be a clone thing. (Cigarette machines dispense cigars if they have a coin in them) --SkyMarshal
|
||||
list("spaceman96", "Trenna Seber", /obj/item/weapon/pen/multi), //For Spesss.
|
||||
list("asanadas", "Book Berner", /obj/item/clothing/under/chameleon/psyche)
|
||||
)
|
||||
|
||||
/proc/EquipCustomItems(mob/living/carbon/human/M)
|
||||
for(var/list/Entry in CustomItemList)
|
||||
// load lines
|
||||
var/file = file2text("config/custom_items.txt")
|
||||
var/lines = dd_text2list(file, "\n")
|
||||
|
||||
for(var/line in lines)
|
||||
// split & clean up
|
||||
var/list/Entry = dd_text2list(line, ":")
|
||||
for(var/i = 1 to parts.len)
|
||||
Entry[i] = trim(Entry[i])
|
||||
|
||||
if(Entry.len < 3)
|
||||
continue;
|
||||
|
||||
if(Entry[1] == M.ckey && Entry[2] == M.real_name)
|
||||
var/ok = 0 // 1 if the item was placed successfully
|
||||
var/path = Entry[3]
|
||||
var/obj/item/Item = new path()
|
||||
var/list/Paths = dd_text2list(Entry[3], ",")
|
||||
for(P in Paths)
|
||||
var/ok = 0 // 1 if the item was placed successfully
|
||||
P = trim(P)
|
||||
var/path = text2path(P)
|
||||
var/obj/item/Item = new path()
|
||||
|
||||
if(istype(M.back,/obj/item/weapon/storage) && M.back:contents.len < M.back:storage_slots) // Try to place it in something on the mob's back first
|
||||
Item.loc = M.back
|
||||
ok = 1
|
||||
else
|
||||
for(var/obj/item/weapon/storage/S in M.contents) // Try to place it in any item that can store stuff, on the mob.
|
||||
if (S:len < S:storage_slots)
|
||||
Item.loc = S
|
||||
ok = 1
|
||||
break
|
||||
if(istype(M.back,/obj/item/weapon/storage) && M.back:contents.len < M.back:storage_slots) // Try to place it in something on the mob's back first
|
||||
Item.loc = M.back
|
||||
ok = 1
|
||||
else
|
||||
for(var/obj/item/weapon/storage/S in M.contents) // Try to place it in any item that can store stuff, on the mob.
|
||||
if (S:len < S:storage_slots)
|
||||
Item.loc = S
|
||||
ok = 1
|
||||
break
|
||||
|
||||
if (ok == 0) // Finally, since everything else failed, place it on the ground
|
||||
Item.loc = get_turf(M.loc)
|
||||
if (ok == 0) // Finally, since everything else failed, place it on the ground
|
||||
Item.loc = get_turf(M.loc)
|
||||
Reference in New Issue
Block a user