Solved Parse as time period

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Weber

New Member
Jan 31, 2018
5
0
0
24
Is this not supported? I seem to be completely unable to store a duration in a variable unless I state that duration explicitly in the skript;
code_language.skript:
command /duration <string>:
    trigger:
        set {_old} to now
        wait 5 seconds
        set {_time} to arg 1 parsed as time period
        message "%difference between {_time} and difference between {_old} and now%"
Try this with 3 seconds as your first argument; It should return "2 seconds"
I've also attempted to parse it as duration and timeperiod
It seems that it's unsupported, but I figured I'd check here to see if it's simply me not knowing about a syntax or something.

For reference, the following skript does work as expected, which confirms that variables can definitely store durations:

code_language.skript:
command /durationfixed:
    trigger:
        set {_old} to now
        wait 5 seconds
        set {_time} to 3 seconds
        message "%difference between {_time} and difference between {_old} and now%"

Would greatly appreciate any help!
 
Hey, I MAY be wrong, but i don't think you can use <string> in this case
What are you typing after /duration when you run the command?
What is the error you are getting?

uiVssPH.png
 
Try parsing it as a 'timespan'.

Also, what errors are you getting?
 
This works:
code_language.skript:
command /duration <int>:
    trigger:
        set {_old} to now
        wait 5 seconds
        set {_time} to "%arg-1% seconds" parsed as timespan
        message "%difference between {_time} and difference between {_old} and now%"
but you have to wait 5 seconds for it, and if you don't want that you can just use this easier script:
code_language.skript:
command /duration <int>:
    trigger:
        set {_old} to 5 seconds
        set {_time} to "%arg-1% seconds" parsed as timespan
        message "%difference between {_time} and {_old}%"
 
Status
Not open for further replies.