Tweaking incidences of "the player's surroundings"

(6M62)

For various reasons, I’ve replaced the phrase “the player’s surroundings” in my game with my own phrase that gets that computed text (i.e. it starts off with “the player’s surroundings”) then capitalises the first letter and prints that version instead.

I found after an UNDO, the moment of the room name automatically being printed evades my tweak, and I don’t know where it is to replace it. Maybe in the i6 bits.

Does someone know where this is, or how to tweak it to do what I want to do? Thanks

-Wade

The I6 DealWithUndo() routine. This calls SL_Location(), which is the standard implementation of the “player’s surroundings” phrase.

Thanks. But I don’t know how to make that I6 routine point to my I7 phrase, or how to rewrite it to do what the phrase is doing anyway (capitalise first letter when printing).

-Wade

Is anyone able to help me with my not-knowings raised in the immediately prior post?

-Wade

If you were using Ver 10, what @zarf says is correct and a simple modification to DealWithUndo would sort it (exactly how you would need to write it would depend on how you’ve implemented your replacement for player's surroundings, but in principle)

To say xyzzy surroundings (this is xyzzying):
	say "[Player's surroundings]" in sentence case.

Include (-

[ DealWithUndo;
	VM_RestoreWindowColours();
	VM_Style(SUBHEADER_VMSTY);
	((+ xyzzying +)-->1)();                      !  ####### Insertion here #######
	! SL_Location();                                ! ####### Commented out ######
	print "^";
	VM_Style(NORMAL_VMSTY);
	IMMEDIATELY_UNDO_RM(69);
	print "^";
];
-) replacing "DealWithUndo".

Unfortunately in 6M62 the undo handling isn’t broken out to a short routine in this way, but is part of the mammoth Keyboard() routine. So:

To say xyzzy surroundings (this is xyzzying):
	say "[Player's surroundings] xyzzy" in sentence case.

Include (-
Replace Keyboard;
-) after "Definitions.i6t".

Include (-

[ Keyboard  a_buffer a_table  nw i w w2 x1 x2;
	sline1 = score; sline2 = turns;

	while (true) {
		! Save the start of the buffer, in case "oops" needs to restore it
		for (i=0 : i<64 : i++) oops_workspace->i = a_buffer->i;
	
		! In case of an array entry corruption that shouldn't happen, but would be
		! disastrous if it did:
		#Ifdef TARGET_ZCODE;
		a_buffer->0 = INPUT_BUFFER_LEN;
		a_table->0 = 15;  ! Allow to split input into this many words
		#Endif; ! TARGET_
	
		! Print the prompt, and read in the words and dictionary addresses
		PrintPrompt();
		DrawStatusLine();
		KeyboardPrimitive(a_buffer, a_table);
	
		! Set nw to the number of words
		#Ifdef TARGET_ZCODE; nw = a_table->1; #Ifnot; nw = a_table-->0; #Endif;
	
		! If the line was blank, get a fresh line
		if (nw == 0) {
			@push etype; etype = BLANKLINE_PE;
			players_command = 100;
			BeginActivity(PRINTING_A_PARSER_ERROR_ACT);
			if (ForActivity(PRINTING_A_PARSER_ERROR_ACT) == false) {
				PARSER_ERROR_INTERNAL_RM('X', noun); new_line;
			}
			EndActivity(PRINTING_A_PARSER_ERROR_ACT);
			@pull etype;
			continue;
		}
	
		! Unless the opening word was OOPS, return
		! Conveniently, a_table-->1 is the first word on both the Z-machine and Glulx
	
		w = a_table-->1;
		if (w == OOPS1__WD or OOPS2__WD or OOPS3__WD) {
			if (oops_from == 0) { PARSER_COMMAND_INTERNAL_RM('A'); new_line; continue; }
			if (nw == 1) { PARSER_COMMAND_INTERNAL_RM('B'); new_line; continue; }
			if (nw > 2) { PARSER_COMMAND_INTERNAL_RM('C'); new_line; continue; }
		
			! So now we know: there was a previous mistake, and the player has
			! attempted to correct a single word of it.
		
			for (i=0 : i<INPUT_BUFFER_LEN : i++ ) buffer2->i = a_buffer->i;
			#Ifdef TARGET_ZCODE;
			x1 = a_table->9;  ! Start of word following "oops"
			x2 = a_table->8;  ! Length of word following "oops"
			#Ifnot; ! TARGET_GLULX
			x1 = a_table-->6; ! Start of word following "oops"
			x2 = a_table-->5; ! Length of word following "oops"
			#Endif; ! TARGET_
		
			! Repair the buffer to the text that was in it before the "oops"
			! was typed:
			for (i=0 : i<64 : i++ ) a_buffer->i = oops_workspace->i;
			VM_Tokenise(a_buffer,a_table);
		
			! Work out the position in the buffer of the word to be corrected:
			#Ifdef TARGET_ZCODE;
			w = a_table->(4*oops_from + 1); ! Start of word to go
			w2 = a_table->(4*oops_from);    ! Length of word to go
			#Ifnot; ! TARGET_GLULX
			w = a_table-->(3*oops_from);      ! Start of word to go
			w2 = a_table-->(3*oops_from - 1); ! Length of word to go
			#Endif; ! TARGET_
		
			! Write spaces over the word to be corrected:
			for (i=0 : i<w2 : i++) a_buffer->(i+w) = ' ';
		
			if (w2 < x2) {
				! If the replacement is longer than the original, move up...
				for (i=INPUT_BUFFER_LEN-1 : i>=w+x2 : i-- )
					a_buffer->i = a_buffer->(i-x2+w2);
		
				! ...increasing buffer size accordingly.
				#Ifdef TARGET_ZCODE;
				a_buffer->1 = (a_buffer->1) + (x2-w2);
				#Ifnot; ! TARGET_GLULX
				a_buffer-->0 = (a_buffer-->0) + (x2-w2);
				#Endif; ! TARGET_
			}
		
			! Write the correction in:
			for (i=0 : i<x2 : i++) a_buffer->(i+w) = buffer2->(i+x1);
		
			VM_Tokenise(a_buffer, a_table);
			#Ifdef TARGET_ZCODE; nw = a_table->1; #Ifnot; nw = a_table-->0; #Endif;
		
			return nw;
		}

		! Undo handling
	
		if ((w == UNDO1__WD or UNDO2__WD or UNDO3__WD) && (nw==1)) {
			Perform_Undo();
			continue;
		}
		i = VM_Save_Undo();
		#ifdef PREVENT_UNDO; undo_flag = 0; #endif;
		#ifndef PREVENT_UNDO; undo_flag = 2; #endif;
		if (i == -1) undo_flag = 0;
		if (i == 0) undo_flag = 1;
		if (i == 2) {
			VM_RestoreWindowColours();
			VM_Style(SUBHEADER_VMSTY);
			((+ xyzzying +)-->1)();                               !   ###### Insertion here ######
			!SL_Location();                                            !   ###### Commented out #####
			print "^";
			! print (name) location, "^";
			VM_Style(NORMAL_VMSTY);
			IMMEDIATELY_UNDO_RM('E'); new_line;
			continue;
		}
		return nw;
	}
];
-) after "Output.i6t".
3 Likes

Thanks @drpeterbatesuk . I’ll have a look at the code you’ve given and compare it to where/how my UNDO code is stored. It’s probably already a messy situation as I have both Undo Output Control and Unified Glulx Input going. EDIT - Yeah, UGI changed that routine, then Undo Output Control changed UGI. I altered the code there and it worked. Thanks!

-Wade