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.
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.
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.
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);
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
);
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).
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!
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]);
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]);
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;
const colors = console.getnum(4, 1);
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
);
console.putmsg(" 3.\1h\14 White on Blue\1n");
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') +
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");
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.)
console.putmsg(" 3.\1h\14 White on Blue\1n");
Not sure. Try \x014 instead of \14 and see if it helps.
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
Sysop: | Coz |
---|---|
Location: | Anoka, MN |
Users: | 2 |
Nodes: | 4 (0 / 4) |
Uptime: | 190:40:38 |
Calls: | 184 |
Calls today: | 1 |
Files: | 5,413 |
Messages: | 222,750 |