How do I determine why I can'tchange the value of a variable

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi

    I had a variable with interaction, and the interactions themselves worked well. When the player hits the clock, they either clock in, or clock out. But I added some life bar and text box stuff, and now I can't figure out why I can only "clock in" and the "clock out" part stopped working.

    My question is more how do I trouble shoot - You guys are great, but I don't expect you to program my entire game! So I feel bad asking at every stage. I don't really want to have to come onto the forum with every question (maybe someday I will once I can also help answer questions).

    I tried moving the order of events around, but it didn't help.I tried making the text box background various things like invisible (the green square, I think that's what's causing the problem). The most frustrating part is that it was *totally fine* before. The problem is on ebreakroom , under the "clock in events" group - capx attached

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So, to help you trouble shoot the issue, what you need to know is, the events are always processed in order. You have 2 events that define if the player is clocking in or out. Because the clock out event and clock in event do not in any way declare that you cannot immediately change clock state right after it just changed, you are getting a cascade effect. The first event sets the clocked in value to one, then the second sees the value as 1 and sets it to 0. When ever you implement a toggle system like this, you need to be mindful of these cascading results that will throw off your result.

    As always, there are many different ways to solve this issue. You could utilize a state called "Clocking In". You could incorporate an if/else structure into your events. You could require a time limit for the user to be clocked in before clocking out. You could require at least 1 layout change before clocking out. Any one of these suggestions could give you the result you want. You would just need to decide what works best for you.

    I am attaching a modified version of your project showing how I would fix this issue. I would suggest you try to solve it yourself given the above information before you take a look at my change. Doing so would help you in your future trouble shooting.

  • Thank you for answering me! I'm a total noob so I get frustrated and rage quit pretty easily. I've been trying to fix it on my own for an embarrassing amount of time (like two weeks). I needed the vocabulary words "cascade" and "if/else".

    Ah, I understood order matters, but I don't understand...why the order of events worked until I added the text background? I wasn't getting a cascade effect before that happened and the events were in the same order. Def helps to know that's what that effect is called! I've run into it before and fixed it by arranging stuff, but now I have options.

    I know you must reply to these questions in kind a lot because you say as always. Sorry, this went way over my head. It would be really nice to require a time limit or layout change, but I have no idea how to do that. It's...very difficult for me to navigate the tutorials on the site because the terms I want to use are in so many posts. Super-noob here. If we were driving cars I'd have a big "STUDENT DRIVER" painted on the side.

    I've never actually used if/else, that will help for <b> LOTS </b> of things. So far I've just been creating two events, one for each condition, and it's very repetitive, and sometimes I have to make 5 or 6 for each "else" condition (if player hits door but does not have hairnet, flash the no entry message, if player hits door but does not have clean hands, flash the no entry message, etc). This thing really actually helped me a lot once I read your post and searched for "if/else" - ... t-features . Actually I feel pretty stupid for not setting events up this way earlier (Praise your chosen overlord for if else statements, I guess). Thank you again; you have no idea how valuable your time is to me and how much this helped.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)