Page 1 of 1

How to replace NewMessages

Posted: Thu Aug 12, 2010 7:54 am
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.

Posted: Thu Aug 12, 2010 3:02 pm
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;

Posted: Sat Aug 14, 2010 6:33 am
by Bainespal
Yes, that works. Thanks! :)

Posted: Sun Aug 15, 2010 7:18 am
by Johnny
You're welcome. Happy Hugo'ing!