Zeldaboy111

Skript #228 - tycoon

Aug 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.75 KB | None | 0 0
  1.  
  2. options:
  3. prefix: &f[&2Tycoon&f] &8>>
  4. version: 1.0
  5.  
  6. command /tycoon [<text>] [<text>]:
  7. trigger:
  8. if player has permission "Tycoon.*":
  9. if arg 1 is "help":
  10. send "&f--------------[&2Tycoon&f]--------------"
  11. send "&a/Tycoon help &8>> &2Krijg de help pagina"
  12. send "&a/Tycoon shop create &8>> &2Maak een shop"
  13. send "&a/Tycoon shop &8>> &2Ga naar het shop gui"
  14. send "&a/Tycoon shop remove &8>> &2Verwijder de shop"
  15. send "&f--------------[&2Tycoon&f]--------------"
  16.  
  17. if arg 1 is "shop":
  18. if arg 2 is "create":
  19. send "{@prefix} &2Succesvol een shop item gegeven."
  20. give player a book named "&6Create Shop" with lore "&5Klik om een shop te maken - Tycoon"
  21. #send "{@prefix} &aSuccesvol de shop gemaakt!"
  22. #spawn Llama at player
  23. #set {_Llama} to last spawned Llama
  24. #set name of last spawned Llama to "&6Tycoon shop"
  25. #add "{Age:1,NoAI:1,Silent:1b,Invulnerable:1}" to nbt tag of {_Llama}
  26.  
  27.  
  28. else if arg 2 is set:
  29. send "{@prefix} &4Dit command is niet goed uitgevoerd, doe &c/tycoon stop create&4."
  30.  
  31.  
  32. else:
  33. send "{@prefix} &4Doe &c/tycoon help &4voor meer info."
  34.  
  35. else if arg 1 is "help":
  36. send "&f--------------[&2Tycoon&f]--------------"
  37. send "&a/Tycoon help &8>> &2Krijg de help pagina"
  38. send "&a/Tycoon shop &8>> &2Ga naar het shop gui"
  39. send "&f--------------[&2Tycoon&f]--------------"
  40.  
  41. else if arg 1 is "shop":
  42. send "{@prefix} &2Shop geoopent."
  43.  
  44. on rightclick on a villager:
  45. wait 1 tick
  46. set {_world} to world of clicked entity
  47. set {_locX} to x-coordinate of clicked entity
  48. set {_locY} to y-coordinate of clicked entity
  49. set {_locZ} to z-coordinate of clicked entity
  50.  
  51. open chest with 1 rows named "&6Tycoon Shop" to player
  52. make gui slot 0 of player with redstone dust named "&6Machine Shop" to close then run function openShop(player, "machines")
  53. make gui slot 8 of player with barrier named "&4Delete Shop" to run function removeShop(player, clicked entity, "%{_locX}%", "%{_locY}%", "%{_locZ}%", "%{_world}%")
  54.  
  55.  
  56.  
  57. on rightclick:
  58. if player is holding a book named "&6Create Shop" with lore "&5Klik om een shop te maken - Tycoon":
  59.  
  60. set {_locX} to x-coordinate of targeted block
  61. set {_locY} to y-coordinate of targeted block+0.5
  62. set {_locZ} to z-coordinate of targeted block
  63.  
  64. set {_block} to location of targeted block
  65.  
  66. loop blocks in radius 5 around player:
  67. if location of loop-block is {_block}:
  68.  
  69. send "{@prefix} &2Succesvol de shop gemaakt!"
  70. set {_gm} to gamemode of player
  71.  
  72. if gamemode of player is not creative:
  73. remove 1 of tool from tool
  74.  
  75. spawn villager at location {_locX}, {_locY}, {_locZ}
  76. set {_villager} to last spawned villager
  77. set name of last spawned villager to "&6Tycoon shop"
  78. add "{Profession:5,Age:1,NoAI:1,Silent:1b,Invulnerable:1}" to nbt tag of {_villager}
  79. add "%world of player% - %{_locX}%, %{_locY}%, %{_locZ}%" to {Tycoon::shopLocations::*}
  80.  
  81.  
  82. on death of villager:
  83. if attacker is a player:
  84. if name of villager is "&6Tycoon shop":
  85.  
  86. set {_locX} to x-coordinate of victim
  87. set {_locY} to y-coordinate of victim
  88. set {_locZ} to z-coordinate of victim
  89.  
  90. if {Tycoon::shopLocations::*} doesn't contain "%world of victim% - %{_locX}%, %{_locY}%, %{_locZ}%":
  91. stop
  92. else:
  93. remove "%world of victim% - %{_locX}%, %{_locY}%, %{_locZ}%" from {Tycoon::shopLocations::*}
  94. send "{@prefix} &2Succesvol de shop verwijderd!" to attacker
  95.  
  96. play "block_wood_hit" to attacker at volume 10
  97.  
  98. set {_item} to false
  99.  
  100. loop items in attacker's inventory:
  101. if loop-item is a book named "&6Create Shop" with lore "&5Klik om een shop te maken - Tycoon":
  102. set {_item} to true
  103. stop loop
  104.  
  105. else:
  106. set {_item} to false
  107.  
  108. if {_item} is false:
  109. give attacker a book named "&6Create Shop" with lore "&5Klik om een shop te maken - Tycoon"
  110.  
  111.  
  112. every 1 tick:
  113. loop all players:
  114.  
  115. if loop-player is holding a paper named "&6Dirt machine" with lore "&5Tycoon Machine":
  116. set {_block} to location of targeted block of loop-player
  117. loop blocks in radius 5 around loop-player:
  118. if location of loop-block is {_block}:
  119.  
  120.  
  121. set {_dir} to the facing of loop-player
  122. set {_world} to world of loop-player
  123. set {_x} to x-coordinate of targeted block of loop-player
  124. set {_y} to y-coordinate of targeted block of loop-player + 1
  125. set {_z} to z-coordinate of targeted block of loop-player
  126. set {_y2} to y-coordinate of targeted block of loop-player
  127.  
  128. set {tycoon::scematicDrawn::%loop-player%} to true
  129. if {tycoon::targetedBlock::%loop-player%} is "%{_x}%, %{_y2}%, %{_z}%, %{_world}%":
  130. stop loop
  131.  
  132. if {tycoon::targetedBlock::%loop-player%} is "%{_x}%, %{_y}%, %{_z}%, %{_world}%":
  133. stop loop
  134.  
  135. if {tycoon::scematic::%loop-player%} is "dirt_machine":
  136. removeScematic(loop-player, "dirt_machine", "%{tycoon::scematic::%loop-player%::x}%", "%{tycoon::scematic::%loop-player%::y}%", "%{tycoon::scematic::%loop-player%::z}%", {tycoon::scematic::%loop-player%::dir})
  137.  
  138. set {tycoon::targetedBlock::%loop-player%} to "%{_x}%, %{_y}%, %{_z}%, %{_world}%"
  139. set {tycoon::scematic::%loop-player%::x} to "%{_x}%"
  140. set {tycoon::scematic::%loop-player%::y} to "%{_y}%"
  141. set {tycoon::scematic::%loop-player%::z} to "%{_z}%"
  142. set {tycoon::scematic::%loop-player%::dir} to {_dir}
  143. set {tycoon::scematic::%loop-player%} to "dirt_machine"
  144.  
  145. drawScematic(loop-player, "dirt_machine", "%{_x}%", "%{_y}%", "%{_z}%", {_dir})
  146.  
  147. else:
  148. if {tycoon::targetedBlock::%loop-player%} is set:
  149. if {tycoon::scematic::%loop-player%} is "dirt_machine":
  150. removeScematic(loop-player, "dirt_machine", "%{tycoon::scematic::%loop-player%::x}%", "%{tycoon::scematic::%loop-player%::y}%", "%{tycoon::scematic::%loop-player%::z}%", {tycoon::scematic::%loop-player%::dir})
  151. delete {tycoon::scematic::%loop-player%}
  152. delete {tycoon::targetedBlock::%loop-player%}
  153.  
  154. function drawScematic(p: Player, t: String, x: String, y: String, z: String, direction: Direction):
  155. if {_t} is "dirt_machine":
  156. set {_world} to world of {_p}
  157. set {_opposite} to getOppositeDirection({_direction})
  158. #fill("%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", addNumber({_x} parsed as a number, {_y} parsed as a number, {_z} parsed as a number, {_world}, {_opposite}, 6.0), "%{_world}%", "scematic_dirt_machine", {_p})
  159. clear {scematic::block::%{_p}%::types::*}
  160. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "2", "0", "2", "-2", "0", "2")
  161. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "2", "0", "12", "-2", "0", "12")
  162. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "2", "0", "3", "2", "0", "11")
  163. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "-2", "0", "3", "-2", "0", "11")
  164.  
  165. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "2", "5", "2", "-2", "5", "2")
  166. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "2", "5", "12", "-2", "5", "12")
  167. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "2", "5", "3", "2", "5", "11")
  168. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "-2", "5", "3", "-2", "5", "11")
  169.  
  170. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "2", "1", "2", "2", "4", "2")
  171. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "-2", "1", "2", "-2", "4", "2")
  172. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "2", "1", "12", "2", "4", "12")
  173. fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", "-2", "1", "12", "-2", "4", "12")
  174.  
  175.  
  176.  
  177.  
  178. #fillDir({_p}, "scematic_dirt_machine", "%{_world}%", {_opposite}, "%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", 0, 0, 1, -2, 0, -2)
  179.  
  180.  
  181. function removeScematic(p: player, t: String, x: String, y: String, z: String, direction: Direction):
  182. if {_t} is "dirt_machine":
  183. set {_world} to world of {_p}
  184. set {_opposite} to getOppositeDirection({_direction})
  185. remove("%{_x} parsed as a number%", "%{_y} parsed as a number%", "%{_z} parsed as a number%", addNumber({_x} parsed as a number, {_y} parsed as a number, {_z} parsed as a number, {_world}, {_opposite}, 6.0), "%{_world}%", "scematic_dirt_machine", {_p})
  186.  
  187. #BEzig met alle scematics fixen
  188.  
  189.  
  190. #Directions etc.
  191.  
  192. #Make all strings!
  193. function fillDir(p: player, block: String, world: String, d: direction, x: String, y: String, z: String, xa: String, ya: String, za: String, xa2: String, ya2: String, za2: String):
  194. #clear {scematic::block::%{_p}%::types::*}
  195.  
  196. set {_x1} to {_x} parsed as a number
  197. set {_y1} to {_y} parsed as a number
  198. set {_z1} to {_z} parsed as a number
  199.  
  200. if {_d} is north OR south:
  201.  
  202. if firstChar({_za}) is "-":
  203. replace all "-" in {_za} with ""
  204. else:
  205. set {_za} to "-%{_za}%"
  206.  
  207. if firstChar({_xa}) is "-":
  208. replace all "-" in {_xa} with ""
  209.  
  210. else:
  211. set {_xa} to "-%{_xa}%"
  212.  
  213. if firstChar("%{_za2}%") is "-":
  214. send "&6%{_za2}%" to {_p}
  215. replace all "-" in {_za2} with ""
  216.  
  217. else:
  218. set {_za2} to "-%{_za2}%"
  219.  
  220.  
  221. if firstChar({_xa2}) is "-":
  222. replace all "-" in {_xa2} with ""
  223.  
  224. else:
  225. set {_xa2} to "-%{_xa2}%"
  226.  
  227. set {_loc1} to location addDir({_d}, {_xa}, {_x1}), addDir({_d}, {_ya}, {_y1}), addDir({_d}, {_za}, {_z1}) of world "%{_world}%"
  228. set {_loc2} to location addDir({_d}, {_xa2}, {_x1}), addDir({_d}, {_ya2}, {_y1}), addDir({_d}, {_za2}, {_z1}) of world "%{_world}%"
  229.  
  230. else:
  231. if firstChar({_za}) is "-":
  232. replace all "-" in {_za} with ""
  233. else:
  234. set {_za} to "-%{_za}%"
  235.  
  236. if firstChar({_xa}) is "-":
  237. replace all "-" in {_xa} with ""
  238. else:
  239. set {_xa} to "-%{_xa}%"
  240.  
  241. #set {_za} to {_za} parsed as a number
  242. #set {_xa} to {_xa} parsed as a number
  243.  
  244. if firstChar({_za2}) is "-":
  245. replace all "-" in {_za2} with ""
  246. else:
  247. set {_za2} to "-%{_za2}%"
  248.  
  249. if firstChar({_xa2}) is "-":
  250. replace all "-" in {_xa2} with ""
  251. else:
  252. set {_xa2} to "-%{_xa2}%"
  253.  
  254. set {_loc1} to location addDir({_d}, {_za}, {_x1}), addDir({_d}, {_ya}, {_y1}), addDir({_d}, {_xa}, {_z1}) of world "%{_world}%"
  255. set {_loc2} to location addDir({_d}, {_za2}, {_x1}), addDir({_d}, {_ya2}, {_y1}), addDir({_d}, {_xa2}, {_z1}) of world "%{_world}%"
  256.  
  257. loop blocks between block at {_loc1} and block at {_loc2}:
  258. add "%location of loop-block%$%loop-block%" to {scematic::block::%{_p}%::types::*}
  259.  
  260. if loop-block is air:
  261. set block at location of loop-block to green glass block
  262.  
  263. else:
  264. set block at location of loop-block to red glass block
  265.  
  266.  
  267. function addDir(final: direction, rem: string, n: number) :: number:
  268. if firstChar({_rem}) is "-":
  269. replace all "-" in {_rem} with ""
  270. set {_rem} to {_rem} parsed as a number
  271. if {_final} is north:
  272. remove {_rem} from {_n}
  273.  
  274. if {_final} is east:
  275. add {_rem} to {_n}
  276.  
  277. if {_final} is south:
  278. add {_rem} to {_n}
  279.  
  280. if {_final} is west:
  281. remove {_rem} from {_n}
  282.  
  283. else:
  284. set {_rem} to {_rem} parsed as a number
  285. if {_final} is north:
  286. add {_rem} to {_n}
  287.  
  288. if {_final} is east:
  289. remove {_rem} from {_n}
  290.  
  291. if {_final} is south:
  292. remove {_rem} from {_n}
  293.  
  294. if {_final} is west:
  295. add {_rem} to {_n}
  296.  
  297. return {_n}
  298.  
  299. function firstChar(s: String) :: String:
  300. add {_s} to {_s::*}
  301.  
  302. loop {_s::*}:
  303. set {_fc} to first character of loop-value
  304.  
  305. if {_fc} is "-":
  306. return {_fc}
  307.  
  308. else:
  309. return "<none>"
  310.  
  311. #send ({_fc} parsed as a string) to console
  312. set {_fc} to {_fc} parsed as a String
  313. return {_fc}
  314.  
  315.  
  316. function fill(x: String, y: String, z: String, loc2: location, world: String, block: String, p: player):
  317. set {_loc1} to location ({_x} parsed as a number), ({_y} parsed as a number), ({_z} parsed as a number) of world "%{_world}%"
  318. if {_block} is "scematic_dirt_machine":
  319. clear {scematic::block::%{_p}%::types::*}
  320. loop blocks between block at {_loc1} and block at {_loc2}:
  321. add "%location of loop-block%$%loop-block%" to {scematic::block::%{_p}%::types::*}
  322.  
  323. if loop-block is air:
  324. set block at location of loop-block to green glass block
  325.  
  326. else:
  327. set block at location of loop-block to red glass block
  328.  
  329.  
  330.  
  331. function getDirectionalBlock(i: item, d: direction) :: item:
  332. set {_block::north} to 1
  333. set {_block::south} to 3
  334. set {_block::west} to 4
  335. set {_block::east} to 5
  336. return "%{_i}%:%{_block::%{_d}%}%" parsed as an item
  337.  
  338.  
  339. function getOppositeDirection(direction: direction) :: direction:
  340. loop split "%{_direction}%" by "and":
  341. if {_dir} is not set:
  342. set {_dir} to numbersIn(loop-value)
  343. set {_final} to loop-value
  344.  
  345. else if numbersIn(loop-value) > {_dir}:
  346. set {_dir} to numbersIn(loop-value)
  347. set {_final} to loop-value
  348.  
  349. if {_final} contains "north":
  350. return north
  351. if {_final} contains "east":
  352. return east
  353. if {_final} contains "south":
  354. return south
  355. if {_final} contains "west":
  356. return west
  357.  
  358.  
  359. function getUpStairDirection(i: item, d: direction, j: number) :: item:
  360. set {_block::north} to 3
  361. set {_block::south} to 2
  362. set {_block::west} to 1
  363. set {_block::east} to 8
  364. set {_rblock} to {_block::%{_d}%}
  365.  
  366. return "%{_i}%:%{_block::%{_d}%}%" parsed as an item
  367.  
  368. function getDownStairDirection(i: item, d: direction, j: number) :: item:
  369. set {_block::north} to 7
  370. set {_block::south} to 6
  371. set {_block::west} to 5
  372. set {_block::east} to 4
  373. set {_rblock} to {_block::%{_d}%}
  374.  
  375. return "%{_i}%:%{_block::%{_d}%}%" parsed as an item
  376.  
  377.  
  378.  
  379.  
  380. function getOppositeDirection(direction: direction) :: direction:
  381. loop split "%{_direction}%" by "and":
  382. if {_dir} is not set:
  383. set {_dir} to numbersIn(loop-value)
  384. set {_final} to loop-value
  385.  
  386. else if numbersIn(loop-value) > {_dir}:
  387. set {_dir} to numbersIn(loop-value)
  388. set {_final} to loop-value
  389.  
  390. if {_final} contains "north":
  391. return north
  392. if {_final} contains "east":
  393. return east
  394. if {_final} contains "south":
  395. return south
  396. if {_final} contains "west":
  397. return west
  398.  
  399.  
  400.  
  401. function numbersIn(s: String) :: number:
  402. set {_return} to ""
  403. loop {_s} split at "":
  404. set {_num} to loop-value parsed as a number
  405. if {_num} is set:
  406. "%{_num}%" = "%loop-value%"
  407. set {_return} to "%{_return}%%{_num}%"
  408.  
  409. return {_return} parsed as a number
  410.  
  411. function addNumber(x: number, y: number, z: number, w: world, dir: direction, num: number) :: location:
  412. if {_dir} is north:
  413. remove {_num} from {_z}
  414.  
  415. if {_dir} is east:
  416. add {_num} to {_x}
  417.  
  418. if {_dir} is south:
  419. add {_num} to {_z}
  420.  
  421. if {_dir} is west:
  422. remove {_num} from {_x}
  423.  
  424. set {_return} to location {_x}, {_y}, {_z} of world "%{_w}%"
  425. return {_return}
  426.  
  427. function remove(x: String, y: String, z: String, loc2: location, world: String, block: String, p: player):
  428. set {_loc1} to location ({_x} parsed as a number), ({_y} parsed as a number), ({_z} parsed as a number) of world "%{_world}%"
  429. if {_block} is "scematic_dirt_machine":
  430. loop {scematic::block::%{_p}%::types::*}:
  431. set {_list} to loop-value
  432. set {_list::*} to {_list} split at "$"
  433.  
  434. set {_loc} to {_list::1}
  435. set {_type} to {_list::2}
  436. set {_loc::*} to {_loc} split at ","
  437.  
  438. set {_x} to {_loc::1}
  439. set {_y} to {_loc::2}
  440. set {_z} to {_loc::3}
  441. replace "x: " in {_x} with ""
  442. replace " y: " in {_y} with ""
  443. replace " z: " in {_z} with ""
  444.  
  445. set block at location at ({_x} parsed as a number), ({_y} parsed as a number), ({_z} parsed as a number) in world "%{_world}%" to ({_type} parsed as an item)
  446.  
  447.  
  448.  
  449. function removeShop(p: Player, e: Entity, x: String, y: String, z: String, w: String):
  450. if {Tycoon::shopLocations::*} doesn't contain "%{_w}% - %{_x}%, %{_y}%, %{_z}%":
  451. send "Cancelled" to {_p}
  452. stop
  453.  
  454. else:
  455. loop all villagers in radius 6 around {_p}:
  456. if "%location of loop-entity%" is "x: %{_x}%, y: %{_y}%, z: %{_z}%":
  457. set health of loop-entity to 0
  458. play "block_wood_hit" to {_p} at volume 10
  459. close {_p}'s inventory
  460.  
  461. remove "%{_w}% - %{_x}%, %{_y}%, %{_z}%" from {Tycoon::shopLocations::*}
  462.  
  463.  
  464. function getItem(p: Player, i: string):
  465. if {_i} contains "_machine":
  466. replace "_machine" with " Machine" in {_i}
  467.  
  468.  
  469. add {_i} to {_i::*}
  470. loop {_i::*}:
  471. set {_i1} to first character of loop-value
  472. set {_i2} to last (length of loop-value - 1) characters of loop-value
  473. set {_i} to "%{_i1} to upper case%%{_i2} to lower case%"
  474.  
  475. set {_item} to paper named "&6%{_i}%" with lore "&5Tycoon Machine"
  476. send "{@prefix} &a%{_i}% &2gekocht!" to {_p}
  477. give {_p} {_item}
  478.  
  479.  
  480. function openShop(p: Player, page: String):
  481. if {_page} is "machines":
  482. open chest with 3 rows named "&6Shop - Machines" to {_p}
  483. make gui slot 22 of {_p} with a barrier named "&4Sluit menu" to close
  484. make gui slot 0 of {_p} with dirt named "&6Dirt Machine" to close then run function getItem({_p}, "dirt_machine")
Add Comment
Please, Sign In to add comment