This is my code
function repeatedly_execute_always() {
if (gPause.Visible) return;
if (IsTimerExpired(1)) {
vDXM += 1;
Display("You start feeling the DXM");
}
// advance game clock
time_loop++;
if (time_loop == 40) { // advance game minutes
time_loop = 0;
time_min++;
if (time_min == 60) { // advance game hours
time_min = 0;
time_hour++;
if (vDXM > 0) {
vDXM -= 1;
}
if (time_hour == 24) { // advance game days
time_hour = 0;
time_day++;
}
}
}
lblDXM.Text = String.Format("DXM: %d", vDXM); // GUI that displays vDXM value
==================================and==================================
function iRobo_Talk()
{
if (player.InventoryQuantity[iRobo.ID] == 0) { // Discards the bottle if none is left
Display ("An empty bottle of cough syrup");
player.LoseInventory (iRobo);
UpdateInventory();
}
else {
if (vDXM == 0) { // Drinks an ounce if you have it, starts timer
Display ("You swig an ounce, and though its horrid taste does not deter you from its abuse, the resultant nausea- stymied from consuming surplus ammounts of saccharin-laden syrup within a brief time- makes you reluctant to take another.");
player.InventoryQuantity[iRobo.ID] -= 1;
SetTimer(1, 200); // 1200
}
if (vDXM > 0) { // If you are already feelin it, drinks another ounce and makes you higher/ removes an ounce
vDXM += 1;
Display ("You swig another ounce.");
player.InventoryQuantity[iRobo.ID] -= 1;
}
}
}
The problem is that when the timer (which simulates drug onset time) is started by the drinking of an ounce of cough syrup, and subsequent ounces are drank before said timer expires, the vDXM global variable value is only 1 after the timer expires (as if only 1 ounce was drank), though the inventory quantity depletes. How would one go about changing it so that even if multiple ounces are drank at once the effects (vDXM += 1) are not felt until after the timer expires?
I am not at home atm, so I cannot read your post thoroughly, but if I understand your problem correctly, you may try to add another varible (say, vDS) as a temporal buffer to keep track of how many ounces of syrup are drunk before the timer ends.
function repeatedly_execute_always() {
if (gPause.Visible) return;
if (IsTimerExpired(1)) {
vDXM = vDS; vDS = 0;
Display("You start feeling the DXM");
}
// advance game clock
time_loop++;
if (time_loop == 40) { // advance game minutes
time_loop = 0;
time_min++;
if (time_min == 60) { // advance game hours
time_min = 0;
time_hour++;
if (vDXM > 0) {
vDXM -= 1;
}
if (time_hour == 24) { // advance game days
time_hour = 0;
time_day++;
}
}
}
lblDXM.Text = String.Format("DXM: %d", vDXM); // GUI that displays vDXM value
function iRobo_Talk()
{
if (player.InventoryQuantity[iRobo.ID] == 0) { // Discards the bottle if none is left
Display ("An empty bottle of cough syrup");
player.LoseInventory (iRobo);
UpdateInventory();
}
else {
if (vDXM == 0) { // Drinks an ounce if you have it, starts timer
if (vDS == 0) {
Display ("You swig an ounce, and though its horrid taste does not deter you from its abuse, the resultant nausea- stymied from consuming surplus ammounts of saccharin-laden syrup within a brief time- makes you reluctant to take another.");
player.InventoryQuantity[iRobo.ID] -= 1;
vDS = 1;
SetTimer(1, 200); // 1200
} else {
Display("You swing another ounce of the syrup.");
vDS ++;
}
}
if (vDXM > 0) { // If you are already feelin it, drinks another ounce and makes you higher/ removes an ounce
vDXM += 1;
Display ("You swig another ounce.");
player.InventoryQuantity[iRobo.ID] -= 1;
}
}
}
It's a hard time for me to type this with my phone, so I'll leave this unexplained. Hopefully you can understand it. Also, obviously this is untested and I could make many typos.
that worked perfectly thanks again for your help