How do I use the new Date plugin

0 favourites
  • 11 posts
From the Asset Store
Create your game with this complete pack of images and animations!
  • Hi!

    I want to show in an object Text the actual month using the new Date plug-in of beta R201 but when I take the expression, show me that error. I tried deleting TimeStamp but tell me Sintax error.

    Sorry but i´m beginner

    Tagged:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I haven't used the new beta, but are you sure this function is meant to get an argument?

    From the look of it, these functions are all mapped from regular JavaScript:

    developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth

    Unfortunately Dates in Javascript are pretty complex and bizarre. There are a lot of different ways of achieving the same thing and the API has a fair bit of legacy.

    Maybe you can experiment with the regular JavaScript API in the Chrome console (or browser equivalent) and then try and apply those learnings to C3's API.

    And I'd recommend double checking that it really takes an argument, as I mentioned at the start.

  • Yes, I think it's more for people who are experts in Construct 3, I still have a long way to go :D

    I'll wait for Scirra to do a tutorial. Thanks a lot!

  • In your screenshot "TimeStamp" is an auto-complete and indicates what value you should put between the parenthesis.

    Since you want the actual month, according to the actual time/date, you can make use of the expression .now within the Date plugin.

    + System: On start of layout

    -> Text: Set text to Date.GetUTCMonth(Date.Now)

    Will display "5" in your text object.

    As indicated, the month is returned from 0 to 11 (0 is January, 1 is February, etc...).

    If you want to display the month in "letters"/as word, you likely need to set up an array that contains your months and display it accordingly.

    See this example c3p made in r201

  • Was this feature removed in r203? I'm getting an "Object not found" error.

  • No, the changelog makes no note of that nature.

    Are you sure you added the plugin to the project ?

  • Are you sure you added the plugin to the project ?

    I didn't ... duh. For some reason I thought it'd be accessible from the default system functions. Thank you muchly!

  • In your screenshot "TimeStamp" is an auto-complete and indicates what value you should put between the parenthesis.

    Since you want the actual month, according to the actual time/date, you can make use of the expression .now within the Date plugin.

    + System: On start of layout

    -> Text: Set text to Date.GetUTCMonth(Date.Now)

    Will display "5" in your text object.

    As indicated, the month is returned from 0 to 11 (0 is January, 1 is February, etc...).

    If you want to display the month in "letters"/as word, you likely need to set up an array that contains your months and display it accordingly.

    See this example c3p made in r201

    Oh, thanks a lot!!! That's exactly what I was looking for.

  • In your screenshot "TimeStamp" is an auto-complete and indicates what value you should put between the parenthesis.

    Since you want the actual month, according to the actual time/date, you can make use of the expression .now within the Date plugin.

    + System: On start of layout

    -> Text: Set text to Date.GetUTCMonth(Date.Now)

    Will display "5" in your text object.

    As indicated, the month is returned from 0 to 11 (0 is January, 1 is February, etc...).

    If you want to display the month in "letters"/as word, you likely need to set up an array that contains your months and display it accordingly.

    See this example c3p made in r201

    This should be in documentation somehow, its pretty useful and straight forward. I had to come here after visiting the docs.

  • The documentation indicates every elements I've talked about.

    This is the general way of using the editor and expressions.

    Also a new intermediate example has been added to the C3 start page that specifically deals with time & date : editor.construct.net

  • In your screenshot "TimeStamp" is an auto-complete and indicates what value you should put between the parenthesis.

    Since you want the actual month, according to the actual time/date, you can make use of the expression .now within the Date plugin.

    + System: On start of layout

    -> Text: Set text to Date.GetUTCMonth(Date.Now)

    Will display "5" in your text object.

    As indicated, the month is returned from 0 to 11 (0 is January, 1 is February, etc...).

    If you want to display the month in "letters"/as word, you likely need to set up an array that contains your months and display it accordingly.

    See this example c3p made in r201

    This^^

    Thank you for your reply! I have been wondering the same thing.

    It wasn't exactly apparent what one is supposed to write for the parameters in the documentation.... "date.Now" was the solution :)

    To check dates/time I set a variable for month, and one for day.

    Set variable "playersMonth" to date.getMonth(Date.Now)

    Set variable "PlayerDay" to date.GetDay(Date.Now)

    Then I compare those variables to whatever I need.

    Trigger Once

    If "playerMonth" > 3 (for example)

    and

    If "playerDay" > 15 (for example)

    Flawed code I know, but it helped me tease apart the timestamp dilemma. My project only needed to check the date once to determine certain settings at the beginning of the game.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)