How do you code when tapped?



So I want it for a game, I kniw there's a block, but how do you code it? I'd do

When character is pressed
Check once if (value) length = 0
Set length to 1
(code you want)

But when do you set length to 1 again?, so it works infinite tmes, it's for a game, but I can't use when tapped!?
EDIT:who put tags here?


I'll tag if I think you can answer well!
All for now, pweaty pwease, I have to quit my collab if I don't get an answer


It seems to me like some part of your question is missing here. I know that you know how to use "when__ is tapped." So, what's missing?

Are you wanting something to repeat infinitely, after a character has been tapped? If so, then you could simply put a "repeat forever" block inside.


I mean when __ is tapped, a synonym for it in a way, like doing the same thing, but NOT using that block, using values and when is pressed!, understand?


This post was flagged by the community and is temporarily hidden.


OK, so, for the purposes of this project, you want to use "when __ is pressed" but not "when __ is tapped". This is starting to sound like a familiar problem. Not sure. Could it be that you also care about when the press is released as well? And do you know what the sequence of events is that you want to see happen, during and after the pressing? The problem that I'm having is that I can't narrow-down what you're trying to do very well. It could still be a lot of things, and the answer kind of depends on which.


No, I can't use the when tapped block @all!


This post was flagged by the community and is temporarily hidden.


Well, basically the tapped was just an example, I need to find out when length first = 1, as in if you do it as in
When length = 1 it'll keep on repeating
When length = 1
Check once if q (value) = 0
Set q to 1

When do you set q to 0 so it repeats whenever the value is first set to q, like when you change it to 3 then 0 again the moment length reaches 0 the code plays again
Explained enough?
Took a while


i still can't understand what you are trying to do.
i've never used the length value.
wish you best of luck


Sorry. Electrical outage here left me with no connection for a couple of hours. Alarms are still going off. Not sure what's up with that.

You have vaguely described "life meter" or a "fuel meter" or a "somethings-left meter" that is meant to cause a block of code to restart, once the meter variable gets back to zero. Right? It's like you are trying to create a "do while" or "do until" loop. If that's the case, i often use a flag variable like an alarm to let different pieces of the code talk to each other. You can even have several places in the code where the flag can get "set" and use the state of the flag as your signal to either keep doing the repeatable action or to restart ot. If you do things that way, of course you want your restart code to clear that flag, first thing.

I think this is the key to your question, but it's still worded kinda tricky:

To start with, I can only guess that this is a question. There's no question mark. :slight_smile: Second, the role of "q" is still kind of jello for me. At the beginning, you're talking about it as a variable, which makes perfect sense. In another part of the same sentence, though, ("value is first set to q"), you are speaking of "q" as if it's a specific numerical value. And, by the way, "the value" of what is "first set to q"? Even if I were to make an example of a "do while" or a "do until" loop, I can't be sure that it would do what you have in mind. I would be glad to try, but there's just not enough context.

Yes, I know, it can be a pain trying to explain things to people who can't see your code and who don't even know what the game is. :grimacing: Don't sweat it.


That's exactly it!, it was so the background woukd only load once, but when the other background loads the background is cleared, so I create a value and then when that value is that, then the background reloads, wwnt me to take screenshots?


I think I understand your need here, something like this:

value(q) = 0;
when OBJECT is tapped {
If value(q) equals 0 then
Set value(q) to 1;
Do some action;
Reset value(q) to 0

Yeah it's a mishmash of syntax there. Hope it's not confusing, trying to distinguish what is variable and what is function etc. you are looking for a condition like a switch to get reset or turned back off once the function has been performed? Like

Lights are off
When I enter the house
Turn lights on
Find my slippers then
Turn the lights off

Then I would be sat in a dark house but with warm feet. Oh well not a great analogy. Anyhow, could you not just put the value block at the end of your function to reset it to 0 ?


You can't do:
When q = 1
When tapped
1. I'm NOT allowed to use when tapped
2. How do you do a when tapped as a second rule anyway?


It would repeat heaps of times, only repeat once, plus if you don't reset it, it onky does it once, only the first moment it's supposed to do the code
Thanksfor your help tho :slightly_smiling:


I don't really understand what you mean. There is a when _ is tapped when!


I mean doing a synonym for it, do something the same, but not using the when