Skip to content

Use script glow status to track whether the project is running #3912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

adroitwhiz
Copy link
Contributor

@adroitwhiz adroitwhiz commented Mar 8, 2023

Resolves

Resolves #1948
Closes #2419

Proposed Changes

  • Refactor _emitProjectRunStatus to take a simple Boolean "project running/not running" argument
  • Count threads as "project running" only if they request a block glow
  • Allow flyout blocks to request a block glow

Reason for Changes

This fixes edge-activated hat blocks causing the project to always count as "running" and making the green flag appear active even if no scripts are running.

The system for tracking script glows is much more robust and accurate than the system that was previously used for determining if the project was running, so we should make use of that.

The rationale for each change is described in the corresponding commit message.

Test Coverage

Tested manually, and existing tests pass.

Here's what you should look for when testing this:

  • Regular event hat blocks (when key pressed, etc) should cause the green flag button to appear activated.
  • Edge-activated hat blocks (when loudness, etc) with no blocks attached should never cause the green flag button to appear activated.
  • Edge-activated hat blocks with blocks attached should cause the green flag button to appear activated when those attached blocks are running.
  • All of the above should hold true even if another sprite is selected.
  • Clicking a flyout block should cause the green flag button to appear activated. Blocks like "wait" and "glide" should make it appear activated for as long as the block is running.
  • Block monitors (aka variable readouts) should never cause the green flag button to appear activated.

Instead of calculating the number of monitor threads and subtracting it
from the total number of threads, just check whether any non-monitor
threads exist. We don't need to know how many there are, just whether
any exist. This lets us get rid of _getMonitorThreadCount and convert
the _nonMonitorThreadCount property to a boolean.
@adroitwhiz adroitwhiz force-pushed the edge-activated-flag branch from c589448 to d663ba2 Compare March 8, 2023 21:01
This means that:
- Monitor blocks don't count, because they don't affect block glow (the
monitor block container has forceNoGlow set)
- Edge-activated hats with no stacks attached don't count (the block to
glow is null)
- Edge-activated hats whose predicates are false don't count (they're
evaluated outside stepThreads so block glow isn't set to true)

Basically, anything which would cause blocks to glow will cause the
project to be considered "running".
For some reason, this wasn't getting respected anyway and flyout blocks
were glowing anyway. Now that we're using block glow to track project
run status, set forceNoGlow to false on the flyout blocks so that
clicking one still counts as making the project run, like it did before
the previous commit.
@adroitwhiz adroitwhiz force-pushed the edge-activated-flag branch from d663ba2 to 244b9d3 Compare March 8, 2023 21:26
@adroitwhiz
Copy link
Contributor Author

@Wowfunhappy See if this fixes the issue you found with #2419.

@Wowfunhappy
Copy link

@adroitwhiz It does, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Edge-triggered(?) hat blocks make the green flag always look active
2 participants