I can't tell if I am being stupid, but I am looking for a way in Gamemaker to have a variable include a modifier which has the potential to change every step.

This variable is called mTiredness, and I would like it to include the TimeOfDayModifier which needs to be checked frequently.

However, I obviously can't put

mTiredness = mTiredness + TimeOfDayModifier

in a Step event, as this would add the modifier, in my case, 60 times a second, which I do not want!

Instead, I want a consistent variable comprised of the base amount and the modifier, while allowing that modifier to change.

Can anybody help me? I cannot think of an easy way to do this.


Make a script. It's a function actually, so you can make it return the sum you desire. That way you don't affect the mTiredness value. You will only need to have global access to those variables or either pass them as arguments/parameters.

  • \$\begingroup\$ Right, so I just use the return function in that script, and then place the script in a step event? I knew there was a simple way to do this, thanks! \$\endgroup\$ – Bonfire Dog Jul 4 '16 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.