Discuss Scratch
- TerryLeeStudio
-
Scratcher
100+ posts
Increment counter
Already in various programming languages as i
Working principe
1.when forever, repeat or repeat until block is started, it reset to 0
2.when the script inside them ends and the block loops, it increase by 1
3.you will only able to put this reporter to the block mentioned above and local to the block. Which means if you have 2 loops running, the counter won’t be messed up
Mock-up using scratchblocks
Working principe
1.when forever, repeat or repeat until block is started, it reset to 0
2.when the script inside them ends and the block loops, it increase by 1
3.you will only able to put this reporter to the block mentioned above and local to the block. Which means if you have 2 loops running, the counter won’t be messed up
Mock-up using scratchblocks
(loop increment :: control)or
(times looped :: control)There is a workaround by using a variable but just like the change block, it is common enough that it deserves it own reporter block
Last edited by TerryLeeStudio (April 7, 2023 12:02:14)
- TerryLeeStudio
-
Scratcher
100+ posts
Increment counter
Duplicate.That’s a manual counter, I want an integrated counter within loops that increase when it loops.
Like this example
define split (word) at blankThere is workaround of these blocks, but they are used frequent enough to add them in
repeat (1000)
if <(letter (loop increment :: control) of (word)) = [ ]> then
add (var) to [list v]
set [var v] to [0]
else
set [var v] to (join (var) (letter (loop increment :: control) of (word))
end
end
define split (word) at blank
set [loop increment replacement v] to [0]
repeat (1000)
if <(letter (loop increment replacement) of (word)) = [ ]> then
add (var) to [list v]
set [var v] to [0]
else
set [var v] to (join (var) (letter (loop increment replacement) of (word))
end
change [loop increment replacement v] by (1)
end
<[] = []>
Last edited by TerryLeeStudio (April 17, 2023 14:59:41)
- qwerty_wasd_gone
-
Scratcher
1000+ posts
Increment counter
Support, I don't like using variables as a workaround, this new block would save me time! 
But there might be a problem, what if you put a loop inside a loop? which loop would it detect?

But there might be a problem, what if you put a loop inside a loop? which loop would it detect?
when green flag clicked
repeat until <(x position) = [40]>
repeat (3)
move (loop increment::control) steps
end
end
Last edited by qwerty_wasd_gone (April 18, 2023 13:05:31)
- TerryLeeStudio
-
Scratcher
100+ posts
Increment counter
Support, I don't like using variables as a workaround, this new block would save me time!Great question, looking for various Python document, seems like inside is more intuitive
But there might be a problem, what if you put a loop inside a loop? which loop would it detect?when green flag clicked
repeat until <(x position) = [40]>
repeat (3)
move (loop increment::control) steps
end
end
- qwerty_wasd_gone
-
Scratcher
1000+ posts
Increment counter
what do you mean by inside?Support, I don't like using variables as a workaround, this new block would save me time!Great question, looking for various Python document, seems like inside is more intuitive
But there might be a problem, what if you put a loop inside a loop? which loop would it detect?when green flag clicked
repeat until <(x position) = [40]>
repeat (3)
move (loop increment::control) steps
end
end
- TerryLeeStudio
-
Scratcher
100+ posts
Increment counter
I mean it will move 0, 1, 2, 0, 1, 2 steps etc.what do you mean by inside?Support, I don't like using variables as a workaround, this new block would save me time!Great question, looking for various Python document, seems like inside is more intuitive
But there might be a problem, what if you put a loop inside a loop? which loop would it detect?when green flag clicked
repeat until <(x position) = [40]>
repeat (3)
move (loop increment::control) steps
end
end
- qwerty_wasd_gone
-
Scratcher
1000+ posts
Increment counter
okI mean it will move 0, 1, 2, 0, 1, 2 steps etc.what do you mean by inside?Support, I don't like using variables as a workaround, this new block would save me time!Great question, looking for various Python document, seems like inside is more intuitive
But there might be a problem, what if you put a loop inside a loop? which loop would it detect?when green flag clicked
repeat until <(x position) = [40]>
repeat (3)
move (loop increment::control) steps
end
end

- waitwhat2288
-
Scratcher
100+ posts
Increment counter
I cease to understand what's so difficult about implementing your own indexes, it's just setting the initial and how much it increments with two blocks of code and an index variable.
However, many other people and I use indexes extremely often, so it wouldn't necessarily be a waste of yet another “not used so often” reporter.
However, many other people and I use indexes extremely often, so it wouldn't necessarily be a waste of yet another “not used so often” reporter.
Last edited by waitwhat2288 (July 9, 2023 17:59:37)
- SonicFanX123_321
-
Scratcher
1000+ posts
Increment counter
like the 6502 asm right? then you can just make a variable.
inc Variable