Menu

bubblecode can prompt users for input with the ask command, making it easy to build interactive programs.

The ask command

ask displays a prompt and waits for the user to type a response. The response is stored in the variable you specify.

example.bubble

When running in the browser, the prompt appears as an inline input field. Type your answer and press Enter.

Combining ask with logic

User input can drive program flow just like any other variable.

example.bubble

Building a game

The ask command is the foundation for interactive games. Here’s a number guessing game:

example.bubble

How it works in the browser

Under the hood, the bubblecode WASM runtime uses a replay model for interactive input:

  1. Your script starts running until it hits an ask command
  2. The runtime pauses and shows the prompt
  3. You type your answer and press Enter
  4. The runtime replays the entire script from the beginning, feeding all collected answers in order
  5. This repeats until the program finishes

This means every ask re-runs the script — but it happens so fast you won’t notice.