nfell2009

TimeParser

Mar 5th, 2015
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.71 KB | None | 0 0
  1. #
  2. #   Time Parser (TimeParser.sk)
  3. #   By nfell2009
  4. #   All rights reserved
  5. #
  6.  
  7. #   Example:
  8. #   #   All variables are optional, however 1 must be put in otherwise you'll get nothing back
  9. #   #   The variables are the name of the actual variable. TimeParser will set the variables for you
  10. #   #                                       1           2       3                 [4]                [5]                   [6]                   [7]
  11. #   #                                  Input Type  Time input  Time Variable  [Days variable]    [Hours variable]    [Minutes variable]    [Seconds variable]
  12. #   execute console command "/timeparser QuickDate 1d1h1m1s nf.%player%.time nf.%player%.days nf.%player%.hours nf.%player%.minutes nf.%player%.seconds"
  13. #   message "%{nf.%player%.time}%"
  14.  
  15. #   Input type list:
  16. #       QuickDate - Simply converts 1d1h1m1s into 1 day 1 hour 1 minute 1 second
  17.  
  18. on script load:
  19.     set {tp::running} to true
  20.  
  21. on script unload:
  22.     set {tp::running} to false
  23.  
  24. command /timeparser [<text>] [<text>] [<text>] [<text>] [<text>] [<text>] [<text>]:
  25.     executable by: console
  26.     trigger:
  27.         if arg 1 is "QuickDate":
  28.             if arg 2 is set:
  29.                 set {_l} to length of arg 2
  30.                 set {_t} to arg 2
  31.                 delete {%arg 3%}
  32.                 delete {%arg 4%}
  33.                 delete {%arg 5%}
  34.                 delete {%arg 6%}
  35.                 delete {%arg 7%}
  36.                 if arg 4 is not set:
  37.                     set {_arg4} to "_arg4"
  38.                 else:
  39.                     set {_arg4} to arg 4
  40.                 if arg 5 is not set:
  41.                     set {_arg5} to "_arg5"
  42.                 else:
  43.                     set {_arg5} to arg 5
  44.  
  45.                 if arg 6 is not set:
  46.                     set {_arg6} to "_arg6"
  47.                 else:
  48.                     set {_arg6} to arg 6
  49.  
  50.                 if arg 7 is not set:
  51.                     set {_arg7} to "_arg7"
  52.                 else:
  53.                     set {_arg7} to arg 7
  54.                 set {_num} to 0
  55.                 set {_arg} to 3
  56.                 set {_%{_arg4}%.num} to 0
  57.                 set {_%{_arg5}%.num} to 0
  58.                 set {_%{_arg6}%.num} to 0
  59.                 set {_%{_arg7}%.num} to 0
  60.                 set {_num} to 0
  61.                 loop {_l} times:
  62.                     add 1 to {_num}
  63.                     set {_s} to subtext of {_t} from characters {_num} to {_num}
  64.                     if {_s} is "0", "1", "2", "3", "4", "5", "6", "7", "8" or "9":
  65.                         if {_numbers} is not set:
  66.                             set {_numbers} to {_s}
  67.                         else:
  68.                             set {_numbers} to "%{_numbers}%%{_s}%"
  69.                     else:
  70.                         if {_numbers} is set:
  71.                             if {_s} is "d":
  72.                                 set {_%{_arg4}%.num} to {_numbers} parsed as integer
  73.                                 delete {_numbers}
  74.                             else if {_s} is "h":
  75.                                 set {_%{_arg5}%.num} to {_numbers} parsed as integer
  76.                                 delete {_numbers}
  77.                             else if {_s} is "m":
  78.                                 set {_%{_arg6}%.num} to {_numbers} parsed as integer
  79.                                 delete {_numbers}
  80.                             else if {_s} is "s":
  81.                                 set {_%{_arg7}%.num} to {_numbers} parsed as integer
  82.                                 delete {_numbers}
  83.                 #   Uncomment this for pretty numbers
  84.                 #   May break your code. I'm not sure tbh
  85.                 #   If it breaks, don't report it as a bug
  86.                 #   because I won't fix it as I have warned you
  87.                 #   and because I'm lazy lul
  88.                 #if length of "%{_%{_arg4}%.num}%" is less than or equal to 1:
  89.                 #   set {_%{_arg4}%.num} to "0%{_%{_arg4}%.num}%"
  90.                 #else if length of "%{_%{_arg5}%.num}%" is less than or equal to 1:
  91.                 #   set {_%{_ar54}%.num} to "0%{_%{_arg5}%.num}%"
  92.                 #else if length of "%{_%{_arg6}%.num}%" is less than or equal to 1:
  93.                 #   set {_%{_arg6}%.num} to "0%{_%{_arg6}%.num}%"
  94.                 #else if length of "%{_%{_arg7}%.num}%" is less than or equal to 1:
  95.                 #   set {_%{_arg7}%.num} to "0%{_%{_arg7}%.num}%"
  96.                 set {%arg 3%} to "%{_%{_arg4}%.num}% days %{_%{_arg5}%.num}% hours %{_%{_arg6}%.num}% minutes %{_%{_arg7}%.num}% seconds"
  97.                 if arg 4 is set:
  98.                     set {%arg 4%} to {_%{_arg4}%.num} parsed as integer
  99.                 if arg 5 is set:
  100.                     set {%arg 5%} to {_%{_arg5}%.num} parsed as integer
  101.                 if arg 6 is set:
  102.                     set {%arg 6%} to {_%{_arg6}%.num} parsed as integer
  103.                 if arg 7 is set:
  104.                     set {%arg 7%} to {_%{_arg7}%.num} parsed as integer
Advertisement
Add Comment
Please, Sign In to add comment