Want to make a countdown timer that changes how the character interacts with the environment at certain intervals

Hi I'm very new to Quest, for the most part it's easy enough to use but I've just now begun to dabble a bit in code. I had this (late for halloween) way too ambitious idea of a story where your character is slowly transforming into a monster (werewolf or something I guess) while solving puzzles to find a cure.

The idea is that after a set amount of time the character's form will change a little bit (Think of it like status ailments almost like Transformed 0, Transformed 1, Transformed 2, Transformed 3, Game Over) and now all the previous interactions they had in the rooms will be replaced with new ones exclusive to your current form. The idea here being that it becomes harder and harder to do what you need to do the more you transform. Maybe you need to talk to an NPC to get a helpful item but your current status is "Transformed 2" which causes an interaction where the NPC flees in terror instead of helping you etc. There would need to be a timer for each status change interval I'd assume...am I making sense? I hope I am!

Now I realize that setting up something like this probably takes a lot of work and I don't expect people to just come in and hand me the code and fly away like Superman. I'm trying to learn how it all works and I really feel like this would be a fun game to make. I've looked at tutorials but they're all old and don't seem to correspond to version 5.8 (which I'm using) and I honestly just don't know where to start to get the exact result I'm looking for. Any help at all would be greatly appreciated, even if it's just a link to another thread or page that can help me with this particular thing.

Thanks for taking the time to read this!


Are you looking for something that changes with each action?
"Time" advances with every thing you do?
OR, something based on real time?
If you take a break for 5 minutes, you transform even if you are not at the keyboard...
The first one is easy, just add +1 to a transform counter at each action.
The second one need a real timer that will advance the counter.
Code for both are here on the site.
(But someone else that knows where they are, is probably already posting the answer.)


using 'Timers' is really messy... as trying to work with real-ticking time is very messy...

so, you might want to just use an Integer Attribute of/for an Object and increase/decrease it as/when desired/needed (via within Verbs for/of an Object, Turnscripts, and/or the special 'changed' Script Attribute of/for an Object)


A really useful math feature is the REMAINDER Value from Division

in programming, floating point (decimal/fractional) arithmetic is actually done via separating it into three/four main operations:

  1. calculating the whole values (left side of the decimal)
  2. calculating the decimal/fraction (REMAINDER) values (right side of the decimal)
  3. the placement of the decimal point itself
  4. putting #1-3 together for your final answer/value

so, usually programming already has a built-in function for getting the REMAINDER Value, which is known as 'modulus/modulo/mod' (whatever) and usually the operational sign/symbol used is the: %

modulus/modulo/mod operation: division, but getting/finding/returning just the REMAINDER Value

as the REMAINDER Value allows for two huge applications:

  1. cyclic/intervals
concept example:

00 % 5 = R0 -> 0
01 % 5 = R1 -> 1
02 % 5 = R2 -> 2
03 % 5 = R3 -> 3
04 % 5 = R4 -> 4
05 % 5 = R0 -> 0
06 % 5 = R1 -> 1
07 % 5 = R2 -> 2
08 % 5 = R3 -> 3
09 % 5 = R4 -> 4
10 % 5 = R0 -> 0
11 % 5 = R1 -> 1
12 % 5 = R2 -> 2
13 % 5 = R3 -> 3
14 % 5 = R4 -> 4
15 % 5 = R0 -> 0
16 % 5 = R1 -> 1
17 % 5 = R2 -> 2
18 % 5 = R3 -> 3
19 % 5 = R4 -> 4
20 % 5 = R0 -> 0

examples:

seconds_integer_variable = GetRandomInt (0,360)
minutes_integer_variable = GetRandomInt (0,360)
hours_integer_variable = GetRandomInt (0,360)

clock_seconds_integer_variable = seconds_integer_variable % 60
// clock_seconds_integer_variable = {0 to 59}

clock_minutes_integer_variable = minutes_integer_variable % 60
// clock_minutes_integer_variable = {0 to 59}

civilian_hours_integer_variable = hours_integer_variable % 12
// civilian_hours_integer_variable = {0 to 11}

military_hours_integer_variable = hours_integer_variable % 24
// military_hours_integer_variable = {0 to 23}
  1. divisible/factors (which also includes, whether a number/value is even or odd)
integer_variable = GetRandomInt (0,100)

// only showing/checking the prime numbers, to keep the coding simple

// concept/understanding coding of how it works:

if (integer_variable % 2 = 1) {
  msg (integer_variable + " is an odd number")
  msg (integer_variable + " is NOT divisible by 2")
  msg ("2 is NOT a factor of " + integer_variable)
} else if (integer_variable % 2 = 0) {
  msg (integer_variable + " is an even number")
  msg (integer_variable + " is divisible by 2")
  msg ("2 is a factor of " + integer_variable)
} else if (integer_variable % 3 = 0) {
  msg (integer_variable + " is divisible by 3")
  msg ("3 is a factor of " + integer_variable)
} else if (integer_variable % 5 = 0) {
  msg (integer_variable + " is divisible by 5")
  msg ("5 is a factor of " + integer_variable)
} else if (integer_variable % 7 = 0) {
  msg (integer_variable + " is divisible by 7")
  msg ("7 is a factor of " + integer_variable)
} else if (integer_variable % 11 = 0) {
  msg (integer_variable + " is divisible by 11")
  msg ("11 is a factor of " + integer_variable)
} else if (integer_variable % 13 = 0) {
  msg (integer_variable + " is divisible by 13")
  msg ("13 is a factor of " + integer_variable)
} else if (integer_variable % 17 = 0) {
  msg (integer_variable + " is divisible by 17")
  msg ("17 is a factor of " + integer_variable)
}  else if (integer_variable % 19 = 0) {
  msg (integer_variable + " is divisible by 19")
  msg ("19 is a factor of " + integer_variable)
} else if (integer_variable % 23 = 0) {
  msg (integer_variable + " is divisible by 23")
  msg ("23 is a factor of " + integer_variable)
} else if (integer_variable % 29 = 0) {
  msg (integer_variable + " is divisible by 29")
  msg ("29 is a factor of " + integer_variable)
} else if (integer_variable % 31 = 0) {
  msg (integer_variable + " is divisible by 31")
  msg ("31 is a factor of " + integer_variable)
}
// etc etc etc

if you want to see my really old and very convoluted but somewhat innovative way of doing it:

http://textadventures.co.uk/forum/samples/topic/4162/countdown-timer-code

(this was me before I knew about using the modulus/modulo/REMAINDER operation, lol)
(I was literally adjusting each digit of the time, via using 'if' Scripts, like a stop watch)


this was just some quick starting help, but code heavy (as I'm lazy), so feel free to ask away for help... for more direct and detailed and step by step help, and via doing so with the GUI/Editor (if coding still is confusing), though it takes much more time that way...


See... 4 minutes...


Log in to post a reply.

Support

Forums