Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.
Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.
This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
-
dx876234
- Posts: 188
- Joined: Sat Jul 24, 2010 6:13 am
#1
Post
by dx876234 » Wed Apr 10, 2013 1:02 pm
I suggest the atExit() function is modified to return the old callback, this should be done in all callback function. This would enable chaining.
-dx
Code: Select all
function atExit(func)
if( type(func) ~= "function" and type(func) ~= "nil" ) then
local err = "Error: Non-function type passed to atExit() where a function is expected.";
setTextColor(cli.yellow);
error(err, 2);
return;
end
local ofunc = __EXIT_CALLBACK
__EXIT_CALLBACK = func;
return ofunc
end
-
Administrator
- Site Admin
- Posts: 5329
- Joined: Sat Jan 05, 2008 4:21 pm
#2
Post
by Administrator » Thu Apr 11, 2013 10:51 am
I'm not sure if I agree with this. The default callback just prints a line of text and that's it; there would really be no reason to need to 'chain' it. Rather than setting multiple callbacks in your code, you should combine them into one. You could also just use function hooking to accomplish the same thing.
-
dx876234
- Posts: 188
- Joined: Sat Jul 24, 2010 6:13 am
#3
Post
by dx876234 » Fri Apr 12, 2013 6:57 am
My specific issue is that rombot uses atexit internally:
Code: Select all
function exitCallback()
releaseKeys();
end
atExit(exitCallback);
I would like to hook onto it as well in my script but would prefer not to be dependent on the internals of the bot. But its not a biggie, I can call the exitCallback() from my own callback.
-dx
-
Administrator
- Site Admin
- Posts: 5329
- Joined: Sat Jan 05, 2008 4:21 pm
#4
Post
by Administrator » Fri Apr 12, 2013 2:34 pm
A hook would work, but you can also just do this:
Code: Select all
function my_exitCallback()
exitCallback();
-- Any additional code here
end
atExit(my_exitCallback);
-
dx876234
- Posts: 188
- Joined: Sat Jul 24, 2010 6:13 am
#5
Post
by dx876234 » Mon Apr 15, 2013 6:43 am
Ye, thats what I'm doing atm, problem is that this is a userfunction so what happens if another userfunction also needs to handle the exit or pause callback? Or a user uses it in his/her waypoint script? It would be nice to be able to subscribe to these events without having to hardcode.
Just my 5 cents
-dx
-
lisa
- Posts: 8332
- Joined: Tue Nov 09, 2010 11:46 pm
- Location: Australia
#6
Post
by lisa » Mon Apr 15, 2013 7:46 am
I use this in a userfunction.
Code: Select all
function logtrace()
errorCallback()
logInfo(player.Name,debug.traceback(),true,"crashes")
end
atError(logtrace)
-
dx876234
- Posts: 188
- Joined: Sat Jul 24, 2010 6:13 am
#7
Post
by dx876234 » Mon Apr 15, 2013 8:27 am
I also use the atError in an userfunction Lisa, I havent noticed any collitions yet but theyr there...
-dx
-
Administrator
- Site Admin
- Posts: 5329
- Joined: Sat Jan 05, 2008 4:21 pm
#8
Post
by Administrator » Mon Apr 15, 2013 4:52 pm
Really, that is something that should be handled by the main script. It would be best to register it as an event and have the script call it as the user requests.
What are you attempting to accomplish with the atExit() callback?
-
dx876234
- Posts: 188
- Joined: Sat Jul 24, 2010 6:13 am
#9
Post
by dx876234 » Wed Apr 17, 2013 6:30 am
I see your point, this prolly should be a task for the executing script.
I've started an Event Manager as an userfunction and will publish in rom userfunction section shortly. It will take over all event exits in MM and enable subscription of these, for compatibility w RoMBot I'm registering all its original callbacks as subscribed on their respective events. The userfunction also enables user defined events for other waypoints/userfunctions to define and subscribe to, as example I'm using player detection and mob detection.
best regard
DX
Who is online
Users browsing this forum: No registered users and 1 guest