You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
kakafarm
changed the title
Interactive fiction on the r4rs/tc web repl?
Interactive fiction on the r4rs/tc web repl? (cleaning the textarea and using read-line)
Oct 26, 2024
@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:
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
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.The text was updated successfully, but these errors were encountered: