DoString Trouble menu

User Tag List

Page 7 of 7 FirstFirst ... 34567
Results 91 to 96 of 96
  1. #91
    Shynd's Avatar Contributor
    Reputation
    97
    Join Date
    May 2008
    Posts
    393
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pretty sure the function would end up being declared at the global scope, but as long as you use a unique prefix to the function name, I don't see where the problem would be. It'd be the same as an AddOn declaring global functions, which they do all the time. You should be able to declare it once, then use and call it for the life of the lua instance.

    DoString Trouble
  2. #92
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by tanis2000 View Post
    Any of you guys tried passing your LUA input handler something different than a simple call to a function, like a block of script or a custom function definition? Is there any way to make that work?

    I was thinking about something amongst the line of:

    Code:
    function UseContainerItemByName(search)
      for bag = 0,4 do
        for slot = 1,GetContainerNumSlots(bag) do
          local item = GetContainerItemLink(bag,slot)
          if item and item:find(search) then
            UseContainerItem(bag,slot)
          end
        end
      end
    end
    Of course passing something like that whole piece of code inside a function won't work.. but what if we call FrameScript_Execute with a block of code that is something like:

    Code:
    function UseContainerItemByName(search)
      for bag = 0,4 do
        for slot = 1,GetContainerNumSlots(bag) do
          local item = GetContainerItemLink(bag,slot)
          if item and item:find(search) then
            UseContainerItem(bag,slot)
          end
        end
      end
    end
    MyInputHandler(UseContainerItemByName("Refreshing Spring Water"))
    Maybe that would work. I do not have access to my own stuff so I can't check it yet.. but would it work? Or would it corrupt the global LUA stuff as that function would end up being declared as global scope?
    You can just pass it all as one line.
    That's what I'm doing in the luretable LUA I wrote for Nesox. That's about ~28 lines of LUA compressed into one line.

    Code:
    Lua_DoString("for bag=0,4 do for slot=1,GetContainerNumSlots(bag)do local item=GetContainerItemLink(bag,slot)if item and item:find(search)then UseContainerItem(bag,slot)end end end")
    Rougly, with a string, you can just use this regex:
    Code:
    Regex reg = new Regex("\\s*");
    test.Replace(function, " ");
    I think it should work for compressing a multiline LUA function down to one line.

    EDIT: And yes, as Shynd said, once a function is declared it stays there until a reload of the UI.
    That means you can declare a global function when your bot loads, and be using that until WoW closes or the UI reloads.
    Last edited by MaiN; 06-23-2009 at 11:16 AM.
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  3. #93
    tanis2000's Avatar Active Member
    Reputation
    39
    Join Date
    Feb 2009
    Posts
    123
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by MaiN View Post
    You can just pass it all as one line.
    That's what I'm doing in the luretable LUA I wrote for Nesox. That's about ~28 lines of LUA compressed into one line.

    Code:
    Lua_DoString("for bag=0,4 do for slot=1,GetContainerNumSlots(bag)do local item=GetContainerItemLink(bag,slot)if item and item:find(search)then UseContainerItem(bag,slot)end end end end")
    Rougly, with a string, you can just use this regex:
    Code:
    Regex reg = new Regex("\\s*");
    test.Replace(function, " ");
    I think it should work for compressing a multiline LUA function down to one line.
    That's fine if you only need to do an action that does not return any values. But if, for example, I want to use a function similar to that one to check if I have the item, I can't pass that line to MyInputHandler as you can't pass a whole block of code to a function.. or at least to my function

  4. #94
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by tanis2000 View Post
    That's fine if you only need to do an action that does not return any values. But if, for example, I want to use a function similar to that one to check if I have the item, I can't pass that line to MyInputHandler as you can't pass a whole block of code to a function.. or at least to my function
    Just make yourself able to select what to return.
    I was talking about a function without any return btw.
    Lua("blah blah, kjasdjasd, test = blah", "test")
    so it will return test
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  5. #95
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone able to tell me what in my (I know its ugly :>) code is wrong? For some reason my wow keeps just closing when I use it.

    Code:
    void lua_dostring(string lstring, Process* proc)
    {
        DWORD_PTR lstring_mem  = proc->AllocateMemory(0x300);
        DWORD_PTR codecave     = proc->AllocateMemory(0x1024);
    
        proc->WriteMemString(lstring_mem, lstring);
    
        proc->WriteMemString(codecave, "\xB9");  // MOV ecx,
        proc->WriteMemDWORD(codecave+1, lstring_mem + lstring.length() - 1);
        proc->WriteMemString(codecave+5, "\xB8"); // MOV eax
        proc->WriteMemDWORD(codecave+6, lstring_mem); // Address of the string to execute
        proc->WriteMemString(codecave+11, "\x6A"); // push
        proc->WriteMemString(codecave+12, zerostring); // 0
        proc->WriteMemString(codecave+13, "\x50\x50\xB8"); // push eax  -> push eax -> mov eax
        proc->WriteMemDWORD(codecave+16, 0x49AAB0); // Function-address
        proc->WriteMemString(codecave+20, "\xFF\xD0\x83\xC4\xC\xC3"); // call eax -> add esp, 0xC -> retn
    
        proc->Suspend();
        proc->CreateThread(codecave);
        proc->WaitForThread();
        proc->Resume();
    
        proc->FreeMemory(lstring_mem);
        proc->FreeMemory(codecave);
    }
    The funny thing is wow often exits when I suspend its thread or create the RemoteThread. This never happens with any other application.
    Here is my implementation of those functions:

    Code:
    bool Process::Suspend()
    {
        if(SuspendThread(thread_handle) > 0)
            return false;
    
        return true;
    }
    
    bool Process::Resume()
    {
        if(ResumeThread(thread_handle) > 1)
            return false;
    
        return true;
    }
    
    void Process::CreateThread(DWORD_PTR address, LPVOID param)
    {
        RemoteThread = CreateRemoteThread(process_handle, NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(address), 0, 0, NULL);
    }
    
    void Process::WaitForThread()
    {
        WaitForSingleObject(RemoteThread, INFINITE);
    };
    Maybe someone is able to point me to my mistake. Thanks.

  6. #96
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would make a naked function and patch in your values and then copy it to the target process. CreateRemoteThread after you suspend it and then see if that works. Seems a lot more clean imo.

Page 7 of 7 FirstFirst ... 34567

Similar Threads

  1. Glider Trouble
    By Kirin in forum World of Warcraft General
    Replies: 3
    Last Post: 01-05-2007, 07:06 AM
  2. Glider trouble
    By Kirin in forum World of Warcraft Bots and Programs
    Replies: 0
    Last Post: 01-04-2007, 06:00 PM
  3. trouble finding .blp
    By yellowsn in forum WoW ME Questions and Requests
    Replies: 5
    Last Post: 11-23-2006, 12:06 AM
  4. Blizz is in some trouble. youll love this :)
    By WoWLegend in forum World of Warcraft General
    Replies: 23
    Last Post: 09-26-2006, 08:01 AM
  5. Idea to get people you dont like in trouble!!!
    By paypal in forum WoW Scam Prevention
    Replies: 10
    Last Post: 08-30-2006, 09:43 PM
All times are GMT -5. The time now is 11:14 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search