Advertisement
SmallBlue

Split component

Jul 1st, 2021 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. /**
  2. * # Split component
  3. *
  4. * Splits a string
  5. */
  6. /obj/item/circuit_component/split
  7. display_name = "Split"
  8. display_desc = "Splits a string by the separator and turns it into a list"
  9.  
  10. /// The input port
  11. var/datum/port/input/input_port
  12.  
  13. /// The seperator
  14. var/datum/port/input/separator
  15.  
  16. /// The result from the output
  17. var/datum/port/output/output
  18.  
  19. circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL|CIRCUIT_FLAG_OUTPUT_SIGNAL
  20.  
  21. var/max_range = 5
  22.  
  23. /obj/item/circuit_component/split/Initialize()
  24. . = ..()
  25. input_port = add_input_port("Input", PORT_TYPE_STRING)
  26. separator = add_input_port("Seperator", PORT_TYPE_STRING)
  27. output = add_output_port("Output", PORT_TYPE_LIST)
  28.  
  29. /obj/item/circuit_component/split/Destroy()
  30. input_port = null
  31. separator = null
  32. output = null
  33. return ..()
  34.  
  35. /obj/item/circuit_component/split/input_received(datum/port/input/port)
  36. . = ..()
  37. if(.)
  38. return
  39.  
  40. var/separator = separator.input_value
  41. if(isnull(separator))
  42. return
  43.  
  44. var/value = input_port.input_value
  45. if(isnull(value))
  46. return
  47.  
  48. var/list/result = splittext(value,separator)
  49.  
  50. output.set_output(result)
  51.  
  52.  
  53. /**
  54. Using vendored Node v12.20.0
  55. => Starting 'dm'
  56. :: Skipping 'yarn' (up to date)
  57. :: Skipping 'tgui' (up to date)
  58. :: Skipping 'tgfont' (up to date)
  59. DM compiler version 514.1557
  60. loading tgstation.mdme
  61. loading interface\skin.dmf
  62. code\modules\wiremod\components\list\split.dm:40:error: separator.input_value: compile failed (possible infinite cross-reference loop)
  63. code\modules\wiremod\components\list\split.dm:41:error: separator: compile failed (possible infinite cross-reference loop)
  64. code\modules\wiremod\components\list\split.dm:49:error: separator: compile failed (possible infinite cross-reference loop)
  65. code\modules\wiremod\components\list\split.dm:51:error: result: compile failed (possible infinite cross-reference loop)
  66. tgstation.mdme.dmb - 4 errors, 0 warnings (7/1/21 10:40 pm)
  67. Total time: 0:59
  68. => Target 'dm' failed in 59.763s, exit code: 4294967295
  69. => Target 'default' failed
  70. Press any key to continue . . .
  71. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement