Adding to EndGame message

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

Bainespal
Posts: 151
Joined: Fri Jul 09, 2010 8:59 am

Adding to EndGame message

Post by Bainespal »

The documentation to the roodylib extension suite explains the use of SpecialKey to add another option during a particular ending state. I'm pretty sure you're also going to need to tell the player that there is such a choice, by printing your "(A)musing" (or whatever) notice.

You could almost use NewMessages to replace the messages for case &EndGame. However, I only want to show the special option for some ending states and not all of them. I'd need to add a new "num" value case, but that would mean I'd also have to replace EndGame itself, in order to test for the new case.

I've added roodylib, and I see that roodylib has changed EndGame. Looking at the code, I still don't see what I have to replace in order to add text to the message.

Roody_Yogurt
Posts: 2181
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Post by Roody_Yogurt »

If you notice, EndGame has this line:

Code: Select all

Message(&EndGame, 1,end_type)
"end_type" is the endflag value you used to call EndGame (example: endflag = 3)

Because of this, you can replace the EndGame message with something like this:

Code: Select all

replace NewMessages(r, num, a, b)
{
   select r
	case &EndGame
	{
		select num
		case 1
		{
			print "\nThe game has ended.  Do you want to (R)ESTART,
				R(E)STORE a saved game, ";
#ifclear NO_UNDO
			if not UNDO_OFF         ! if not otherwise overridden
				print "(U)NDO your last turn, ";
#endif
                        if a = 3 ! ( a = end_flag)
                             print "(A)musing notes, ";
			print "or (Q)UIT? ";
		}
		case 2
		{
			print "Enter (R)ESTART, R(E)STORE, ";
#ifclear NO_UNDO
			if not UNDO_OFF
				print "(U)NDO, ";
#endif
                        if a = 3 ! ( a = end_flag)
                             print "(A)musing notes, ";
			print "or (Q)UIT: ";
		}
	}

   case else : return false
   return true ! this line is only reached if we replaced something
}
where the applicable text only prints when it's the right endflag.

Bainespal
Posts: 151
Joined: Fri Jul 09, 2010 8:59 am

Post by Bainespal »

That works well. Thank you.

Roody_Yogurt
Posts: 2181
Joined: Mon Apr 29, 2002 6:23 pm
Location: Milwaukee

Post by Roody_Yogurt »

Glad to hear it!

Post Reply