• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

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

redraj

New member
Joined
Feb 1, 2015
RedCents
571¢
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);
}
 
I think this is what I'm looking for, thank you kindly! I'll play with it tonight.
 
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