Clamps pill numbers between 1 and 20.

This commit is contained in:
Zuhayr
2013-11-23 13:47:20 +10:30
parent 85661195bc
commit 7cc1c93207
+26 -15
View File
@@ -204,6 +204,8 @@
var/bottlesprite = "1" //yes, strings
var/pillsprite = "1"
var/client/has_sprites = list()
var/waiting = null //Fix for spamming 'create multiple pills'
var/max_pill_count = 20
/obj/machinery/chem_master/New()
var/datum/reagents/R = new/datum/reagents(100)
@@ -348,23 +350,32 @@
icon_state = "mixer0"
else if (href_list["createpill"] || href_list["createpill_multiple"])
var/count = 1
if (href_list["createpill_multiple"]) count = isgoodnumber(input("Select the number of pills to make.", 10, pillamount) as num)
if (count > 20) count = 20 //Pevent people from creating huge stacks of pills easily. Maybe move the number to defines?
if (href_list["createpill_multiple"] && !waiting)
waiting = 1
count = Clamp(isgoodnumber(input("Select the number of pills to make.", 10, pillamount) as num),1,max_pill_count)
var/amount_per_pill = reagents.total_volume/count
if (amount_per_pill > 50) amount_per_pill = 50
var/name = reject_bad_text(input(usr,"Name:","Name your pill!","[reagents.get_master_reagent_name()] ([amount_per_pill] units)"))
while (count--)
var/obj/item/weapon/reagent_containers/pill/P = new/obj/item/weapon/reagent_containers/pill(src.loc)
if(!name) name = "[reagents.get_master_reagent_name()] ([amount_per_pill] units)"
P.name = "[name] pill"
P.pixel_x = rand(-7, 7) //random position
P.pixel_y = rand(-7, 7)
P.icon_state = "pill"+pillsprite
reagents.trans_to(P,amount_per_pill)
if(src.loaded_pill_bottle)
if(loaded_pill_bottle.contents.len < loaded_pill_bottle.storage_slots)
P.loc = loaded_pill_bottle
src.updateUsrDialog()
if(waiting < 2)
var/name = reject_bad_text(input(usr,"Name:","Name your pill!","[reagents.get_master_reagent_name()] ([amount_per_pill] units)"))
waiting = 2
while (count--)
var/obj/item/weapon/reagent_containers/pill/P = new/obj/item/weapon/reagent_containers/pill(src.loc)
if(!name) name = "[reagents.get_master_reagent_name()] ([amount_per_pill] units)"
P.name = "[name] pill"
P.pixel_x = rand(-7, 7) //random position
P.pixel_y = rand(-7, 7)
P.icon_state = "pill"+pillsprite
reagents.trans_to(P,amount_per_pill)
if(src.loaded_pill_bottle)
if(loaded_pill_bottle.contents.len < loaded_pill_bottle.storage_slots)
P.loc = loaded_pill_bottle
src.updateUsrDialog()
spawn(0)
waiting = null
else if (href_list["createbottle"])
if(!condi)
var/name = reject_bad_text(input(usr,"Name:","Name your bottle!","[reagents.get_master_reagent_name()] ([reagents.total_volume] units)"))