Help me modify the SCRIPT command, for science

I’m going to be showing Blue Lacuna at the IndieCade games festival in L.A. next month. I’d like to do something similar to what I did at Slamdance four years ago with Whom the Telling Changed, and record a transcript of all the people who interact with the game at the festival. This would provide an interesting, semi-empirical comparison to see if highlighted keywords make IF less frustrating.

For Slamdance, I’d paid a friend of mine to modify the Gargoyle source code to hack this in. I’m no longer in touch with him, however, so I’m trying to roll something myself in I7 this time. This is as far as I’ve gotten:

Include (-

[ SWITCH_TRANSCRIPT_ON_R  newFileName;
	if (actor ~= player) rfalse;
	if (gg_scriptstr ~= 0) rfalse; !return GL__M(##ScriptOn, 1);
	newFileName = "bl-" + (string) random(10000000) + "-script";
	if (gg_scriptfref == 0) {
		!gg_scriptfref = glk_fileref_create_by_prompt($102, $05, GG_SCRIPTFREF_ROCK);
		print (string) newFileName;
		gg_scriptfref = glk_fileref_create_by_name($102, newFileName, GG_SCRIPTFREF_ROCK);
		if (gg_scriptfref == 0) jump S1Failed;
	}
	! stream_open_file
	gg_scriptstr = glk_stream_open_file(gg_scriptfref, $05, GG_SCRIPTSTR_ROCK);
	if (gg_scriptstr == 0) jump S1Failed;
	glk_window_set_echo_stream(gg_mainwin, gg_scriptstr);
	!GL__M(##ScriptOn, 2);
	!VersionSub();
	return;
	.S1Failed;
	return;
	!GL__M(##ScriptOn, 3);
];

-) instead of "Switch Transcript On Rule" in "Glulx.i6t".

The idea is supposed to be that each time this routine runs, it creates a new file with a random number in its name, without showing any messages to the user at all regardless of success or failure. (Yeah, this is a nasty hack, etc., etc… it’s just for one computer at one venue.) What I’ve got so far is broken for apparently a couple of reasons: I guess you can’t dynamically create strings this easily in I6, and also apparently I’m not giving the glk_fileref_create_by_name function the sort of string it expects.

(Oh, and I need to compile Blue Lacuna with build 5Z71, in case that makes a difference.)

Any pointers?

What happens if you use the code:

Array Output_File_Name -> 'b' 'l' '-' 0 0 0 0 0 0 0 0 '-' 's' 'c' 'r' 0;

[ Build_Name num;
	for (num = 3; num < 11; ++ num)
		Output_File_Name->num = random(10) + '0' - 1;
];

Call Build_Name() and pass Output_File_Name to the function?

I think you also need $E0 as the first byte of the array to tag it as a Glulx unencoded string object.

You might try using the function Glulx_ChangeAnyToCString(). I believe this is how the external files template handles strings.

–Erik

Thanks, everyone, got it working. If anyone else needs to do something similar in the future, here’s the final code:

Section - New Switch Transcript On rule

First when play begins: try switching the story transcript on.

Include (-

Array Output_File_Name -> $E0 'b' 'l' '-' 0 0 0 0 0 0 0 0 '-' 's' 'c' 'r' 0;

[ Build_Name num;
   for (num = 4; num < 11; ++ num)
      Output_File_Name->num = random(10) + '0' - 1;
];

[ SWITCH_TRANSCRIPT_ON_R  newFileName tmpStr;
	if (actor ~= player) rfalse;
	Build_Name();
	gg_scriptfref = glk_fileref_create_by_name($102, Glulx_ChangeAnyToCString(Output_File_Name), GG_SCRIPTFREF_ROCK);
	if (gg_scriptfref == 0) jump S1Failed;
	gg_scriptstr = glk_stream_open_file(gg_scriptfref, $05, GG_SCRIPTSTR_ROCK);
	if (gg_scriptstr == 0) jump S1Failed;
	glk_window_set_echo_stream(gg_mainwin, gg_scriptstr);
	return;
	.S1Failed;
	return;
];

-) instead of "Switch Transcript On Rule" in "Glulx.i6t".