How to replace NewMessages

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

How to replace NewMessages

Post by Bainespal »

In hugolib.h, the NewMessages routine appears to be a stub intended to be replaced in the game code so that the user can customize specific parser messages.

Code: Select all

routine NewMessages(r, num, a, b)       ! The NewMessages routine may be
{                                       ! replaced, and should return true
	return false                    ! if a replacement message <num>
&#125;                                       ! exists for routine <r>
I'm trying to modify the third message for the CheckReach routine (here's the code from Message):

Code: Select all

	case &CheckReach
	&#123;
		select num
		case 1
		&#123;
			print "Except that "; The&#40;parent&#40;a&#41;&#41;; \
				MatchPlural&#40;parent&#40;a&#41;, "has", "have"&#41;; \
				" "; The&#40;a&#41;; "."
		&#125;
		case 2
		&#123;
			print "Except that "; The&#40;parent&#40;a&#41;&#41;; \
				MatchPlural&#40;parent&#40;a&#41;, "doesn't", "don't"&#41;; \
				" want to give "; The&#40;player, true&#41;; \
				" "; The&#40;a&#41;; "."
		&#125;
		case 3&#58;  print CThe&#40;player&#41;; " can't reach "; The&#40;a&#41;; \
				" from "; The&#40;parent&#40;player&#41;&#41;; "."
	&#125;
I want to replace case 3, so I tried

Code: Select all

replace NewMessages&#40;CheckReach, 3&#41;
  &#123;  &#91;My modification here.&#93;  &#125;
in my code, but I get errors, regardless as to whether I try "NewMessages(CheckReach, 3)" or "NewMessages(&CheckReach, 3)".

I actually haven't tried to create a different message in place of the library message yet, because I haven't figured out how to do what I want it to (de-capitalize room names). But I can't experiment to try to do that until I can successfully replace the message.

Johnny
Posts: 36
Joined: Sat Oct 15, 2005 4:30 pm
Location: Humble, Texas

Post by Johnny »

You want to do something like this:

Edit: Roody_Yogurt rools, I drool.

Code: Select all

replace NewMessages&#40;r, num, a, b&#41;
&#123;
    select r

    case &CheckReach
    &#123;
        select num
        case 3
        &#123;
            !!! Your changes go here.
            return true
        &#125;
    &#125;

    return false
&#125;

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

Post by Bainespal »

Yes, that works. Thanks! :)

Johnny
Posts: 36
Joined: Sat Oct 15, 2005 4:30 pm
Location: Humble, Texas

Post by Johnny »

You're welcome. Happy Hugo'ing!

Post Reply