1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Parse as time period

Discussion in 'Skript' started by Weber, Mar 3, 2018.

Thread Status:
Not open for further replies.
  1. Weber

    Weber New Member

    Joined:
    Jan 31, 2018
    Messages:
    5
    Likes Received:
    0
    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 (Skript):
    1. command /duration <string>:
    2.     trigger:
    3.         set {_old} to now
    4.         wait 5 seconds
    5.         set {_time} to arg 1 parsed as time period
    6.         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 (Skript):
    1. command /durationfixed:
    2.     trigger:
    3.         set {_old} to now
    4.         wait 5 seconds
    5.         set {_time} to 3 seconds
    6.         message "%difference between {_time} and difference between {_old} and now%"
    Would greatly appreciate any help!

     
  2. Best Answer:
    Post #4 by TPGamesNL, Mar 3, 2018
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    232
    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?

    [​IMG]
     
  4. Mr_Simba

    Mr_Simba King of the Pridelands
    Supporter

    Joined:
    Dec 9, 2016
    Messages:
    256
    Likes Received:
    56
    Medals:
    Try parsing it as a 'timespan'.

    Also, what errors are you getting?
     
  5. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    108
    Medals:
    This works:
    Code (Skript):
    1. command /duration <int>:
    2.     trigger:
    3.         set {_old} to now
    4.         wait 5 seconds
    5.         set {_time} to "%arg-1% seconds" parsed as timespan
    6.         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 (Skript):
    1. command /duration <int>:
    2.     trigger:
    3.         set {_old} to 5 seconds
    4.         set {_time} to "%arg-1% seconds" parsed as timespan
    5.         message "%difference between {_time} and {_old}%"
     
Thread Status:
Not open for further replies.

Share This Page

Loading...