ryanisaacg / quicksilver

A simple framework for 2D games on desktop and web
https://ryanisaacg.github.io/quicksilver
Other
780 stars 77 forks source link

Integration with scripting languages #229

Closed ryanisaacg closed 5 years ago

ryanisaacg commented 6 years ago

Rust has some less-than-ideal compile times, especially on Windows. This could be alleviated by allowing users to write change-intensive portions of their programs in a scripting language, which would also allow dynamic reloading of behavior at runtime.

A few languages that it would be good to integrate with are:

memoryruins commented 6 years ago

A month ago Kyren from Chucklefish explained on reddit some differences of rlua and hlua.

Gluon is another option. Its VM is tested for wasm builds on travis ci. Unaware if wasm has been tested beyond that, but the language is actively developed.

ryanisaacg commented 6 years ago

Thanks for the lua link!

Gluon definitely looks like it's great technically, but the syntax kinda puts me off (it reminds me of Haskell which I'm fond of, except I wouldn't really want to script game logic in Haskell.) I'd definitely be open to merging support for it, but probably wouldn't work on it myself.

memoryruins commented 6 years ago

Understandable ^^

Lua is attractive with its popularity in video game scripting, but it seems problematic for wasm/browser targets. If it could be embedded easily by a user in their quicksilver game (for a custom level editor / game api) without crate integration, quicksilver could provide an example/tutorial in the /examples.

The simplest language from the list, both in syntax and for embedding, appears to be Rhai. One game engine currently using it is Orbgame.

ryanisaacg commented 6 years ago

Yeah, having looked through the Rhai source it's definitely lightweight. Thanks for the link to Orbgame, I'd never seen that before.

memoryruins commented 6 years ago

Not many have. It was never published on crates.io, and hasn't been updated since February. Cool seeing Redox add it though!

beatgammit commented 6 years ago

Lua is written in ANSI-C, so compiling it for WASM is fairly trivial (example here).

I'm not sure how hard it would be to port hlua or rlua to be WASM compatible, but it probably isn't too bad.

I'm somewhat interested in getting Rust->WASM with Lua working, but it's not immediately pressing for me (read: I'm interested in helping, but not leading the effort).

ryanisaacg commented 6 years ago

As far as I'm aware, it's currently not possible to link a Rust module with a C module in WASM, which would mean that porting rlua or hlua to WASM would require a Rust implementation of the Lua library.

beatgammit commented 6 years ago

Really? That's unfortunate. I guess WASM doesn't have modules yet, so that would make sense, but once it does, I'd expect that to be doable.

It could be doable with a JavaScript shim for all of the calls.

ryanisaacg commented 5 years ago

This is no longer a high priority, as it seems the general pattern of Rust scripting languages is to make data marshaling very convenient, so it makes more sense for the user to embed scripting into their application rather than the other way around. This means that Quicksilver probably doesn't need to support any scripting directly.