Open kakafarm opened 1 month ago
@kakafarm I just added some examples files to make your quest of making a text-driven game easier! (see #77 for details)
In general, I think you shouldn't try to "hook" into the r4rs repl with JavaScript code (like you are showing with the feed_code
function). This can lead to read/write problems and is not very portable to other hosts. Instead, I suggest that you compile the game scheme file to a JavaScript program using ribbit and enable the "web" capabilities. To showcase what I mean, I added a text-game.scm
program to the examples. You can compile it like this:
$ ./rsc.exe -t js -l r4rs/tc -f+ js/web -o game.js examples/text-game.scm
Now, game.js
can be loaded in any html file and will create a text-area with the running scheme program. I added an example "console.html" under host/js/console.html
with #77 as well. See the comments inside text-game.scm
for information about how to run the scheme progam in web-javascript or python :)
I made these examples quickly, if you encounter problems, don't hesitate to report them
Thank you. Will post an update when there's something not very embarrassing, only a little.
I am trying to write an interactive fiction game in Ribbit. Right now I am able to load arbitrary Scheme code as shown in the web repl examples, using this function after successfully fetching the source:
I am missing two things before I am able to use Ribbit for this game:
Clean the repl textarea after loading the source code:
When I
repl.value = ""
, the repl stops working. No new user input makes the repl print a result.Read the user input:
When I try to read user input using
(read-line)
, the repl stops working and no new user input makes the repl print a result.