LUA callback handler menu

Shout-Out

User Tag List

Results 1 to 3 of 3
  1. #1
    Master674's Avatar Elite User
    Reputation
    487
    Join Date
    May 2008
    Posts
    578
    Thanks G/R
    2/23
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    LUA callback handler

    <something used to be here... its gone now>
    Last edited by Master674; 10-15-2012 at 12:54 PM.

    LUA callback handler
  2. #2
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand you correctly you want something like this
    Code:
    lua_Debug d = {0};
    int call_depth = 1; // adjust as needed, or loop while incrementing it until lua_getstack returns 0 for a full stack trace
    lua_getstack(l, call_depth, &d);
    lua_getinfo(l, "Sln", &d);
    if(d.short_src[0] == '[') // lazy hack. C callbacks also start with '[' but since we aren't checking call depth 0 it's okey. callbacks normally don't call other callbacks directly.
    	std::wcout << "callback called from dostring(\"" << d.source << "\")" << std::endl;
    else
    	std::wcout << "callback called from file: '" << d.source << "' function: '" << (d.name ? d.name : "(none)") << "' line: " << d.currentline << std::endl;
    Last edited by _Mike; 05-11-2012 at 10:43 PM.

  3. #3
    Sirmabus's Avatar Active Member
    Reputation
    34
    Join Date
    Jun 2008
    Posts
    69
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your question is fairly nebulous but I think I see what you want to do.

    First "SetTimedEvent()" is not a known/standard API function.
    Are you talking about this?: Simple C++ Timer Wrapper - CodeProject
    At any rate one can with a degree of certainty assume that your SetTimedEvent() calls some kind of callback function after a given time or even periodically.

    You can run any number of Lua instances at any given time only limited by how many threads and memory you have on your platform.
    What you'll have to do from your callback is create a Lua state for each instance using the C API like this
    Code:
    lua_State *L = luaL_newstate()
    Then load the Lua libs if need, load the text file in then pcall it.

    Code:
    luaL_openlibs(L);
    luaL_loadfile(L, szFile);
    lua_pcall(L, 0, LUA_MULTRET, 0);
    lua_close(L);
    Look at the Lua console source ("Lua.c" I think) to see how it is done there for a more detailed example.

    Note each Lua state will be in it's own context. If you need to share context between them then you will need to make a custom setup for it.
    There are some existing setups including a muti-threaded Lua version, etc., on LuaForge and some other sights; just Google for it.
    If you need additional functionality (what you mean by Lua callbacks?) it's pretty easy to add with a DLL, or using LuaJIT you might be able to use it's FFI library to directly interface with API calls, etc.

    Looks to me you need to research the Lua API in detail plus look around some (again Google for it).

Similar Threads

  1. [Question] Lua Callback: Return table of values
    By DrakeFish in forum WoW Memory Editing
    Replies: 6
    Last Post: 06-18-2011, 10:44 PM
  2. Replies: 10
    Last Post: 02-13-2011, 01:21 AM
  3. Call Lua callback in DLL cause some Error
    By rafaelcn in forum WoW Memory Editing
    Replies: 3
    Last Post: 08-04-2010, 03:32 AM
  4. The Lua Callback OffSet0x in BabBot?
    By nemody in forum WoW Memory Editing
    Replies: 1
    Last Post: 06-20-2010, 10:22 PM
  5. [WoW] [3.0.9] [Info] LUA Callbacks
    By Cypher in forum WoW Memory Editing
    Replies: 46
    Last Post: 04-24-2009, 02:45 AM
All times are GMT -5. The time now is 07:07 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search