Snapblocks

:information_source: Summary Allow users to use snapblocks in their posts.
:hammer_and_wrench: Repository Link GitHub - snap-blocks/snapblocks-discourse: snapblocks discourse plugin
:open_book: Install Guide How to install plugins in Discourse

Features

Snapblocks is a fork of scratchblocks that allows users to convert text into images of Snap! scripts. This Discourse plugin allows users to use snapblocks in their posts.

You can create snapblocks in a post, by typing snapblocks code inside [snapblocks][/snapblocks] bbcode tags. For example:

[snapblocks]
move (10) steps
[/snapblocks]

You can alternatively use [scratchblocks][/scratchblocks] as an alias, though it can be disabled.

You can also use [sb][/sb] to add snapblocks code inline.

Use the [sb]move (10) steps[/sb] block to move forward.

Options

There are a few settings available to change how snapblocks are rendered.

  • Block Style
  • Block Scale
  • Zebra Coloring
  • Block Wrap
  • Show Spaces
  • Santa Hats

Many options can also be used in snapblocks snippets.

[snapblocks blockStyle="snap-flat" wrap="true" wrapSize=100 zebra="true" showSpaces="false" santa="true"]
when flag clicked
if <[] = []> {
  forever {
    run ({} @addInput) with inputs [Hello world] @delInput @verticalEllipsis @addInput
  }
}
[/snapblocks]

You can also set the block style using the default parameter.

[snapblocks="snap-flat"]
move (10) steps
[/snapblocks]

Configuration

Name Description
Block Style The default block style. Can be snap, snap-flat, scratch2, scratch3, or scratch3-hc.
Block Scale The default block image scale. Must be a float.
Zebra Coloring If multiple blocks are the same color, alternate a lighter color.
Block Wrap Wrap block parts onto a new line if the block gets too wide.
Show Spaces Show spaces as a dot in inputs.
Scratchblock Alias Enable the [scratchblocks] alias.

CHANGELOG

  • 1.4.1
    • Fix multiline code snippet quoting
    • Actually detect block translations
  • 1.4.0
    • Make quoting snapblocks better
    • Text in blocks cannot be selected (though you can still select over them and quote the whole script).
  • 1.3.0
    • Add “Santa Hats” option to settings
    • Add santa option to snapblocks snippets
    • Updated snapblocks to 1.8.0
  • 1.2.0
    • Allow the [scratchblocks] alias to be toggled (I finally figured out how to do it).
    • Update snapblocks to 1.7.0
  • 1.1.1
    • Make sure overflowing scripts can be scrollable.
    • Added actual text when using the snapblocks button in the toolbar.
  • 1.1.0
    • Updated snapblocks to 1.6.0
  • 1.0.0
    • Initial release

TODO

  • Allow separate default style for [scratchblocks]
12 Likes

Are there any incompatibilities with scratchblocks that would suggest the need for a separate plugin for Scratch?

If not, it could be noted here and in the plugin’s README on GitHub.

1 Like

I’d say that the only incompatibilities are mainly just some minor syntax tweaks, like dropdown menus and the define block. For the most part, scratchblocks code is mostly compatible with snapblocks.

I do still think there should be a separate plugin for scratchblocks, since I know forums that are for scratch/scratch mods might not want to use snapblocks, since snapblocks is geared to work best for snap (and I have been lacking on the scratch styles polish), not to mention, I didn’t add the ability to switch the toolbar shortcut to use scratchblocks instead.

If anyone would like to try and create a scratchblocks plugin using this plugin as a base (I’m probably not going to get around to making one myself), I think it’s worth noting that the render function I used is not in the scratchblocks api, so it would take a bit more work than just dropping in scratchblocks.

1 Like

It appears, at first glance, that there is no objection to utilizing this plugin for initial experiments (my environment being a school setting) and only then investing time into a Scratch plugin should the necessity arise.

1 Like

Feature request: The block-style could be defined separately for the [scratchblocks] alias.
This would allow effortless usage of different styled Scratch and Snap! elements.

2 Likes

That’s actually a good idea. I’ll look into adding that.

3 Likes