Author Topic: baffling 'function not found' error  (Read 5647 times)

Offline detah

  • BFF
  • ***
  • Posts: 190
  • Ruler of 2D
    • View Profile
baffling 'function not found' error
« on: March 07, 2008, 10:38:02 am »
This is regarding a room in LPMUD v3.2.9-dev.438.

I have some code to let the player type 'lift slab' to lift a slab in the room. To do so, I created an addaction for lift. However, when the player types 'lift slab' it generates an error:
Code: [Select]
function lift1 not found.
program: , object: players/detah/gornak/room/hhhhh line 0
Here is the room file from the top of the file to the end of the init fun. [I do not wish to show the whole file because this area is going on a live mud shortly.]
Code: [Select]
#include <prop/room.h>
#include <worlds.h>
#include "/players/detah/defs.h"
inherit "/complex/room";
int SLAB_LIFTED, HANGMAN_PRESENT;

reset() {
   ::reset();
     SLAB_LIFTED=0;
     HANGMAN_PRESENT=1;
}

init() {
  ::init();
     add_action("move1","move");
     add_action("push1","push");
     add_action("lift1","lift");
     add_action("lift1","take"); //changed from take1
     add_action("get1","get");
     add_action("pick1","pick");
     add_action("pick1","pull");
     add_action("exa1","'");
     add_action("exa1","exa");
     add_action("exa1","examine");
     add_action("debug1","debug1");
     if(notify_leave(this_player())) {
       SLAB_LIFTED=1;
       return 1;
     }
}
I have tried dozens of things to 'fix' this error. I tried changing functions around. Renaming functions. Moving ifs around. Commenting out stuff. Here is the latest incarnation of the lift1 function.
Code: [Select]
lift1(str) {
    if(!str) {
      write("Lift what?\n");
      return 1;
    }
    if(str!="slab") {
      write("Lift what?\n");
      return 1;
    }
    if(str=="slab") {
      if(this_player()->query_str() < XX) {  //number commented out to protect the innocent
        write("The slab does not budge. You are not strong enough to lift the "+
              "slab. Try again when you are stronger.\n");
        return 1;
      }
      if(SLAB_LIFTED==1) {
        write("The slab is already lifted.\n");
        return 1;
      }
      if(SLAB_LIFTED==0) {
        write("You lift the slab with ease.\n");
        SLAB_LIFTED==1;
       return 1;
      }
    }
}     
I am baffled. Anyone have a suggestion?

Offline Nulvect

  • BFF
  • ***
  • Posts: 127
    • View Profile
Re: baffling 'function not found' error
« Reply #1 on: March 07, 2008, 12:05:02 pm »
Try prototyping the functions your add_action will reference. That is, somewhere around your global vars just add lines like
Code: [Select]
int lift1(string);
I always have to do that on mudos.

Offline chaos

  • BFF
  • ***
  • Posts: 291
  • Job, school, social life, sleep. Pick 2.5.
    • View Profile
    • Lost Souls
Re: baffling 'function not found' error
« Reply #2 on: March 10, 2008, 12:57:25 pm »
Do the other add_action()s work -- is lift1() the only one that fails?

Offline chaos

  • BFF
  • ***
  • Posts: 291
  • Job, school, social life, sleep. Pick 2.5.
    • View Profile
    • Lost Souls
Re: baffling 'function not found' error
« Reply #3 on: March 10, 2008, 12:59:12 pm »
If so, I can think of one scenario that would cause that... one of your header files has a macro #define lift1 something_else.

Offline detah

  • BFF
  • ***
  • Posts: 190
  • Ruler of 2D
    • View Profile
Re: baffling 'function not found' error
« Reply #4 on: March 19, 2008, 01:06:01 pm »
Thank you all for your suggestions. It was indeed the lack of prototype functions. By inserting prototype functions, that solved about a dozen issues in other files also. Thanks, Nulvect.

-Detah