Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # Time Parser (TimeParser.sk)
- # By nfell2009
- # All rights reserved
- #
- # Example:
- # # All variables are optional, however 1 must be put in otherwise you'll get nothing back
- # # The variables are the name of the actual variable. TimeParser will set the variables for you
- # # 1 2 3 [4] [5] [6] [7]
- # # Input Type Time input Time Variable [Days variable] [Hours variable] [Minutes variable] [Seconds variable]
- # execute console command "/timeparser QuickDate 1d1h1m1s nf.%player%.time nf.%player%.days nf.%player%.hours nf.%player%.minutes nf.%player%.seconds"
- # message "%{nf.%player%.time}%"
- # Input type list:
- # QuickDate - Simply converts 1d1h1m1s into 1 day 1 hour 1 minute 1 second
- on script load:
- set {tp::running} to true
- on script unload:
- set {tp::running} to false
- command /timeparser [<text>] [<text>] [<text>] [<text>] [<text>] [<text>] [<text>]:
- executable by: console
- trigger:
- if arg 1 is "QuickDate":
- if arg 2 is set:
- set {_l} to length of arg 2
- set {_t} to arg 2
- delete {%arg 3%}
- delete {%arg 4%}
- delete {%arg 5%}
- delete {%arg 6%}
- delete {%arg 7%}
- if arg 4 is not set:
- set {_arg4} to "_arg4"
- else:
- set {_arg4} to arg 4
- if arg 5 is not set:
- set {_arg5} to "_arg5"
- else:
- set {_arg5} to arg 5
- if arg 6 is not set:
- set {_arg6} to "_arg6"
- else:
- set {_arg6} to arg 6
- if arg 7 is not set:
- set {_arg7} to "_arg7"
- else:
- set {_arg7} to arg 7
- set {_num} to 0
- set {_arg} to 3
- set {_%{_arg4}%.num} to 0
- set {_%{_arg5}%.num} to 0
- set {_%{_arg6}%.num} to 0
- set {_%{_arg7}%.num} to 0
- set {_num} to 0
- loop {_l} times:
- add 1 to {_num}
- set {_s} to subtext of {_t} from characters {_num} to {_num}
- if {_s} is "0", "1", "2", "3", "4", "5", "6", "7", "8" or "9":
- if {_numbers} is not set:
- set {_numbers} to {_s}
- else:
- set {_numbers} to "%{_numbers}%%{_s}%"
- else:
- if {_numbers} is set:
- if {_s} is "d":
- set {_%{_arg4}%.num} to {_numbers} parsed as integer
- delete {_numbers}
- else if {_s} is "h":
- set {_%{_arg5}%.num} to {_numbers} parsed as integer
- delete {_numbers}
- else if {_s} is "m":
- set {_%{_arg6}%.num} to {_numbers} parsed as integer
- delete {_numbers}
- else if {_s} is "s":
- set {_%{_arg7}%.num} to {_numbers} parsed as integer
- delete {_numbers}
- # Uncomment this for pretty numbers
- # May break your code. I'm not sure tbh
- # If it breaks, don't report it as a bug
- # because I won't fix it as I have warned you
- # and because I'm lazy lul
- #if length of "%{_%{_arg4}%.num}%" is less than or equal to 1:
- # set {_%{_arg4}%.num} to "0%{_%{_arg4}%.num}%"
- #else if length of "%{_%{_arg5}%.num}%" is less than or equal to 1:
- # set {_%{_ar54}%.num} to "0%{_%{_arg5}%.num}%"
- #else if length of "%{_%{_arg6}%.num}%" is less than or equal to 1:
- # set {_%{_arg6}%.num} to "0%{_%{_arg6}%.num}%"
- #else if length of "%{_%{_arg7}%.num}%" is less than or equal to 1:
- # set {_%{_arg7}%.num} to "0%{_%{_arg7}%.num}%"
- set {%arg 3%} to "%{_%{_arg4}%.num}% days %{_%{_arg5}%.num}% hours %{_%{_arg6}%.num}% minutes %{_%{_arg7}%.num}% seconds"
- if arg 4 is set:
- set {%arg 4%} to {_%{_arg4}%.num} parsed as integer
- if arg 5 is set:
- set {%arg 5%} to {_%{_arg5}%.num} parsed as integer
- if arg 6 is set:
- set {%arg 6%} to {_%{_arg6}%.num} parsed as integer
- if arg 7 is set:
- set {%arg 7%} to {_%{_arg7}%.num} parsed as integer
Advertisement
Add Comment
Please, Sign In to add comment