familychicken

shop

Jul 3rd, 2022 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. options:
  2. shopp: &7[&7&l・&r&7]
  3. c: ◈
  4.  
  5. variables:
  6. {mg::1} = iron nugget
  7. {mg::2} = iron ingot
  8. {mg::3} = iron block
  9. {mg::4} = bone block
  10.  
  11.  
  12. on join:
  13. set {%player%.maxbuy} to 1
  14.  
  15. function maxbuy_guicreate(p: player) :: item:
  16. set {_cl} to {%{_p}%.guic}
  17. set {_disp::*} to (coloured "&r&7[x1]"), (coloured "&r&7[x10]"), (coloured "&r&7[x100]"), and (coloured "&r&7[max]")
  18. set {_disp::1} to coloured "&a&n[x1]" if mod({_cl}, 4) is 0
  19. set {%{_p}%.maxbuy} to 1 if mod({_cl}, 4) is 0
  20. set {_disp::2} to coloured "&a&n[x10]" if mod({_cl}, 4) is 1
  21. set {%{_p}%.maxbuy} to 10 if mod({_cl}, 4) is 1
  22. set {_disp::3} to coloured "&a&n[x100]" if mod({_cl}, 4) is 2
  23. set {%{_p}%.maxbuy} to 100 if mod({_cl}, 4) is 2
  24. set {_disp::4} to coloured "&a&n[max]" if mod({_cl}, 4) is 3
  25. set {%{_p}%.maxbuy} to -1 if mod({_cl}, 4) is 3
  26. set {_answer} to iron block named "&7&n購入オプション" with lore "%{_disp::1}% %{_disp::2}% %{_disp::3}% %{_disp::4}%" with nbt "{loc:""buy""}"
  27. return {_answer}
  28.  
  29. on inventory click:
  30. if name of event-item is "&7&n購入オプション":
  31. cancel event
  32.  
  33. function maxbuy_multibuy(m: number, a: number, mbuy: number, startm: number, limit: number, max: number) :: numbers:
  34. if {_mbuy} is -1:
  35. set {_mbuy} to floor(log(({_max}*({_a}-1))/{_m}+{_a}^{_startm}, {_a}))-{_startm}
  36. if {_limit} is not -1:
  37. set {_mbuy} to {_limit}-{_startm} if {_limit} <= {_startm}+{_mbuy}
  38. set {_answer::1} to {_m}*(({_a}^({_mbuy}+{_startm})-{_a}^{_startm})/({_a}-1))
  39. set {_answer::2} to {_mbuy}
  40. return {_answer::*}
  41.  
  42. function maxbuy_shop(m: number, a: number, startm: number, limit: number, c: text, p: player, upgp: text):
  43. set {_mbuy} to {%{_p}%.maxbuy}
  44. set {_cost::*} to maxbuy_multibuy({_m}, {_a}, {_mbuy}, {%{_p}%::upgrade::%{_upgp}%}, {_limit}, {%{_p}%::%{_c}%})
  45. broadcast "%{_cost::*}%"
  46. if {%{_p}%::%{_c}%} >= {_cost::1}:
  47. remove {_cost::1} from {%{_p}%::%{_c}%}
  48. add {_cost::2} to {%{_p}%::upgrade::%{_upgp}%}
  49. message "&f{@c} &f購入に成功しました。&7(+%{_cost::2}%)" to {_p}
  50. else if {_mbuy} is not 0:
  51. message "&f{@c} &7購入に失敗しました。" to {_p}
  52. message "&f{@c} &7あと &f%nn({_cost::1}-{%{_p}%::%{_c}%}, {_p})% %{_c}% &7必要です。 &8(%100*{%{_p}%::%{_c}%}/{_cost::1}% %%)" to {_p}
  53. else:
  54. message "&f{@c} &7既に上限に達しています。"
  55.  
  56. command /numbered <number> <number> <number> <number> <number> <number>:
  57. trigger:
  58. set {_aa::*} to maxbuy_multibuy(arg-1, arg-2, arg-3, arg-4, arg-5, arg-6)
  59. broadcast "%{_aa::1}%"
  60.  
  61. command /aaaa:
  62. trigger:
  63. set {%player%::upgrade::test} to 0
  64.  
  65. command /buy:
  66. trigger:
  67. maxbuy_shop(2, 1.5, {%player%::upgrade::test}, 50, "xp", player, "test")
  68.  
  69. command /getxp <number>:
  70. trigger:
  71. set {%player%::xp} to arg-1
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
Add Comment
Please, Sign In to add comment