• 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

Question - How do I use a 'macro style variable' in a plugin?

redraj

New member
I'm trying to pull some basic information that is already done by a plugin, into another plugin.

How do I refer/reference/use that value?

For example, I want to pull information already gathered by Those other guys who we never mention around Maskoi

into another plugin. Is there a way to just use ${NetBots[Name].Level} without having to cut/paste the entire netbots code into the plugin I'm making?

EDITED FOR PROFANITY
 
It depends on what you are trying to do. You can reference other plugin shared data if you know the actual variable names or you can pass what you want to the MQ2 Parser and use what is returned.

From within your plugin you can pass ${NetBots[Name].Level} to the parser and you will get back the same data you would get back in a macro.

ParseMacroData() is what you should look for in the MQ2 Source.

Here is an example used in MQ2Cast that may help.

Look at the calls to the Evaluate Routine.

Rich (BB code):
void StopHandle()
{
   if(StopF==FLAG_REQUEST) {
      if(DEBUGGING) {
         WriteChatf("[%I64u] MQ2Cast:[Immobilize]: Request.",GetTickCount642());
      }
      StopM=GetTickCount642()+DELAY_STOP;
      StopF=FLAG_PROGRESS1;
      StopE=DONE_PROGRESS;
   }
   if(Evaluate("${If[${Stick.Status.Equal[ON]},1,0]}")) {
      if(DEBUGGING) {
         WriteChatf("[%I64u] MQ2Cast:[Immobilize]: Stick Pause Request.",GetTickCount642());
      }
      Stick("pause");
      MoveS=FLAG_PROGRESS1;
   }
   if(Evaluate("${If[${Bool[${FollowFlag}]},1,0]}")) {
      if(DEBUGGING) {
         WriteChatf("[%I64u] MQ2Cast:[Immobilize]: AdvPath Pause Request.",GetTickCount642());
      }
      Execute("/varcalc PauseFlag 1");
      MoveA=FLAG_PROGRESS1;
   }
   if(Evaluate("${If[${AdvPath.Following} && !${AdvPath.Paused},1,0]}")) {
      if(DEBUGGING) {
         WriteChatf("[%I64u] MQ2Cast:[Immobilize]: MQ2AdvPath Pause Request.",GetTickCount642());
      }
      FollowPath("pause");
      MoveF=FLAG_PROGRESS1;
   }
   if(Evaluate("${If[${AdvPath.Playing} && !${AdvPath.Paused},1,0]}")) {
      if(DEBUGGING) {
         WriteChatf("[%I64u] MQ2Cast:[Immobilize]: MQ2AdvPath Pause Request.",GetTickCount642());
      }
      Path("pause");
      MoveP=FLAG_PROGRESS1;
   }
   if(Immobile=Moving()) {
      if(DEBUGGING) {
         WriteChatf("[%I64u] MQ2Cast:[Immobilize]: Complete.",GetTickCount642());
      }
      StopF=FLAG_COMPLETE;
      StopE=DONE_SUCCESS;
   }
   if(GetTickCount642() > StopM) {
      WriteChatf("[%I64u] MQ2Cast:[Immobilize]: Aborting!",GetTickCount642());
      StopF=FLAG_COMPLETE;
      StopE=DONE_ABORTED;
      return;
   }
   if(StopF==FLAG_PROGRESS1) {
      StopF=FLAG_PROGRESS2;
      if(Speed()!=0.0f) {
         MQ2Globals::ExecuteCmd(FindMappableCommand("back"),1,0);
         MQ2Globals::ExecuteCmd(FindMappableCommand("back"),0,0);
      }
   }
}

Here is the actual Evaluate routine:

Rich (BB code):
long Evaluate(PCHAR zFormat, ...)
{
   char zOutput[MAX_STRING]={0}; va_list vaList; va_start(vaList,zFormat);
   vsprintf(zOutput,zFormat,vaList);
   if(!zOutput[0]) {
      return 1;
   }
   ParseMacroData(zOutput);
   return atoi(zOutput);
}
 
Yes, the ParseMacroData(string); then atoi(string) is the method for accessing a plugins output. if you want to match its input you need to reference the actual process within the plugin. So if i want to know if i am connected to eqbc from another plugin:

Rich (BB code):
bool EQBCConnected() {
  typedef WORD (__cdecl *fEqbcIsConnected)(VOID);
  PMQPLUGIN pLook=pPlugins;
  while(pLook && strnicmp(pLook->szFilename,"mq2eqbc",8)) pLook=pLook->pNext;
  if(pLook)
	if(fEqbcIsConnected checkf=(fEqbcIsConnected)GetProcAddress(pLook->hModule,"isConnected"))
	  if(checkf()) return true;
  return false;
}

Then i can just:
Rich (BB code):
if(EQBCConnected())
    dothis
 
Question - How do I use a 'macro style variable' in a plugin?

Users who are viewing this thread

Back
Top
Cart