5E Product Walkthrough Playlist
  1. #1

    [Programming] Help with Calendar Rigging

    edit: nevermind, I figured it out.

    Code:
                                            function onInit()
    						DB.addHandler("calendar.current.minute", "onUpdate", onSourceChanged);
    						onCheckTime();
    						onSourceChanged();
    					end
    					
    					function onCheckTime()
    						nOld = DB.getValue("calendar.current.minute");
    					end
    					
    					function onAddIt()
    						if nIsNewHour > 0 then 
    							nDifference = nFull - nOld;
    						end
    						if nIsNewHour == 0 then
    							nDifference = nNew - nOld;
    						end
    					end
    					
    						
    					function onClose()
    						DB.removeHandler("calendar.current.minute", "onUpdate", onSourceChanged);
    					end
    					nIsNewHour = 0;
    					function onSourceChanged()
    						setValue(string.format("%02d", DB.getValue("calendar.current.minute", 0)));
    						nNew = DB.getValue("calendar.current.minute");
    						
    						if nNew == 0 then
    							nIsNewHour = 60;
    							
    						end
    						nFull = nNew + nIsNewHour;
    						onAddIt();
    						
    						if nDifference > 4 and nDifference < 58 then
    							window.stressroll.onUpdate();
    							onCheckTime();
    							nIsNewHour = 0;
    						end
    						
    						if nDifference < 0 or nDifference > 58 then
    							onCheckTime();
    							nIsNewHour = 0;
    						end
    						
    					end
    					
    					
    					function onWheel(n)
    						if not Input.isControlPressed() then
    							return false;
    						end
    						CalendarManager.adjustMinutes(n);
    						return true;
    					end



    ---------------------------------------------------------------------------------------------------------

    Hey guys! So i've almost got something rigged up on my Alien RPG ruleset so that stress will reduce by 1 every 5 minutes. It's working almost perfectly. My issue comes from when I scroll down (decrease) the minutes to, and below 0 (effectively going back an hour).

    example, stress is reduced every 5 minutes. my time is 4:03, i mousewheel the time backwards, and when i hit both 4:00, and 3:59, stress is reduced on all the characters by 1 each time.

    this effect must come from my workaround to get the time to recognize when a new hour has passed, so that when i start at 4:58, and end at 5:03, stress is reduced on all the characters by 1.

    This is the script i have placed into the "currentminutes" part of my charactersheet on charsheet_main2.xml

    Code:
                                            function onInit()
    						DB.addHandler("calendar.current.minute", "onUpdate", onSourceChanged);
    						onCheckTime();
    						onSourceChanged();
    					end
    					
    					function onCheckTime()
    						nOld = DB.getValue("calendar.current.minute");
    					end
    					
    					function onAddIt()
    						if nIsNewHour > 0 then 
    							nDifference = nFull - nOld;
    						end
    						if nIsNewHour == 0 then
    							nDifference = nNew - nOld;
    						end
    					end
    					
    						
    					function onClose()
    						DB.removeHandler("calendar.current.minute", "onUpdate", onSourceChanged);
    					end
    					nIsNewHour = 0;
    					function onSourceChanged()
    						setValue(string.format("%02d", DB.getValue("calendar.current.minute", 0)));
    						nNew = DB.getValue("calendar.current.minute");
    						
    						if nNew == 0 then
    							nIsNewHour = 60;
    							
    						end
    						nFull = nNew + nIsNewHour;
    						onAddIt();
    						
    						if nDifference > 4 then
    							window.stressroll.onUpdate();
    							onCheckTime();
    							nIsNewHour = 0;
    						end
    						
    						if nDifference < 0 then
    							onCheckTime();
    							nIsNewHour = 0;
    						end
    						
    					end
    					
    					
    					function onWheel(n)
    						if not Input.isControlPressed() then
    							return false;
    						end
    						CalendarManager.adjustMinutes(n);
    						return true;
    					end
    Last edited by pr6i6e6st; August 31st, 2019 at 07:00.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Starfinder Playlist

Log in

Log in