Zeldaboy111

Skript #202 - test

Jul 7th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1.  
  2. function numbersIn(s: String) :: number:
  3. set {_return} to ""
  4. loop {_s} split at "":
  5. set {_num} to loop-value parsed as a number
  6. if {_num} is set:
  7. "%{_num}%" = "%loop-value%"
  8. set {_return} to "%{_return}%%{_num}%"
  9.  
  10. return {_return} parsed as a number
  11.  
  12. function getDirectionalBlock(i: item, d: direction) :: item:
  13. set {_block::north} to 1
  14. set {_block::south} to 3
  15. set {_block::west} to 4
  16. set {_block::east} to 5
  17. return "%{_i}%:%{_block::%{_d}%}%" parsed as an item
  18.  
  19. function getOppositeDirection(direction: direction) :: direction:
  20. loop split "%{_direction}%" by "and":
  21. if {_dir} is not set:
  22. set {_dir} to numbersIn(loop-value)
  23. set {_final} to loop-value
  24.  
  25. else if numbersIn(loop-value) > {_dir}:
  26. set {_dir} to numbersIn(loop-value)
  27. set {_final} to loop-value
  28.  
  29. if {_final} contains "north":
  30. return north
  31. if {_final} contains "east":
  32. return east
  33. if {_final} contains "south":
  34. return south
  35. if {_final} contains "west":
  36. return west
  37.  
  38.  
  39.  
  40. command /test [<item>]:
  41. trigger:
  42. if arg 1 is set:
  43. set {_direction} to direction from targeted block to player
  44. set {_opposite} to getOppositeDirection({_direction})
  45. set {_block} to getDirectionalBlock(arg 1, {_opposite})
  46. set targeted block to {_block}
Add Comment
Please, Sign In to add comment