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));
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...
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
);
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.
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!
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);
My example would've resulted in something like:
/sbbs/data/0001-dfrotz/
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);
stories/zork1.z3/
/sbbs/data/if/stories/zork1.z3/1/
const story = format('stories/%s', argv[0]);
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: | Chris Crash |
---|---|
Location: | Huntington Beach, CA. |
Users: | 578 |
Nodes: | 8 (0 / 8) |
Uptime: | 29:06:45 |
Calls: | 10,736 |
Calls today: | 1 |
Files: | 5 |
Messages: | 443,196 |
Posted today: | 1 |