knugi

Untitled

Sep 30th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. options:
  2. update: true
  3.  
  4. function KSHOP_getPath(t: text) :: string:
  5. if "%skquery version%" is "3.21.4":
  6. set {_path} to "../../kShop/"
  7. else:
  8. set {_path} to "plugins/kShop/"
  9. set {_path} to "%{_path}%%{_t}%.yml"
  10. return {_path}
  11.  
  12.  
  13.  
  14. function KSHOP_getRepairId(i: item) :: string:
  15. set {_id} to id of ("%{_i}%" parsed as item)
  16. set {_id} to "%{_id}%:%data of {_i}%"
  17. replace all ":0" with "" in {_id}
  18. return {_id}
  19.  
  20. function KSHOP_isBasic(i: item) :: boolean:
  21. set {_id} to KSHOP_getRepairId({_i})
  22. set {_items::*} to yaml list "basic" from KSHOP_getPath("basic")
  23. loop {_items::*}:
  24. if "%loop-value%" is "%{_id}%":
  25. return true
  26. return false
  27.  
  28. function KSHOP_getPriceBasic(i: item) :: number:
  29. set {_id} to KSHOP_getRepairId({_i})
  30. set {_ret} to yaml value "price.%{_id}%.%type of {_i}%" from KSHOP_getPath("prices")
  31. broadcast "price.%{_id}%.%type of {_i}%"
  32. set {_ret} to {_ret} parsed as number
  33. return {_ret}
  34.  
  35.  
  36.  
  37. #function
  38. function KSHOP_getPriceAdvanced(i: item) :: number:
  39. set {_id} to KSHOP_getRepairId({_i})
  40. set {_craft} to yaml value "advanced.%{_id}%.craft" from KSHOP_getPath("advanced")
  41. #broadcast "%{_i}% %id of {_i}% %{_craft}%"
  42. set {_ret} to 0
  43. loop length of {_craft} times:
  44. if subtext of {_craft} between index loop-number and loop-number is "{":
  45. set {_a} to loop-number
  46. if subtext of {_craft} between index loop-number and loop-number is "}":
  47. set {_moreId::%{_a}%} to loop-number
  48. loop {_moreId::*}:
  49. clear {_id}
  50. set {_id} to subtext of {_craft} between index loop-index parsed as integer + 1 and loop-value - 1
  51. set {_id} to {_id} parsed as item
  52. if KSHOP_isBasic({_id}) is true:
  53. add KSHOP_getPriceBasic({_id}) to {_ret}
  54.  
  55. broadcast "%{_id}%"
  56. return 0
  57.  
  58. function KSHOP_getPrice(i: item) :: number:
  59. if KSHOP_isBasic({_i}):
  60. return KSHOP_getPriceBasic({_i})
  61. return KSHOP_getPriceAdvanced({_i})
Advertisement
Add Comment
Please, Sign In to add comment