Hey guys,
I´ve installed a cronometer at my projetc. After a time I discovered it had a bug... now and again I would get negative seconds for result.. I thought about it a littel and figured out that it was because seconds marker at the clock restarts every full circle ( 60 seconds). So, If my first marker was 02:45 and my second one was 4:15 I would get 02: -30 for result ( 4 minutes - 2 minutes = 2 minutes; 15 seconds - 45 seconds= -30 seconds).
The solution I got for this problem was to put a "If" condition that says "if seconds are less than or equal to -1, add 60 to seconds and subtract 1 from minutes". The thing is, it seems that my condition simply isnt been triggered, I still get the same problems... any one here can help me out? Bellow goes that part of my code (it compiles ok), I will not post the whole script because it is 650 lines long.
int nMinV1LA1 = GetLocalInt(oPC, "nMinutes_V1LA1") - GetLocalInt(oPC, "initial_minute");int nSecV1LA1 = GetLocalInt(oPC, "nSeconds_V1LA1") - GetLocalInt(oPC, "initial_second"); //Correct the problem that occurs when seconds at SecV1LA1 are less than at "initial_second" if (GetLocalInt(oPC, "nSecV1LA1") < 0) { nSecV1LA1 += 60;
nMinV1LA1 -= 1;
}
help! "If condition don't run"
Débuté par
el.sombrero
, sept. 24 2012 08:51
#1
Posté 24 septembre 2012 - 08:51
#2
Posté 24 septembre 2012 - 09:26
It sounds like the local int's on the PC won't ever be less than zero. Try using nSecV1LA1 directly,
if (nSecV1LA1 < 0)
{
nSecV1LA1 += 60;
nMinV1LA1 -= 1;
}
#3
Posté 24 septembre 2012 - 10:45
Wouldn't it be easier to do all the calculations in seconds, then convert to minutes:seconds when necessary?
#4
Posté 25 septembre 2012 - 05:47
The problem is I'm using the neverwinternights 2 clock, and it only gives me time in numbers and seconds... I would first have to convert all to seconds, then calculate, then convert again... to much trouble
#5
Posté 25 septembre 2012 - 06:03
Hey KevL,
It solved my problem... but I dont understand the difference between the previous condition and the one you proposed... can you explain it to me, so I dont do the same mistake again?
thx!
It solved my problem... but I dont understand the difference between the previous condition and the one you proposed... can you explain it to me, so I dont do the same mistake again?
thx!
#6
Posté 25 septembre 2012 - 06:45
well in your first version:
it's trying to get a local_int from the PC-object that ( i guess ) doesn't actually exist. Rather, the local_int on the PC is, as stated:
So i'm thinking you got confused between the local_int on the PC and the variable_int ( nSecV1LA1 ) that flows through the code, in the script itself
ie. you don't have to 'get' nSecV1LA1 since it's being calculated on-the-fly,
if (GetLocalInt(oPC, "nSecV1LA1") < 0)
it's trying to get a local_int from the PC-object that ( i guess ) doesn't actually exist. Rather, the local_int on the PC is, as stated:
GetLocalInt(oPC, "nSeconds_V1LA1")
So i'm thinking you got confused between the local_int on the PC and the variable_int ( nSecV1LA1 ) that flows through the code, in the script itself
ie. you don't have to 'get' nSecV1LA1 since it's being calculated on-the-fly,
#7
Posté 25 septembre 2012 - 06:48
thx again man!
#8
Posté 25 septembre 2012 - 06:59
np





Retour en haut






