Skip to content

Export makeTornado and makeMonster to JavaScript - #20

Open
jquast wants to merge 1 commit into
SimHacker:mainfrom
jquast:up-feat-export-tornado-monster
Open

jquast wants to merge 1 commit into
SimHacker:mainfrom
jquast:up-feat-export-tornado-monster

Conversation

@jquast

@jquast jquast commented Sep 29, 2026

Copy link
Copy Markdown

makeEarthquake, makeFire and makeFlood are bound; makeMonster and makeTornado were not, so a caller could start neither one:

$ make -C packages/micropolis-engine install
$ cd apps/micropolis
$ node_modules/.bin/tsx -e "import { loadMicropolisMainModule } from './src/lib/wasm/node.ts'; import { createNoopJsCallback } from './src/lib/wasm/callbacks'; (async () => { const e = await loadMicropolisMainModule(); const m = new e.Micropolis(); m.setCallback(createNoopJsCallback(e), {}); m.init(); console.log('makeMonster:', typeof m.makeMonster, 'makeTornado:', typeof m.makeTornado); m.makeMonster(); m.makeTornado(); console.log('sprite types:', m.getActiveSprites().map((s) => s.type)); })();"
makeMonster: undefined makeTornado: undefined
TypeError: m.makeMonster is not a function

The same command after this commit starts one sprite of each:

makeMonster: function makeTornado: function
sprite types: [ 6, 5 ]

Depends on #15 (the loader fix) to run the commands above.

The other disaster triggers (makeEarthquake, makeFire, makeFlood) are
already bound, so bind these two as well and let callers start any
disaster from JavaScript.
@jquast
jquast marked this pull request as ready for review September 29, 2026 17:15

This branch has not been deployed

No deployments
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.

1 participant