Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples for using ifvms.js (client side + maybe server side too?) #10

Closed
jedi4ever opened this issue Apr 8, 2013 · 6 comments
Closed
Labels

Comments

@jedi4ever
Copy link

Hi @curiousdannii , over the last weekend I've taken a great interest in Interactive Fiction.

I'm building a work situation simulator and would love to use ifvms.js or other javascript framework to 'play' these kind of situation.

  1. From the code, it's hard to understand how to embed/use ifvms.js in your own code. It would be great if you have some examples to load it

  2. I could not tell if the code only works inside a browser environment or you could also use it in a nodejs backend process that emit events that could be visualised through socket.io on the browser.

I've seen you have some tests, but from what I can judge the are running inside the browser?
My idea is to :

  • keep the state somehow on the server side and use the browser just a visualising aspect. So if people reconnect to the app, they would still be in their current state.
  • it would allow multi-user access of the same game session , which could be great at collaboratively solving sessions
  1. I also like to integrate 'real' events , inside the game. Could the backend play/capture events and execute some stuff and give back some results? Like a bot command on irc or so.

Any hints you can provide here are greatly appreciated!

@curiousdannii
Copy link
Owner

Only got time for a quick answer right now, sorry! Take a look at https://github.com/curiousdannii/ifvms.js/blob/master/dist/bootstrap.js to see ZVM being used in node.js.
https://github.com/curiousdannii/parchment/blob/master/src/structio/runner.js is used in Parchment on the web.

It's designed to be used with Web Workers (though it isn't yet...), so everything happens with two functions: ZVM.inputEvent() and ZVM.outputEvent().

@jedi4ever
Copy link
Author

awesome! thanks for the pointers. this looks really promising!

@jedi4ever
Copy link
Author


vm = ifvms.bootstrap.zvm('a.z5',['one', 'two']);  
// This seems to work for a few of the examples provided but not for my inform7-> down compile z5 code
console.log(vm.output); 

// Now how do I continue on this thread?
vm.inputEvent({ code: 'read' , response: 'three' });

@curiousdannii
Copy link
Owner

You'll want to write your own event handler... the bootstrap one is very simple because I know what events it will produce. runner.js (in Parchment) handles quite a few more, as does api.js in the same folder.

The read event needs a number of other properties, which is why I add the response text on to the original event object and then give it back to the engine. Which now that I think about it is a really poor design... you should be able to just send back the response text by itself. I'll get around to changing that, eventually.

@jedi4ever
Copy link
Author

We can close it here - I've started to work something out -

See https://github.com/jedi4ever/ifplayer.js , still could use your guidance obviously!

@curiousdannii
Copy link
Owner

Sure thing, ask anytime. The parchment Google group is probably the best place.
Oh, and keep a lookout for changes to the API, it's quite unstable at the moment. If you have any suggestions for improvements to it I'd be happy to hear them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants