Advertisement
benshepherd

garrysmod e2 ram

Aug 17th, 2014
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. @name
  2. @inputs KeyInput Reset
  3. @outputs Index Text:string
  4. @persist KeyLog:string Data:array Menu
  5. @trigger
  6.  
  7. #Set menu to first
  8. if(first())
  9. {
  10. Menu = 0
  11. Index = 0
  12. Reset = 0
  13. }
  14.  
  15. #Manual reset
  16. if(Reset)
  17. {
  18. Menu = 0
  19. Index = 0
  20. KeyLog = ""
  21. exit()
  22. }
  23.  
  24. #Key Chars
  25. KEY_BACKSPACE = 127
  26. KEY_LEFTSHIFT = 154
  27. KEY_ENTER = 13
  28. KEY_NUM1 = 49
  29. KEY_NUM2 = 50
  30. KEY_NUM3 = 51
  31.  
  32. #Delete character
  33. if(KeyInput == KEY_BACKSPACE)
  34. {
  35. KeyLog = KeyLog:sub(1,-2)
  36. }
  37. #Append to KeyLog
  38. elseif(KeyInput > 0 && KeyInput != KEY_LEFTSHIFT && KeyInput != KEY_ENTER)
  39. {
  40. KeyLog += toChar(KeyInput)
  41. }
  42.  
  43.  
  44. #Display Menu(s)
  45. MT = ""
  46. MT += "-- Menu Options --\n"
  47. MT += "- Addr " + Index + " -\n\n"
  48.  
  49. #0 - No menu selected
  50. if(Menu == 0)
  51. {
  52. MT += "[1] Change Address\n"
  53. MT += "[2] Write data\n"
  54. MT += "[3] Read data\n"
  55. MT += "\nInput: "+KeyLog+"\n"
  56.  
  57. #User has selected 'Change Address'
  58. if(KeyLog == "1" && KeyInput == KEY_ENTER)
  59. {
  60. Menu = 1
  61. KeyLog = ""
  62. exit()
  63.  
  64. }
  65. #User has selected 'Write Data'
  66. if(KeyLog == "2" && KeyInput == KEY_ENTER)
  67. {
  68. Menu = 2
  69. KeyLog = ""
  70. exit()
  71.  
  72. }
  73. #User has selected 'Write Data'
  74. if(KeyLog == "3" && KeyInput == KEY_ENTER)
  75. {
  76. Menu = 3
  77. KeyLog = ""
  78. exit()
  79.  
  80. }
  81. }
  82.  
  83. #1 - Change their address
  84. if(Menu == 1)
  85. {
  86. MT += "Enter New Address (1 - 32):\n"
  87. MT += KeyLog + "\n"
  88. }
  89. #User has selected their address
  90. if(KeyInput == KEY_ENTER)
  91. {
  92. Index = KeyLog:toNumber()
  93. KeyLog = ""
  94. Menu = 0
  95. exit()
  96. }
  97.  
  98. #2 - Write to address
  99. if(Menu == 2)
  100. {
  101. MT += "Type 'exit' to return\n"
  102. MT += "Press enter to save input\n"
  103. MT += "Input:\n" + KeyLog
  104.  
  105. if(KeyInput == KEY_ENTER)
  106. {
  107. if(KeyLog != "exit")
  108. {
  109. Data:setString(Index, KeyLog)
  110. }
  111.  
  112. KeyLog = ""
  113. Menu = 0
  114. exit()
  115. }
  116. }
  117.  
  118. if(Menu == 3)
  119. {
  120. MT += "Address " + Index + " returned:\n" + Data:string(Index)
  121.  
  122. if(KeyInput == KEY_ENTER)
  123. {
  124. Menu = 0
  125. KeyLog = ""
  126. exit()
  127. }
  128. }
  129.  
  130. #Write menu
  131. Text = MT
  132. exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement