can't access game.attributes from pause

forkliftforklift Member Posts: 386
edited November -1 in Working with GS (Mac)
I am not able to access game.attributes from a pause screen. Can anyone else confirm this?

Example:
I am changing the size of an actor based on (integer) game.size. Game.size can be either a 1, 2, or 3.

I have a button on the pause screen with the following rules:
(all conditions) if actor touched and game.size = 1, change game.size to 2
(all conditions) if actor touched and game.size = 2, change game.size to 3
(all conditions) if actor touched and game.size = 3, change game.size to 1

This doesn't work. It doesn't actually change the number, even when it's a prototype.

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    Try simplifying it.

    If actor touched then gamesize = gamesize+1

    OR

    if touched
    Change gamesize to (gamsize+1)%3

    Hope that helps,

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • Rob2Rob2 Member Posts: 2,402
    did a quick test, seems to work ok, I displayed the game.size attribute and could see it counting up in the paused scene beneath (bit odd really as that scene should be paused!!)
  • forkliftforklift Member Posts: 386
    quantumsheep said:
    Try simplifying it.

    Change gamesize to (gamsize+1)%3

    Thanks, QS! That did the trick. Never knew about the % function! Had to do a forum search to see what values it produced... 0,1&2 on a %3.

    Works like a charm now.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Modulo is really handy :)
  • quantumsheepquantumsheep Member Posts: 8,188
    forklift said:
    Thanks, QS! That did the trick. Never knew about the % function! Had to do a forum search to see what values it produced... 0,1&2 on a %3.

    Works like a charm now.

    Very glad it worked out for you!

    It's a very handy function. You can even change that number at the end to a variable.

    For example:

    Let''s use two variables:

    Weapon type = 0
    Weapons unlocked = 0

    If you unlock a new weapon, it would change to:

    Weapon type = 0 (as you haven't changed the default weapon a character holds)
    Weapons unlocked = 1

    You could then, in-game, have the following:

    Change attribute weapon type to (weapon type+1)%Weapons unlocked

    This would then allow you to cycle through available weapons that had been unlocked.

    Hope that makes sense,

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • forkliftforklift Member Posts: 386
    Makes me wonder what other things I don't know about that make life easier.

    *edit*

    Awesome, QS. You rock! (and have earned a lifetime subscription of promo codes from me)
Sign In or Register to comment.