# Understanding the Engine Logic Behind prompt.ts and game.askForString()

**URL:** <https://forum.makecode.com/t/understanding-the-engine-logic-behind-prompt-ts-and-game-askforstring/38624>\
**Category:** Help\
**Tags:** extension\
**Created:** [August 11, 2025, 5:13pm UTC](https://forum.makecode.com/t/understanding-the-engine-logic-behind-prompt-ts-and-game-askforstring/38624 "2025-08-11T17:13:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![a012](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/a012/32/24099_2.png) [@a012](https://forum.makecode.com/u/a012)\
**Post date:** [August 11, 2025, 5:13pm UTC](https://forum.makecode.com/t/understanding-the-engine-logic-behind-prompt-ts-and-game-askforstring/38624/1 "2025-08-11T17:13:39Z")

</div>

Hi Richard (and anyone from the MakeCode team),

In my earlier topic here: _Trying to Learn How Richard Builds Engine-Level Code like controller.ts_ I’ve been asking about building engine-level systems like [controller.ts](https://github.com/microsoft/pxt-common-packages/blob/master/libs/game/controller.ts).

This time, I’m curious about [prompt.ts](https://github.com/microsoft/pxt-common-packages/blob/master/libs/game/prompt.ts) — specifically, the function that asks the player for a string (`game.askForString()`).

I’m not asking how to _use_ it — I want to understand how the internal logic was implemented:

- How does it store the prompt state?

- How is it hooked into the game’s update loop?

- How does it capture input events and draw the UI?

- How does it finish and return the value to the caller?

If possible, I’d love a simplified breakdown or pseudo-code showing how you designed it so it feels like a built-in engine feature.

Thanks!

---

<div class="post-metadata">

**Author:** ![a012](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/a012/32/24099_2.png) [@a012](https://forum.makecode.com/u/a012)\
**Post date:** [August 11, 2025, 6:55pm UTC](https://forum.makecode.com/t/understanding-the-engine-logic-behind-prompt-ts-and-game-askforstring/38624/2 "2025-08-11T18:55:21Z")

</div>

If @richard or @joey can help, that would be great — if not, that’s fine too.\*\*  
I’m trying to learn how Richard builds engine-level code. The link wasn’t working before, so here’s the correct clickable version:  
[Trying to Learn How Richard Builds Engine-Level Code like controller.ts - Arcade / Help - Microsoft MakeCode](https://forum.makecode.com/t/trying-to-learn-how-richard-builds-engine-level-code-like-controller-ts/38548)

You can also check my other responses there. If you have any questions, feel free to ask.  
I appreciate your help — thanks and bye for now!

---

<div class="post-metadata">

**Author:** ![not\_a\_lemon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/not_a_lemon/32/35289_2.png) [@not\_a\_lemon](https://forum.makecode.com/u/not_a_lemon)\
**Post date:** [August 11, 2025, 6:55pm UTC](https://forum.makecode.com/t/understanding-the-engine-logic-behind-prompt-ts-and-game-askforstring/38624/3 "2025-08-11T18:55:24Z")

</div>

This would be cool to understand as I’m trying to make a custom version of the prompt.ts code with custom art and font.

---

<div class="post-metadata">

**Author:** ![a012](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/a012/32/24099_2.png) [@a012](https://forum.makecode.com/u/a012)\
**Post date:** [August 12, 2025, 2:13am UTC](https://forum.makecode.com/t/understanding-the-engine-logic-behind-prompt-ts-and-game-askforstring/38624/4 "2025-08-12T02:13:59Z")

</div>

Yeah, I am still learning how they code prompt file with a lot of lines in just an hour as well, but I just hope that `@Richard` or `@Jwunderll` one day can do it.
