Advertisement
xiebozhi

Automatic MineResetLite Builder - Command Helper Script

Dec 8th, 2012
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.58 KB | None | 0 0
  1. ################## Mine Creation Automation
  2. # DEPENDENCY 1: This is a script that works with CommandHelper (CH) in the config.txt
  3. # ### You will have to add many CH permissions to your staff and users for this to work
  4. # ### The console will tell you which perm is currently preventing the function from working.
  5. # DEPENDENCY 2: MineReset Lite
  6. # DEPENDENCY 3: *Optional* Command Signs - lets you use /payResetMine,/payClearBedrock on a sign
  7. #
  8. # *Tabs are ok to use with CommandHelper, its a great plugin for casual programmers
  9. # This script is open source, made by Bobb Shields of Team[GLOKK]
  10. # Fill out the application at http://teamglokk.enjin.com/recruitment to get white-listed.
  11. #
  12. ###########
  13.  
  14. ### This allows an OP with WorldEdit and WorldGuard to build a bedrock wall around a future mine
  15. ### It is overloaded so you can just build a box with /prepareMine
  16. ### Or you can call the next function by providing a $name for a default quality 'A' mine.
  17. ### You may further specify a $quality of {A,B,C,D1,D2}
  18. ### A is the worst, then B, C, and the D's stand for Donor 1 and 2
  19. #
  20. # This will create a MineResetLite mine of whatever name you give it. It will also
  21. # create a WorldGuard region in the heart of the mine so that permissions can be
  22. # restricted (add your own custom commands below) but also for /payClearMine which
  23. # clears out the blocks (including bedrock) from the mines for a high price. This is needed
  24. # due to the fillMode Setting of MRL that when true, only resets the air blocks.
  25. ##### The donor Qualities do not contain bedrock!
  26. #
  27. # No Command Helper perms used because the scripted commands already require them
  28. /prepareMine [$name='none'] [$quality='A']= >>>
  29. run ('/region remove '.$name)
  30. run ('//pos1')
  31. run ('//pos2') #current position is the block your feet are in
  32. run ('//shift 2 me') #so the user isn't pushed out of the way
  33. run ('//expand 40 me')
  34. run ('//expand 40 r')
  35. run ('//shift 1 d')
  36. run ('//set bedrock') #floor
  37. run ('//shift 22 u')
  38. run ('//set bedrock') #ceiling
  39. run ('//shift 1 d')
  40. run ('//expand 20 d')
  41. run ('//outset 1')
  42. run ('//walls bedrock') #walls
  43. run ('//inset 1')
  44. run ('/region define '.$name )
  45. run ('//pos1')
  46. run ('//pos2')
  47. run ('//shift 1 me')
  48. run ('//expand 1 r')
  49. run ('//shift 1 d')
  50. run ('//set glass')
  51. run ('//shift 1 d')
  52. run ('//set glowstone')
  53. run ('//shift 1 d')
  54. run ('//set bedrock')
  55. run ('//shift 3 u')
  56. run ('//expand 2 u')
  57. run ('//set 0') # Make the doorway
  58. run ('//pos1')
  59. run ('//pos2')
  60. run ('//shift 2 me')
  61. run ('//expand 40 me')
  62. run ('//expand 40 r')
  63. run ('//expand 20 u')
  64. run ('//set 0')
  65. # Future update: make the two signs and clear a gangway at the entrance
  66. #run ('' #Region permissions could go here #)
  67.  
  68. if ( equals($name,'none'),
  69. msg ('You may now run the /createMine command to complete the mine')
  70. ,
  71. call_alias(/createMine $name $quality)
  72. )
  73. <<<
  74.  
  75. ### Overload it for more user-friendly /mine
  76. /mine = /mrl
  77. /mine $ = /mrl $
  78.  
  79. ### This creates the percentages in the mines
  80. /createMine $name [$quality='A'] = >>>
  81.  
  82. # Delete the existing mine first. Allows mine percentages to be updated in the same
  83. # that they were created
  84. run ('/mrl erase '.$name)
  85.  
  86. ## This is a SELECT statement with CASES. Its syntax is based soley on commas
  87. # To make a new group, Copy { 'A', TO THE , BEFORE THE 'B', } then change A to whatever label
  88. # To adjust the percentages, go to the appropriate Quality then look for the right label
  89. switch ( $quality,
  90. 'A',
  91. assign(@b,.3)
  92. assign(@e,.2)
  93. assign(@d,.2)
  94. assign(@l,.4)
  95. assign(@g,.5)
  96. assign(@gl,.5)
  97. assign(@c,1)
  98. assign(@w,1.5)
  99. assign(@r,3)
  100. assign(@gr,6)
  101. assign(@i,7)
  102. assign(@f,7)
  103. assign(@s,10)
  104. assign(@a,15)
  105. assign(@dt,15)
  106. assign(@st,31.8)
  107. assign(@o,.1)
  108. ,
  109. 'B',
  110. assign(@b,.2)
  111. assign(@e,.3)
  112. assign(@d,.3)
  113. assign(@l,.3)
  114. assign(@g,.6)
  115. assign(@gl,1)
  116. assign(@c,3)
  117. assign(@w,1)
  118. assign(@r,3)
  119. assign(@gr,5)
  120. assign(@i,9)
  121. assign(@f,8)
  122. assign(@s,7)
  123. assign(@a,10)
  124. assign(@dt,10)
  125. assign(@st,39.8)
  126. assign(@o,1)
  127. ,
  128. 'C',
  129. assign(@b,.1)
  130. assign(@e,.4)
  131. assign(@d,.4)
  132. assign(@l,.2)
  133. assign(@g,.7)
  134. assign(@gl,2.5)
  135. assign(@c,5)
  136. assign(@w,.5)
  137. assign(@r,5)
  138. assign(@gr,4)
  139. assign(@i,11)
  140. assign(@f,9)
  141. assign(@s,5)
  142. assign(@a,5)
  143. assign(@dt,5)
  144. assign(@st,43.7)
  145. assign(@o,2)
  146. ,
  147. 'D1',
  148. assign(@b,.0)
  149. assign(@e,.4)
  150. assign(@d,.4)
  151. assign(@l,.2)
  152. assign(@g,.7)
  153. assign(@gl,2.5)
  154. assign(@c,5)
  155. assign(@w,.5)
  156. assign(@r,6)
  157. assign(@gr,3)
  158. assign(@i,12)
  159. assign(@f,10)
  160. assign(@s,7)
  161. assign(@a,3)
  162. assign(@dt,4)
  163. assign(@st,39.5)
  164. assign(@o,3)
  165. ,
  166. 'D2',
  167. assign(@b,0)
  168. assign(@e,.5)
  169. assign(@d,.5)
  170. assign(@l,.1)
  171. assign(@g,1)
  172. assign(@gl,4)
  173. assign(@c,8)
  174. assign(@w,.1)
  175. assign(@r,7)
  176. assign(@gr,3)
  177. assign(@i,13)
  178. assign(@f,11)
  179. assign(@s,8)
  180. assign(@a,1)
  181. assign(@dt,3)
  182. assign(@st,35.3)
  183. assign(@o,4)
  184. )
  185.  
  186. # Make the mine and assign the percentages. This is the real
  187. # reason these were scripted- to make everything consistent!
  188. run ('/mrl create '.$name )
  189. run ('/mrl set '.$name.' bedrock '.@b.'%')
  190. run ('/mrl set '.$name.' emerald_ore '.@e.'%')
  191. run ('/mrl set '.$name.' diamond_ore '.@d.'%')
  192. run ('/mrl set '.$name.' lava '.@l.'%')
  193. run ('/mrl set '.$name.' gold_ore '.@g.'%')
  194. run ('/mrl set '.$name.' glowstone '.@gl.'%')
  195. run ('/mrl set '.$name.' clay '.@c.'%')
  196. run ('/mrl set '.$name.' water '.@w.'%')
  197. run ('/mrl set '.$name.' redstone_ore '.@r.'%')
  198. run ('/mrl set '.$name.' gravel '.@gr.'%')
  199. run ('/mrl set '.$name.' iron_ore '.@i.'%')
  200. run ('/mrl set '.$name.' coal_ore '.@f.'%')
  201. run ('/mrl set '.$name.' sand '.@s.'%')
  202. run ('/mrl set '.$name.' air '.@a.'%')
  203. run ('/mrl set '.$name.' dirt '.@dt.'%')
  204. run ('/mrl set '.$name.' stone '.@st.'%')
  205. run ('/mrl set '.$name.' obsidian '.@o.'%')
  206.  
  207. run ('/mrl flag '.$name.' resetDelay 10080') # Weekly resets (in minutes)
  208. run ('/mrl flag '.$name.' resetWarnings 1440,360,180,60,30,10,1') #Saying the mine will reset
  209. run ('/mrl flag '.$name.' fillMode true') # True means only air will be replaced on reset
  210.  
  211. # Let everyone know the mine has been installed, its fair game from here
  212. broadcast ( player().' has installed a mine named '.$name)
  213. run ('/mrl reset '.$name.'')
  214.  
  215. # How we got around the lack of signs with MRL is by making these two custom commands
  216. # that take payment from the users to run some OP commands to reset the mine, and
  217. # to //set 0 the region where the mine is- to clear accumulating bedrock
  218. msg ('Remember to place a sign then do ')
  219. msg ('/cmds 1 /payMineReset '.$name.' 10,000' )
  220. msg ('and then click the Reset Sign, and then do')
  221. msg ('/cmds 1 /payClearMine '.$name. ' 50,000' )
  222. msg ('and then click the Clear Sign')
  223.  
  224. # And thank the staffer who installed the mine
  225. msg ('Mine '.$name.' has been created. Thank you, '.player().'!')
  226. <<<
  227.  
  228. #### Confirmation of /yes or /no for payment commands
  229. /yes = >>>
  230. assign(@key, concat('confirmation.', player()))
  231. store_value ( @key, 't') # Persistent value
  232. msg ( 'Confirmation received! Try again' )
  233. <<<
  234.  
  235. /no = >>>
  236. msg ('Maybe next time.')
  237. <<<
  238.  
  239. # The user pays $cost to reset the mine $name
  240. # Designed to be attached to a Command Sign. Just do:
  241. # /cmds 1 /payMineReset CityMine_A 20000
  242. # then click the sign
  243. /payMineReset [$name='none'] [$cost='10000'] = >>>
  244.  
  245. if( equals($name,'none'), die ('You have not specified a mine.') )
  246.  
  247. # Confirmation system of /yes or /no
  248. assign(@key,concat('confirmation.',player() ) )
  249.  
  250. if ( equals (get_value(@key), 't') ,
  251. clear_value(@key)
  252. ,
  253. msg ( 'This will cost you $'.$cost.'. Are you sure you want to continue?' )
  254. msg ( 'Type /yes or /no to confirm' )
  255. die()
  256. )
  257.  
  258. #Retain the account balance
  259. assign(@bal,acc_balance(player() ) )
  260.  
  261. #### Logic and actions
  262. if(gte(@bal,$cost), # If they have enough money
  263. acc_subtract(player(),$cost) # take their money
  264. runas(~op,'/mrl reset '.$name.'') # Reset the mine
  265. , #Else
  266. die ('You did not have enough Gidrins to reset the mine '.$name.'.')
  267. )
  268. <<<
  269.  
  270. # The same idea as /payMineReset
  271. # /cmds 1 /payMineReset CityMine_A 30000
  272. # then click the sign
  273. /payClearMine [$name='none'] [$cost='50000'] = >>>
  274.  
  275. if( equals($name,'none'), die ('You have not specified a mine.') )
  276.  
  277. assign(@key,concat('confirmation.',player() ) )
  278.  
  279. if ( equals (get_value(@key), 't') ,
  280. clear_value(@key)
  281. ,
  282. msg ( 'This will cost you $'.$cost.'. Are you sure you want to continue?' )
  283. msg ( 'Type /yes or /no to confirm' )
  284. die() )
  285.  
  286. #Retain the accountt balance
  287. assign(@bal,acc_balance(player() ) )
  288.  
  289. #### Logic and actions
  290. if(gte(@bal,$cost),
  291. acc_subtract(player(),$cost)
  292. runas(~op,'/region select '.$name)
  293. runas(~op,'//set 0')
  294. , #Else
  295. die ('You did not have enough Gidrins to reset the mine '.$name.'.')
  296. )
  297. <<<
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement