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.

Module Timed Think Function

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

Module Timed Think Function

Post by rrc55 »

I want to write a command independent mod function that performs a task at a regular interval. How do I export it to the core? Is there a better way? Thank you.
r
rrc55
Voice
Posts: 29
Joined: Wed Mar 11, 2009 9:33 am

Post by rrc55 »

I figured it out in case anyone is interested.

Code: Select all

void ecgn_test(void)
{
	dprintf(DP_SERVER, "PRIVMSG %s :TESTING\n", "#ecgn");
}

char *ecgn_start(Function *func_table)
{
	global = func_table;
	module_register(MODULE_NAME, ecgn_table, 1, 2);
	if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 3)))
		return "This module requires irc 1.3 or later.";
	if (!module_depend(MODULE_NAME, "eggdrop", 108, 0))
		return "This module requires eggdrop1.8 or later.";

	add_hook(HOOK_MINUTELY, (Function) ecgn_test);

	add_builtins(H_pub, stat_cmd);
	return NULL;
}
The key here is the add_hook() function. This will call my ecgn function every minute without having to bind it to a command. This is exactly what I wanted.

Hope this helps someone.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

And why would you bother with this if there's time or cron binds?
Once the game is over, the king and the pawn go back in the same box.
r
rrc55
Voice
Posts: 29
Joined: Wed Mar 11, 2009 9:33 am

Post by rrc55 »

What are those and how do you use them?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

If you don't have TCL Commands file then grab it from here and then look at the bind cron or bind time.
Once the game is over, the king and the pawn go back in the same box.
r
rrc55
Voice
Posts: 29
Joined: Wed Mar 11, 2009 9:33 am

Post by rrc55 »

Thanks.
Post Reply