Attribute increasing twice?

NoRReyNoRRey Member, PRO Posts: 9

I don't think the context is that relevant, but I have an image of my code. Every time this "After x seconds" happens, instead of increasing by 1 like it's intended to, game.tableposition increases by two, and I believe it's causing issues. Nowhere else in my code is that attribute coded to change, other than when pressing enter, which SETS it to two, so I know that part isn't the problem.

Comments

  • ArmellineArmelline Member, PRO Posts: 5,482
    edited May 16

    Nothing in that screenshot shows an obvious problem (though I'd move the Destroy down to the bottom to be safe). So next investigation steps would be:

    1. Does game.playing change while this is run?
    2. Is only one of these actors definitely on the scene at any time? I'd test this by first adding a Change Attribute (self attribute) to "random(1,1000)" somewhere above and outside of this timer, then adding a Log Debugging Statement directly above the Change attribute behaviour with the new self attribute as the expression. If one number shows up in the debugger, there's only one actor. If multiple different numbers show up, multiple actors are triggering their own Change attribute behaviours. If multiple of the same number shows up, something crazy is going on with your whole timer/rule.
    3. What's in the Left/Mid/Right rules?
    4. What rules does Ballspawner have?
  • NoRReyNoRRey Member, PRO Posts: 9
    edited May 17
    1. That variable only changes once, after which it starts the loop of deleting and respawning
    2. There is definitely only one actor
    3. The Left/Right/Mid simply compare another attribute to know where to spawn the ball, and that attribute is affected by game.tableposition, using it as a reference (but not changing it)
    4. There is only one other rule that changes the previous variables once, starts playing a sound, and deletes-remakes itself to start the makeshift loop.

    I only did this weird way of looping because timers don't work in loops, and loop(every) can't change it's set time.

    Edit: I tried having it log rightb after changing game.tableposition, and it logs every number from 3 (the first one it changes to) to 7 (which it shouldn't end on)

  • ArmellineArmelline Member, PRO Posts: 5,482

    Would definitely need to see the full project to troubleshoot further then.

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,340

    Never underestimate the power of using the Log Debugging Statement behavior. Put one right after your increase action! It's super helpful in tracking this kind of thing down.

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,340

    As @Armelline said, we'd need to see more, but my guess is that game.playing is being set unexpectedly. If it's a bug in our engine then it's being set to true twice and that's triggering (it shouldn't).

    If it's a bug in your code then somewhere you may be setting game.playing = false and game.playing = true quickly.

    Another possibility is that your table expression for the counter is dependent on a value that changes, causing the timer to re-evaluate unexpectedly (semantically I don't think it should, but I haven't looked at the Timer code in a while).

  • NoRReyNoRRey Member, PRO Posts: 9

    I actually figured out the solution, it was because of the ordering of things, so I put the timer in the rule instead of vice versa, and some other smal tweaks. Also, why is the Head Chief and Key Master commenting on my post wow. Also if that's your status why is your account newer than @Armelline's (who's account is older THAN ME, BY THE WAY)

  • ArmellineArmelline Member, PRO Posts: 5,482

    I just happened to sign up pretty much the day GameSalad launched :D @adent42 is the guy in charge!

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,340

    I was a founder of the company but wasn't active in the forums until a bit later (apparently after @Armelline joined). It could also be a fluke of account creation. As an admin I had to create an account on this forum software before everyone and then import everyone's accounts. So my date might be the day we switched forums, not my real account creation date (I'm too lazy to look).

Sign In or Register to comment.