Skip to content

Broadcast-only messages are not added to the stage broadcasts table #351

@aspizu

Description

@aspizu

Repro

tmp=$(mktemp -d /tmp/goboscript-broadcast-XXXXXX)
printf 'costumes "blank.svg";\n\n' > "$tmp/stage.gs"
printf 'costumes "blank.svg";\n\nonflag {\n    broadcast "hello";\n    broadcast_and_wait "world";\n}\n' > "$tmp/main.gs"
printf '<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>\n' > "$tmp/blank.svg"
cargo run --quiet -- build "$tmp"
python3 - <<'PY' "$tmp/$(basename "$tmp").sb3"
import json, sys, zipfile
with zipfile.ZipFile(sys.argv[1]) as z:
    p=json.loads(z.read('project.json'))
for t in p['targets']:
    print(t['name'], t['broadcasts'])
    for b in t['blocks'].values():
        if b.get('opcode', '').startswith('event_broadcast'):
            print(b['inputs']['BROADCAST_INPUT'])
PY

Observed:

Stage {}
main {}
[1, [11, 'hello', 'hello']]
[1, [11, 'world', 'world']]

The broadcast inputs reference message ids, but the stage broadcasts table is empty. Current code only collects names from on "..." event handlers, so send-only broadcasts are never registered.

Expected

All literal broadcast messages used by broadcast and broadcast_and_wait should be present in the stage broadcasts table, even when no receiver exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions