SHARE
TWEET

Untitled

a guest Feb 2nd, 2019 21 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // How 2 use: run /proc/test_disposal_system via Advanced ProcCall
  2. // locate the X and Y where normally disposed stuff should end up (usually the last bit of conveyor belt in front of the crusher door
  3. // wait and see what comes up!
  4. /proc/test_disposal_system(var/expected_x, var/expected_y, var/sleep_time = 600, var/test_path = "/obj/machinery/disposal")
  5.     if (!usr && (isnull(expected_x) || isnull(expected_y)))
  6.         return
  7.     if (isnull(expected_x))
  8.         expected_x = input(usr,"Please enter X coordinate") as null|num
  9.         if (isnull(expected_x))
  10.             return
  11.     if (isnull(expected_y))
  12.         expected_y = input(usr,"Please enter Y coordinate") as null|num
  13.         if (isnull(expected_y))
  14.             return
  15.  
  16.     var/list/dummy_list = list()
  17.     for (var/obj/machinery/disposal/D in world)
  18.         if (D.z != 1)
  19.             break
  20.         /*
  21.         if (D.type != text2path(test_path))
  22.             continue
  23.         */
  24.         var/obj/item/disposal_test_dummy/TD
  25.         // Mail chute test
  26.         if(istype(D, /obj/machinery/disposal/mail))
  27.             var/obj/machinery/disposal/mail/mail_chute = D
  28.  
  29.             mail_chute.Topic("?rescan=1", params2list("rescan=1"))
  30.             spawn(20)
  31.                 for(var/dest in mail_chute.destinations)
  32.                     var/obj/item/disposal_test_dummy/mail_test/MD = new /obj/item/disposal_test_dummy/mail_test(mail_chute)
  33.                     MD.source_disposal = mail_chute
  34.                     MD.destination_tag = dest
  35.                     mail_chute.destination_tag = dest
  36.                     //dummy_list.Add(MD)
  37.                     mail_chute.flush()
  38.  
  39.         else
  40.             //Regular chute
  41.             TD = new /obj/item/disposal_test_dummy(D)
  42.             TD.expected_x = expected_x
  43.             TD.expected_y = expected_y
  44.             dummy_list.Add(TD)
  45.             TD.source_disposal = D
  46.             spawn(0)
  47.                 D.flush()
  48.  
  49.     message_coders("test_disposal_system() sleeping [sleep_time] and spawned [dummy_list.len] dummies")
  50.     sleep(sleep_time)
  51.  
  52.     var/successes = 0
  53.     for (var/obj/item/disposal_test_dummy/TD in dummy_list)
  54.         if (!TD.report_fail())
  55.             successes ++
  56.        
  57.         qdel(TD)
  58.  
  59.     message_coders("Disposal test completed with [successes] successes")
  60.  
  61. /obj/item/disposal_test_dummy
  62.     icon = 'icons/misc/bird.dmi'
  63.     icon_state = "bhooty"
  64.     name = "wtf"
  65.     var/obj/machinery/disposal/source_disposal = null
  66.     var/expected_x = 0
  67.     var/expected_y = 0
  68.  
  69.     proc/report_fail()
  70.         if(src.x != expected_x || src.y != expected_y)
  71.             message_coders("test dummy misrouted at [log_loc(src)][src.source_disposal ? " from [log_loc(src.source_disposal)]" : " (source disposal destroyed)"]")
  72.             return 1
  73.  
  74.         return 0
  75.  
  76. /obj/item/disposal_test_dummy/mail_test
  77.     var/obj/machinery/disposal/mail/destination_disposal = null
  78.     var/destination_tag = null
  79.     var/success = 0
  80.  
  81. /obj/item/disposal_test_dummy/mail_test/pipe_eject()
  82.     destination_disposal = locate(/obj/machinery/disposal/mail) in src.loc
  83.     if(destination_disposal && destination_disposal.mail_tag == destination_tag)
  84.         success = 1
  85.     spawn(50)
  86.         report_fail()
  87.         qdel(src)
  88.     ..()
  89.  
  90. /obj/item/disposal_test_dummy/mail_test/report_fail()
  91.     if(!success)
  92.         message_coders("mail dummy misrouted at [log_loc(src)] from [log_loc(source_disposal)], destination: [destination_tag], reached: [log_loc(destination_disposal)]")
  93.         return 1
  94.     return 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top