Script Logic Help

Hi all. A while ago I used this script Tchos provided me.

#include "ginc_param_const"

int CSLTimeStamp()
{
       int iYear = GetCalendarYear();
       int iMonth = GetCalendarMonth();
       int iDay = GetCalendarDay();
       int iHour = GetTimeHour();
       return (iYear)*12*28*24 + (iMonth-1)*28*24 + (iDay-1)*24 + iHour;
}

void main(string sTimerName, string sTarget)
{
    object oTarg = GetTarget(sTarget, TARGET_OBJECT_SELF);
	int iHour = CSLTimeStamp();
	SetLocalInt(oTarg, sTimerName, iHour);	
}

Well, I understand the logic of what the script does. But here’s what I want to do.

Node 1: NPC
PC answers, timer starts with the above script.

If 7 days have not gone by, the NPC will have nothing to say to the PC. After 7 days, he will talk Node 1 again. So basically I want a re-occuring dialogue every 7 days. Question is, would I be able to do this with one NPC node and PC responses?

So far I have the above script on the PC responses, and the below one on the NPC node with a NOT, where the NPC says sorry, not enough time has gone by.

///////////////////////////////////////////////////////////////////////////////////////////
//	
//	gc_timer_check
//	by Tchos, 2013-07
//	
//	Use this in a conversation to check how many hours have passed since you marked 
//	the beginning using ga_timer_begin.  You can use the same <, >, and ! comparison 
//	symbols in the sCheck field, as in the gc_local_int or gc_journal_entry scripts.
//	
///////////////////////////////////////////////////////////////////////////////////////////

#include "ginc_var_ops"
#include "ginc_param_const"

int CSLTimeStamp()
{
   int iYear = GetCalendarYear();
   int iMonth = GetCalendarMonth();
   int iDay = GetCalendarDay();
   int iHour = GetTimeHour();
   return (iYear)*12*28*24 + (iMonth-1)*28*24 + (iDay-1)*24 + iHour;
}

int StartingConditional(string sTimerName, string sCheck, string sTarget)
{
    object oTarg = GetTarget(sTarget, TARGET_OBJECT_SELF);
    
	int iStartHour = GetLocalInt(oTarg, sTimerName);
    int iCurrentHour = CSLTimeStamp();
	int iHoursPassed = iCurrentHour-iStartHour;
	
    int iRet = CompareInts(iHoursPassed, sCheck);
    return (iRet);
}

I hope the question makes sense :slight_smile: .

edit:

The simplified question would be, if 7 days have already gone by, how would one reset it to 0? Does it suffice to just use the first script above?

I would be inclined to say that it takes care of it already since it checks for hourspassed in the startingconditional, but that depends on what the sCheck parameter is.

Okay, some more info.

the action script I call as

ga_timer_start("timer_string", "",);

Therefore, the conversation owner has the timer.

the check happens as

gc_timer_check("timer_string", >167, "");

On the same convo, same owner.

yes it’s fine, already set for 7 days.

Alright, thanks. Then I don’t need a gazilion branches on the convo. 2 initial NPC lines out of which 1 says “Not enough time passed” and one where things happen suffice.