• JS Commission?

    From Android8675@VERT/SHODAN to All on Thu May 28 08:07:59 2020
    Looking for some help. I was about to tear into existing .js doors to see if I could figure it all out on my own, but maybe someone here might be able to make it easier for me.

    So I enjoy interactive fiction, a "bit", but finding a decent interpreter has been a pain in Windows because for some reason a lot of programs like Frotz for DOS/Windows just do not output simple text for BBSs, OR they allow saving anywhere which... that's just no good. So I found an old Waffle BBS door that did the trick (allowed saves for each user, output plain text, and even made a top 10 scores list), but now I've jumped over to Linux and dfrotz is working in a few test scenarios, but I'd like to have a small frontend that lets the user specify a couple parameters. So I'm hoping to have a .js door that:

    -takes a story datafile as a parameter
    -asks the user a question which specifies color choices to pass to dfrotz -makes a save folder for the user based on their username-# if it does not exist.
    +and calls dfrotz and exits after.

    Any help is appreciated from "Look at this link, you can do it..." type encouragement all the way up to a chunk of .js that I can drop in, modify as needed, test, deploy, etc.

    Credit given where credit is due. I could even float compensation your way if needed.

    As always, thanks in advance...
    -A.
    --
    Android8675@ShodansCore

    ---
    þ Synchronet þ Shodan's Core @ ShodansCore.com
  • From Coz to Android8675 on Thu May 28 19:14:15 2020
    Re: JS Commission?
    By: Android8675 to All on Thu May 28 2020 08:07 am

    Any help is appreciated from "Look at this link, you can do it..." type encouragement all the way up to a chunk of .js that I can drop in, modify as needed, test, deploy, etc.

    This may not be anything near what you're looking for.. and it's not JS, but have you taken a look at this project:

    https://sourceforge.net/projects/frotzdoor/

    It might get you closer to what you're looking for. I believe Marisa G. frequents DOVEnet and may have more insight as well. Hope this helps!
  • From echicken@VERT/ECBBS to Android8675 on Sun May 31 16:35:14 2020
    Re: JS Commission?
    By: Android8675 to All on Thu May 28 2020 08:07:59

    I'd like to have a small frontend that lets the user specify a couple parameters. So I'm hoping to
    have a .js door that:

    -takes a story datafile as a parameter
    -asks the user a question which specifies color choices to pass to dfrotz -makes a save folder for the user based on their username-# if it does not exist.
    +and calls dfrotz and exits after.

    // Script starts
    console.clear();
    const story = argv[0];
    const color = console.yesno('Do you want color?');
    const save_dir = backslash(format('%s%04d-dfrotz', system.data_dir, user.number));
    mkdir(save_dir);
    bbs.exec(
    'dfrotz' +
    ' -h ' + console.screen_rows +
    ' -f ' + (color ? 'ansi' : 'normal') +
    ' -R ' + save_dir
    );
    // Script ends

    That's a start anyhow; probably some more things to be added.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Android8675@VERT/SHODAN to echicken on Fri Jun 5 13:37:11 2020
    Re: JS Commission?
    By: Android8675 to All on Thu May 28 2020 08:07:59

    // Script starts
    console.clear();
    const story = argv[0];
    const color = console.yesno('Do you want color?');
    const save_dir = backslash(format('%s%04d-dfrotz', system.data_dir, user.number));
    mkdir(save_dir);
    bbs.exec(
    'dfrotz' +
    ' -h ' + console.screen_rows +
    ' -f ' + (color ? 'ansi' : 'normal') +
    ' -R ' + save_dir
    );
    // Script ends

    That's a start anyhow; probably some more things to be added.


    Thanks eC, gonna get to tinkering, can you decode the save_dir const for me? if user 1 runs zork, where's the save end up? if it's like /sbbs/data/if/zork/1/ that'd work...
    --
    Android8675@ShodansCore

    ---
    ­ Synchronet ­ Shodan's Core @ ShodansCore.com
  • From Android8675@VERT/SHODAN to echicken on Sun Jun 7 10:44:14 2020
    Re: JS Commission?
    By: echicken to Android8675 on Fri Jun 05 2020 09:39 pm

    const save_dir = backslash(format('%s%04d-dfrotz', system.data_dir,
    user.number));

    My example would've resulted in something like:

    /sbbs/data/0001-dfrotz/

    Maybe you want something like:

    const save_dir = backslash(format('%s/if/%s/%d', system.data_dir, story, user.number);

    OK, so the first %s is replaced with /sbbs/data/, then if/, then story/, and 0001/ for /sbbs/data/if/zork1/0001/

    I think I can figure that out, might swap story for the internal door code. I could maybe name the story file as the internal door code that way you just call the .js with no parameters needed, but that sounds like it breaks some code rule.

    Looks like I forgot to tell dfrotz which story file to use, so the bbs.exec statement should be more like:

    bbs.exec(
    'dfrotz' +
    '-h ' + console.screen_rows +
    '-f ' + (color ? 'ansi' : 'normal') +
    '-R ' + save_dir +
    story
    );

    Got that part. Thanks again. -A.

    --
    Android8675@ShodansCore

    ---
    þ Synchronet þ Shodan's Core @ ShodansCore.com
  • From Android8675@VERT/SHODAN to echicken on Mon Jun 8 12:32:23 2020
    Re: JS Commission?
    By: Android8675 to echicken on Sun Jun 07 2020 10:44:14

    You could try 'user.curxtrn' in place of 'story', as long as the internal code of the external program matches the name of the story file exactly (or work from there by appending a suffix/file extension or whatever to the value of user.curxtrn).

    OK, I can try that. I started the tinkering. Hopefully I'll have something cool by the end of the week. Board is running so smoothly now.

    Sidenote...
    I'm glad I took the time to move everything over to Linux. It's just so nice, but I broke my webv4 custom.css. Something was causing problems as all the text colors were weird, but after a restart and nuking nginx that I forgot I put on, everything seems to be working smoothly.

    --
    Android8675@ShodansCore

    ---
    ­ Synchronet ­ Shodan's Core @ ShodansCore.com
  • From Android8675@VERT/SHODAN to Coz on Mon Jun 8 12:37:23 2020
    This may not be anything near what you're looking for.. and it's not JS, but have you taken a look at this project:

    https://sourceforge.net/projects/frotzdoor/

    It might get you closer to what you're looking for. I believe Marisa G. frequents DOVEnet and may have more insight as well. Hope this helps!

    Saw that a long time ago, I don't like that it disables saving altogether. IF needs a save capability. Easier to just tell Frotz where it's OK to save files each time and restrict it's access as needed. I'm getting there. I really wanted to mess with fonts and color settings as well. Eventually I'd like to make it so you can run the story through the web or bbs interface, access your saves, and get access to the more advanced story engines like Hugo, TADS, Glulx, etc.

    --
    Android8675@ShodansCore

    ---
    ­ Synchronet ­ Shodan's Core @ ShodansCore.com
  • From echicken@VERT/ECBBS to Android8675 on Tue Jul 14 23:05:35 2020
    Re: JS Commission?
    By: Android8675 to echicken on Tue Jul 14 2020 11:51:05

    const story = backslash(format('stories/%s', argv[0]));
    const save_dir = backslash(format('%sif/%s%d', system.data_dir, story,
    user.number));
    //debug
    console.print(story);
    console.crlf(2);
    console.print(save_dir);

    and it spits out:

    stories/zork1.z3/

    /sbbs/data/if/stories/zork1.z3/1/

    the save path is fine, and I verified it works, but how do I drop the trailing
    slash for the story file? Was thinking:

    const story = format('stories/%s', argv[0]);

    backslash(str) adds a slash or backslash to 'str', depending whether you are on *nix or Windows. I don't think it actually checks to see if the path exists, if there's a file or dir there, etc.

    You might try:

    const story = format('stories/%s', argv[0]);
    const save_dir = backslash(format('%sif/%s', system.data_dir, story));
    const save_file = format('%s%d', save_dir, user.number);

    and then adjust your script to use save_file instead of save_dir.

    Or you could condense it to:

    const save_file = backslash(format('%sif/stories/%s', system.data_dir, argv[0])) + user.number;

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Mortifis@VERT/EPHRAM to Android8675 on Wed Jul 15 00:36:25 2020
    My example would've resulted in something like:

    /sbbs/data/0001-dfrotz/

    Hey eC,

    So I have:

    const story = backslash(format('stories/%s', argv[0]));
    const save_dir = backslash(format('%sif/%s%d', system.data_dir, story, user.number));

    //debug
    console.print(story);
    console.crlf(2);
    console.print(save_dir);

    and it spits out:

    stories/zork1.z3/

    /sbbs/data/if/stories/zork1.z3/1/

    the save path is fine, and I verified it works, but how do I drop the trailing slash for the story file? Was thinking:

    const story = format('stories/%s', argv[0]);

    const story = format('stories/%s', argv[0].slice(0,1)); might work

    ---
    þ Synchronet þ Realm of Dispair BBS - http://ephram.synchro.net:82
  • From Android8675@VERT/SHODAN to echicken on Wed Jul 15 09:40:17 2020
    You might try:

    const story = format('stories/%s', argv[0]);
    const save_dir = backslash(format('%sif/%s', system.data_dir, story));
    const save_file = format('%s%d', save_dir, user.number);

    and then adjust your script to use save_file instead of save_dir.

    Or you could condense it to:

    const save_file = backslash(format('%sif/stories/%s', system.data_dir, argv[0])) + user.number;

    frotz needs a folder for saves. I wonder if I could put all the saves in one folder. Gotta check what frotz uses for save filenames. If the filename contains a story marker then I could probably use:

    const story = format('stories/%s', argv[0]);
    const save_dir = backslash(format('%sif/saves/%s', system.data_dir, user.number));

    That'd dump all saves for one user in /sbbs/data/if/saves/(user.number)/

    Next question how do I take a const from 1-4 and pass 4 different results based on the number?

    Basically
    const colors = console.getnum(4, 1);

    then pass different strings based on the answer like..

    bbs.exec(
    'frotz ' +
    '-h ' + console.screen_rows +
    '-w ' + console.screen_columns +
    '-f ' + (colors ? 'green' : 'white' : 'white' : 'yellow') + // <--- these bits here
    '-b ' + (colors ? 'black' : 'black' : 'blue' : 'black') +
    '-R ' + save_dir +
    story
    );

    Final final... why doesn't the background on this line switch to blue? Ctrl-A "4" should be blue background.

    console.putmsg(" 3.\1h\14 White on Blue\1n");



    --
    Android8675@ShodansCore

    ---
    þ Synchronet þ Shodan's Core @ ShodansCore.com
  • From echicken@VERT/ECBBS to Android8675 on Wed Jul 15 22:43:14 2020
    Re: JS Commission?
    By: Android8675 to echicken on Wed Jul 15 2020 09:40:17

    Next question how do I take a const from 1-4 and pass 4 different results based
    on the number?

    Basically
    const colors = console.getnum(4, 1);
    then pass different strings based on the answer like..

    '-f ' + (colors ? 'green' : 'white' : 'white' : 'yellow') +
    '-b ' + (colors ? 'black' : 'black' : 'blue' : 'black') +

    I would probably do this:

    const fg = ['green', 'white', 'white', 'yellow'];
    const bg = ['black', 'black', 'blue', 'black'];
    const colors = console.getnum(4, 1) - 1;

    bbs.exec(
    'frotz '
    ...
    + '-f ' + fg[colors]
    + '-b ' + bg[colors]
    ...
    );

    Where 'fg' and 'bg' are arrays of strings. If the user hits '4', fg[3] and bg[3] would be used, so the user would get yellow-on-black, and so on. (If I'm understanding your goal properly.)

    Final final... why doesn't the background on this line switch to blue? Ctrl-A
    "4" should be blue background.

    console.putmsg(" 3.\1h\14 White on Blue\1n");

    Not sure. Try \x014 instead of \14 and see if it helps.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
  • From Android8675@VERT/SHODAN to echicken on Mon Jul 20 13:21:55 2020
    Re: JS Commission?
    By: echicken to Android8675 on Wed Jul 15 2020 10:43 pm

    Re: JS Commission?
    By: Android8675 to echicken on Wed Jul 15 2020 09:40:17

    I would probably do this:

    const fg = ['green', 'white', 'white', 'yellow'];
    const bg = ['black', 'black', 'blue', 'black'];
    const colors = console.getnum(4, 1) - 1;

    bbs.exec(
    'frotz '
    ...
    + '-f ' + fg[colors]
    + '-b ' + bg[colors]
    ...
    );

    Where 'fg' and 'bg' are arrays of strings. If the user hits '4', fg[3] and bg[3] would be used, so the user would get yellow-on-black, and so on. (If I'm understanding your goal properly.)

    Yeah, that looks right, and verified that the results I need are getting passed to bbs.exec, but I think frotz doesn't like something. It's throwing up TERMCAP errors. I had to catch the output in a janky way, but it threw up:

    ERROR: Unknown terminal: ansi-bbs
    Check the TERM environment variable.
    Also make s
    ure that the terminal is defined in the terminfo database.
    Alternatively, set the
    TERMCAP environment variable to the desired
    termcap entry
    --clip--

    Tried with both frotz and dfrotz, same error.

    console.putmsg(" 3.\1h\14 White on Blue\1n");

    Not sure. Try \x014 instead of \14 and see if it helps.

    That did it. Thanks.
    -A.

    --
    Android8675@ShodansCore

    ---
    þ Synchronet þ Shodan's Core @ ShodansCore.com
  • From echicken@VERT/ECBBS to Android8675 on Mon Jul 20 22:27:21 2020
    Re: JS Commission?
    By: Android8675 to echicken on Mon Jul 20 2020 13:21:55

    ERROR: Unknown terminal: ansi-bbs
    Check the TERM environment variable.
    Also make s
    ure that the terminal is defined in the terminfo database.
    Alternatively, set the
    TERMCAP environment variable to the desired
    termcap entry

    Try following the "Terminal Capabilities" section here:

    http://wiki.synchro.net/install:nix#terminal_capabilities

    There are probably other hacky ways around this, but with any luck that'll get the job done.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com