Bug free for this long

Yay, data latch bugs! :sweat_smile:

After inputting 2 in binary:

After turning off the store input:

THIS SHOULD STILL BE 0010! :smile:

Literally EVERY SINGLE SCRIPT from the binary latch to the NOR gate:

SR Latch (Set-Reset Latch)
NOR Gate
Please, for the love of god, tell me this isn't a simple fix, because I hate looking stupid (even though I am).

Are LATCH 1 and LATCH 2 global variables? Is there only one latch?

Yeah, there is only one latch. I suppose I should make more variables, shouldn't I?

The problem with having them be script variables is the fact that the blocks can't remember their state.

Ah. Look up "block variables" in the manual.

I'm confused, do you mean the "script variables" section, or is there actually a part called "block variables"?

Yes. At the back of the manual is an index; use it.

This is what I found:

Block variables lets you create a variant of script variables for this block: A script variable is created when a block is called, and it disappears when that call finishes. What if you want a variable that’s local to this block, as a script variable is, but doesn’t disappear between invocations? That’s a block variable. If the definition of a block includes a block variable, then every time that (custom) block is dragged from the palette into a script, the block variable is created. Every time that copy of the block is called, it uses the same block variable, which preserves its value between calls. Other copies of the block have their own block variables.

I understand all of this. My question is, how do I do this with my binary latch? It doesn't work if I use variables that aren't "this sprite only" variables.

You need to create your block variables by right clicking on the hat

and then click on arrow to create a block variable


Ohhhh, thank you. I'm kind of stupid then.

Not at all - it's a bit hidden away :slight_smile:

Okay, so you know how that should be working?

It's not.

I was just telling you how to create them - I've no idea if they are appropriate for your project or not

But Brian thought that they would be so they probably are :slight_smile:

Alright it's fixed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.