This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Mod Function Arguments

Discussion of Eggdrop's code and module programming in C.
Post Reply
r
rrc55
Voice
Posts: 29
Joined: Wed Mar 11, 2009 9:33 am

Mod Function Arguments

Post by rrc55 »

Hi noob here working on my first mod.

I can kind of see how commands are added to the bind table but how does eggdrop know what arguments to pass to my functions when the command is issued?

Thanks.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

If you are referring to the different bindings, each type of binding has a specific set of arguments that the called C function is expected to accept. All in all, very much alike the normal bind command.

Perhaps an example taken from the channels module, the .+chan dcc chat command:

Code: Select all

/* The actual C function that will be mapped to the tcl namespace 
 * Compared to the tcl "bind dcc", having "handle idx text" as arguments
 */
static void cmd_pls_chan(struct userrec *u, int idx, char *par)
{
  char *chname;
  struct chanset_t *chan;
...
}

/* Now to map the function into a dcc partyline command
 * DCC CHAT COMMANDS
 *
 * Function call should be:
 *    int cmd_whatever(idx,"parameters");
 *
 * NOTE: As with msg commands, the function is responsible for any logging.
 */
static cmd_t C_dcc_irc[] = {
...
  {"+chan",    "n",     (Function) cmd_pls_chan,   NULL},
...
  {NULL,       NULL,    NULL,                      NULL}
};
The C_dcc_irc array is then used with add_builtins and del_builtins, which is then responsible for creating the tcl command and mapping it to your function, and register the proper binding.

There are many kinds of "builtins", and each one has it's own setup of expected argument list, so you'll have to check/dig through the code to see what's needed for your kind of command/binding/builtin
NML_375
r
rrc55
Voice
Posts: 29
Joined: Wed Mar 11, 2009 9:33 am

Post by rrc55 »

Got it thanks.
Post Reply