Find documentation at: https://www.npmjs.com/package/glk
let line=new Uint8Array(80);
if(s.toLowerCase()=="quit") return Glk.exit();
if(s) Glk.put_string("Hello, "+s+"!\n");
If you have any suggestions, questions, comments, complaints, etc, you can please to write it on here or on ifMUD. I will also accept the patches if needing for working with Glk implementations other than GlkTerm.
How does this differ from the Glk implementation (glkapi.js) in GlkOte?
Is it for Node then? Do you have to recompile the Glk implementation?
The documentation at the npm site is hard to read as it’s all in a code block. I suggest using more markdown
Yes, it is for Node.js. You only need to compile the Glk implementation if it is not already compiled; if you have the .o or .a files then you can use those. You could use any Glk implementation; you will only need to change the startup code and/or compilation instructions in glkrun.c if you use a different one than GlkTerm (if you do this, please post your patches on here, so that we can use them with other Glk implementations too); changing index.js should be unnecessary, although if your Glk implementation has additional functions and/or constants, you may wish to edit dispatch.js in order to add those additional functions/constants.
I looked at the glkapi.js in GlkOte more now, and here is a list of the differences between my program and that glkapi.js (although I may have missed some or made other mistakes):
- There is no RefBox and RefStruct. Instead, this program uses arrays for references and structures.
- Constants are not placed in a separate namespace.
- Glk function names do not have “glk_” at front.
- This program can use typed arrays when an array must be passed to/from Glk.
- There is no “Do Not Return”.
Also, here is the output from “wc” to show the sizes of these files, in case anyone is interested:
385 699 9677 glkrun.c
274 684 11735 dispatch.js
294 621 9494 index.js
953 2004 30906 total
True. Difficult to read. In Firefox you can go view > page style > without style for now
I do not find it difficult to read. However, if you have npm installed, you can also try “npm show glk readme”; that is another way to read it.
Edit: Someone says it is clipped on the right on the webpage. Not on my computer, though.
It’s because the code text is clipped at the right, so you need to scroll.
Thanks for the tip though