Orange Time System

Discussion in 'JS Plugin Releases (RMMV)' started by Hudell, Oct 24, 2015.

  1. Kane Hart

    Kane Hart Elmlor.com Veteran

    Messages:
    656
    Likes Received:
    166
    Location:
    Barrie, Ontario, Canada
    First Language:
    English
    Not sure if there is a easy way to do this.


    But I have an even for example:


    disable switch 14 in 168 hours


    Is there a way to call that via a NPC? It be nice if she said you have 7 days left or 6 days 21 hours etc. Or even 160 hours left.


    Not sure how I can calculate or display that info. Might be a bit more complex wonder if someone can walk me through it :)
     
  2. lordnitemare

    lordnitemare Villager Member

    Messages:
    5
    Likes Received:
    0


    Ok. Well, I shall fiddle a bit with the time and lighting system then. If I get to a roadblock, I shall tell you. I am not a programmer by any stretch of the imagination, and code is simply beyond me. I can do simple script calls, and I am lucky that all the plugins I have are either literally plug and play, or have detailed videos (Yami and Hime) to explain their features. And you have some nice explanations on the first page, so hopefully I shall be able to tweak it. I probably will be able to get the time system and the actual day/night system working, but the 'eternal night' with the main character being the only light source will probably be the hard one...
     
  3. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,323
    Likes Received:
    2,961
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    I didn't really test it, but this should work.


    First, add this as a new plugin:


    var TimeSystemExtensions = {};

    (function($){
    $.registerCommand = function(variableId, switchId, hours) {
    var time = OrangeTimeSystem.getDateTime();
    time.hour += hours;
    OrangeTimeSystem.validateDateTimeValues(time);

    var timestamp = OrangeTimeSystem.convertConfigToTimestamp(time);

    time.callback = 'S' + switchId + ',FALSE';
    OrangeTimeSystem.registerAfterTimeEvent(time);

    $gameVariables.setValue(variableId, timestamp);
    };

    $.getTimeLeft = function(variableId) {
    var currentTimestamp = OrangeTimeSystem.convertConfigToTimestamp(OrangeTimeSystem.getDateTime());

    return timestamp - currentTimestamp;
    };

    $.splitTimeDifference = function(variableId, daysVariable, hoursVariable, minutesVariable, secondsVariable) {
    var timestamp = $.getTimeLeft(variableId);
    var data = OrangeTimeSystem.convertTimestampToConfig(timestamp);

    if (daysVariable > 0) {
    $gameVariables.setValue(daysVariable, data.day);
    }
    if (hoursVariable > 0) {
    $gameVariables.setValue(hoursVariable, data.hour);
    }
    if (minutesVariable > 0) {
    $gameVariables.setValue(minutesVariable, data.minute);
    }
    if (secondsVariable > 0) {
    $gameVariables.setValue(secondsVariable, data.seconds);
    }

    return timestamp;
    };
    })(TimeSystemExtensions);


    Then, instead of using the plugin command "disable switch 14 in 168 hours", use the following script call:


    TimeSystemExtensions.registerCommand(VARIABLE_ID, 14, 168);


    Changing VARIABLE_ID by the number of a variable where you want to store the data required by this.


    Then, when you want to check the time left, use this:


    TimeSystemExtensions.splitTimeDifference(VARIABLE_ID, DAYS_VARIABLE, HOURS_VARIABLE, MINUTES_VARIABLE, SECONDS_VARIABLE);


    Replacing VARIABLE_ID by the same variable number you used earlier. Then replace DAYS_VARIABLE for the number of the variable where you want to store how many days are left, HOURS_VARIABLE by the number of the variable where you want to store the number of hours left, and so on.


    Then you can include those variables in a text message or do anything else with them.



    Sure. I'm not sure if I understood everything correctly, but if you hit any roadblock you can ask here and I'll try to help.
     
  4. Nanaya

    Nanaya Veteran Veteran

    Messages:
    76
    Likes Received:
    18
    Location:
    Belgium
    First Language:
    French
    Primarily Uses:
    RMMV
    Really nice plugin, thanks !
     
  5. Soulnet

    Soulnet Veteran Veteran

    Messages:
    198
    Likes Received:
    97
    First Language:
    English
    This plugin is great!


    I'm trying to set the clock to be 6am on certain events but also want the calendar to progress.


    E.g. if the game time was 21:00 31st December 2000.


    If I use the change hour to 06:00, the game changes it to that time but the date remains the same (i.e. time travel backwards!) where it should be ideally, 0:600 1st January 2001.


    Is there a way to set it to 06:00 the next day?
     
    Last edited by a moderator: Jun 23, 2016
  6. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,323
    Likes Received:
    2,961
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV


    There's two ways:


    OrangeTimeSystem.hour = 6;
    OrangeTimeSystem.day = OrangeTimeSystem.day + 1;
    OrangeTimeSystem.updateTime(false);


    or


    OrangeTimeSystem.setTime(OrangeTimeSystem.seconds, OrangeTimeSystem.minute, 6, OrangeTimeSystem.day + 1);


    Both will automatically change the month / year if needed.
     
    Soulnet likes this.
  7. Windies

    Windies Earth Bound Veteran

    Messages:
    33
    Likes Received:
    33
    Location:
    Australia
    First Language:
    English
    Noob question


    how do you get it displaying Am and PM , only troubles i'm having at the moment.
     
  8. Hatake-hime

    Hatake-hime Squishy Cat Summoner Veteran

    Messages:
    48
    Likes Received:
    16
    Location:
    Scotland
    First Language:
    English
    Can someone help me with using this?


    Basically I have installed HUD, date, time & night and day cycles.


    I can't get any to work.


    I have the HUD above everything, and it shows up as a box which is good.


    I've adjusted the size and location, but I can't get anything in the box.


    I know I sound real dense but I have no idea why this is happening.


    I set variables for days, years,months, hours, etc., and everything, I can't even get the time to start.


    Is there a script or prompt I need to use to get the time to start or the date to show up on the HUD?


    Sorry I'm a newbie at plugins.


    Thanks for any help.

    44.png
     
  9. Soulnet

    Soulnet Veteran Veteran

    Messages:
    198
    Likes Received:
    97
    First Language:
    English
    I'm new at this too but I found the same issue occurred if you didn't fill in the OrangeTimeSystemVariables. Not just the ones you will use but every one needed a variable to get started.


    Hope that helps cause that did the trick for me.
     
  10. Hatake-hime

    Hatake-hime Squishy Cat Summoner Veteran

    Messages:
    48
    Likes Received:
    16
    Location:
    Scotland
    First Language:
    English
    I'm gonna have a try at that.


    i don't think I filled them all as I wasn't sure what to put in it.


    i also can't download the demo to have a look because my broswer downloads it wrong, so frustrating! Here is hoping.
     
  11. Hatake-hime

    Hatake-hime Squishy Cat Summoner Veteran

    Messages:
    48
    Likes Received:
    16
    Location:
    Scotland
    First Language:
    English
    Okay, I got the year to show up!


    Now I'm wondering how to get the time to start/show. I turned on the switch for time to start and erased it, but nothing seems to be happening on the HUD.


    Can I only have one thing showing on the HUD at once? Does this mean I should have the HUD_line one too to show both time and date?
     
  12. Soulnet

    Soulnet Veteran Veteran

    Messages:
    198
    Likes Received:
    97
    First Language:
    English
    Make sure the values (id) you added for the OrangeTimeSystemVariables matches the id required in the fields.
     
  13. Hatake-hime

    Hatake-hime Squishy Cat Summoner Veteran

    Messages:
    48
    Likes Received:
    16
    Location:
    Scotland
    First Language:
    English
    Ahh! Sorry! I literally just fixed it and was typing out my reply !


    Both fields are working now! I'm just curious, can I adjust it so it shows the time as 00:00 instead of 0:0 ? o:


    If not, sorry to bother you! You might not know, but thanks so so much for helping me!
     
    Last edited by a moderator: Jun 25, 2016
  14. Soulnet

    Soulnet Veteran Veteran

    Messages:
    198
    Likes Received:
    97
    First Language:
    English
    If it's a single digit like 3, try 03 instead.
     
  15. Hatake-hime

    Hatake-hime Squishy Cat Summoner Veteran

    Messages:
    48
    Likes Received:
    16
    Location:
    Scotland
    First Language:
    English
    Sorry, just edited my comment, I figured out the date but the time is the double digit I'd like. Gonna have a look around!


    Like I said, thanks! I appreciate it :D
     
  16. Soulnet

    Soulnet Veteran Veteran

    Messages:
    198
    Likes Received:
    97
    First Language:
    English
    Welcome to help if I can ... which isn't often as i'm also new!
     
  17. Hatake-hime

    Hatake-hime Squishy Cat Summoner Veteran

    Messages:
    48
    Likes Received:
    16
    Location:
    Scotland
    First Language:
    English
    No problem! I'm so glad I got the basics to work.


    Now I just have to figure out how to get the actual time to show two digits instead of one haha. I'll check through the actual code to see!

    44.png
     
  18. Hudell

    Hudell Dog Lord Veteran

    Messages:
    3,323
    Likes Received:
    2,961
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMMV
    you can use the OrangeHudClock instead of the OrangeHudLine.


    I'll check what's wrong with the demo
     
  19. Hatake-hime

    Hatake-hime Squishy Cat Summoner Veteran

    Messages:
    48
    Likes Received:
    16
    Location:
    Scotland
    First Language:
    English
    Hudell, Im not sure theres anything wrong with the demo, it may be the problem with my browser, I've googled it before, not sure though.


    Also, I have a question:


    I used


    OrangeTimeSystem.hour = 6;


    I have a common event that happens at 6am - the event refreshes the switches (turns off limitations so they can be used that next day).


    However if you sleep past it with the 'addhours' script it skips the common event.


    By using the code above, it seems to go to 6am but on the same day (like going back in time) it doesnt register the next day.


    Does that make sense?


    I would like it so that by clicking the bed, it skips to 6am (or even 5:59 to play the event) the next day, no matter what time is now.


    Do you know how I can do this?
     
    Last edited by a moderator: Jun 28, 2016
  20. Soulnet

    Soulnet Veteran Veteran

    Messages:
    198
    Likes Received:
    97
    First Language:
    English
    I think common event and variables are what you want. There is a script to set the time to variables. So the event would be when time = greater than variable(hour), reset my event.
     

Share This Page