• Hail, we're RedGuides. We want you to play six (yes, 6!) EverQuest characters at once. We have scripts and a friendly community to help, please join our playstyle and say hello! 👋
  • We've added LLM sections to our Terms & Rules and Resource Rules, for everyone's sanity & in-game safety.
    Read more
    a. Do not replace your voice with an LLM. This goes for your posts and your scripts. Drafting and editing with a tool is fine, but don't take you out of what you share.
    b. Do not replace your EQ character's voice with an LLM. We don't want scripts that speak over /ooc, /shout or other public channels. This has been an unwritten rule that's kept casino scripts off the site for decades, but we're now compelled to make it clear: keep automated communication private.

    Why Does RG Review Scripts?
    Nearly every LLM-written Lua script we see is making your character do impossible things, and rarely in a way that's beneficial to you. We've seen heavy server hammering, /target over impossible distances when /nav spawn would passively accomplish the same thing, a spawn search that fires 20+ times per second, and other pointless actions that are likely annoying GMs.

    You are welcome to use LLMs as a tool to structure, draft, and edit your work, but please read critically before hitting /lua run

Bug - How can we log the LastCommand prior to an exit or crash?

Redbot

💻❤️
Moderator
Commits
623
@Denethor asked me about logging the last command from a macro, and I'm a little stumped on how this can be done. Any solution we come up with just crashes.

Here's a macro replicating the crash. This happens with both /mqlog and /mlog
TestExit.mac
Code:
sub Main
    /declare blnMacroComplete int outer 0
    /echo TestExit Macro
    /echo Ending in 3 sec...
    /delay 1s
    /echo Ending in 2 sec...
    /delay 1s
    /echo Ending in 1 sec...
    /delay 1s

:OnExit
    /if ( !${blnMacroComplete} && !${MacroQuest.LastCommand.Find[/end]} && !${MacroQuest.LastCommand.Find[/camp]}) {
        /echo Exiting
        /mqlog Exiting
        /echo LastCMD: ${MacroQuest.LastCommand}
        /mqlog LastCMD: ${MacroQuest.LastCommand}
    }
/return

And here's what appears in the Logs/charname_server.log file:

Code:
[2020/06/14 16:51:46] [MQ2] TestExit Macro

[2020/06/14 16:51:46] [MQ2] Ending in 3 sec...

[2020/06/14 16:51:47] [MQ2] Ending in 2 sec...

[2020/06/14 16:51:48] [MQ2] Ending in 1 sec...

[2020/06/14 16:51:49] [MQ2] Exiting

[2020/06/14 16:51:49] [MQ2] LastCMD: /mqlog Exiting

[2020/06/14 16:51:49] Syntax Error: /mqlog LastCMD: ${MacroQuest.LastCommand} Line:16 in testexit.macNewLength 40 was greater than BufferSize - addrlen 29 in ParseMacroData, did you try to read data that exceeds 2048 from your macro?
 
I thought the OnExit was only called when the /end was called?

Anything included after that label will be called whenever an /endmacro
command is issued. To use this feature, the label must be at the end
of your 'Sub Main' function and end with a /return. Please note that
this is NOT required of macros, so no macros will have to be altered
unless you wish to take advantage of this feature. (See my posting
on the messageboards for an example of how to use this.)
 
Okay, so store it to a variable and compare/echo that variable. I can do that for a work around. Trying to wrap my head around the explanation (I understand recursion as a concept, I'm not understanding how I'm triggering it yet. Will re-read when I have more time to focus.)


Regardless, be good if there was an exception handler / catch for that, so it doesn't cause a CTD.
 
/echo LastCMD: ${MacroQuest.LastCommand}
/mqlog LastCMD: ${MacroQuest.LastCommand}


When you mqlog the LastCMD it is evaluated as:
/mqlog LastCMD: /echo LastCMD: ${MacroQuest.LastCommand}

So when you parse that it is:
/mqlog LastCMD: /echo LastCMD: /echo LastCMD: ${MacroQuest.LastCommand}

so when you pare that it is:
/mqlog LastCMD: /echo LastCMD: /echo LastCMD: /echo LastCMD: ${MacroQuest.LastCommand}

etc.
 
Doing something recursively usually has a base case, or a reason to stop doing the recursive function such as each new call to itself having altered information being passed to it. There are problems that can be solved with recursive function calls, but it can also be a recipe for disaster. If you have a recursive call that infinitely calls itself, such as in Knightly description you end up with stack overflow. Each new call is reserving some amount of space on the stack. The stack quickly gets filled with the calls and you run out of space on the stack to store information, and then everything goes down in fire and flames.

In the case of MacroQuest.LastCommand calling itself, it becomes infinite recursion. Storing the information to a variable and then using that variable for the comparison is the way I had ultimately decided was a work around until a fix was generated for it. In a way, it's probably the better way to do it anyway if you plan to call it multiple times. Multiple times can be misleading. For example ${Select[${MacroQuest.LastCommand}, /end, /endm, /endmac, /endmacro]} would be checking ${MacroQuest.LastCommand} for each one of the ${Select's entries. No differently than doing it as a bunch of /if (${MacroQuest.LastCommand.Equal[/end]} || ${MacroQuest.LastCommand.Equal[/endm]} etc etc)
 
Bug - How can we log the LastCommand prior to an exit or crash?

Users who are viewing this thread

Back
Top
Cart