Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to fetch job info? #5122

Closed
YQL-Skorpion opened this issue Nov 25, 2022 · 8 comments
Closed

Is there a way to fetch job info? #5122

YQL-Skorpion opened this issue Nov 25, 2022 · 8 comments
Labels

Comments

@YQL-Skorpion
Copy link

Is there a job analogue of data.ShortName? In particular I'm thinking about writing a few role-partner flex triggers, so it'd be extremely helpful if I can define a trigger based on whether conditions like ['SMN', 'BLM', 'RDM'].includes(job_from_matches_target) evaluate to true, signaling whether I flex for my caster. Sorry in advance if the answer is somewhere in documentation but I failed to find it.

@xiashtra
Copy link
Contributor

data.job, from job.d.ts might give you what you're looking for.

@YQL-Skorpion
Copy link
Author

YQL-Skorpion commented Nov 26, 2022

It seems that data.job returns my job regardless; for example below is a test code used on o7n/s prey:

{
        id: 'O7S Prey',
        type: 'HeadMarker',
        netRegex: { id: '001E' },
        alarmText: (data, matches, output) => {
          let preyName = data.ShortName(matches.target); /* does its job correctly */
          let preyJob = data.job; /* always outputs my job */
          return output.text({ name: preyName, job: preyJob });
        },
        outputStrings: {
          text: {
            en: 'Prey: ${name} (on job ${job})',
          },
        },
},

@trim21
Copy link
Contributor

trim21 commented Nov 26, 2022

There is no simple way to do this but it's doable.

you can use data.party to get all player info in your party。

you can find details here

https://github.com/quisquous/cactbot/blob/main/types/data.d.ts#L26

and here

https://github.com/quisquous/cactbot/blob/main/resources/party.ts#L17

I'm doing something like this:

(It's typescript)

{
  ...
  run(data) {
    if (data.nameToJobID === undefined) {
      data.nameToJobID = Object.fromEntries(data.party.details.map((v) => [v.name, v.job]));
    }
  ...
  }
}

@trim21
Copy link
Contributor

trim21 commented Nov 26, 2022

data.ShortName return an alias, not job info.

But you can use this script to make it return job name ( or maybe you already have but you don't know )

#3000 (comment)

(not a good idea)

@YQL-Skorpion
Copy link
Author

YQL-Skorpion commented Nov 26, 2022

I greatly appreciate the help.

Using the references (in particular data.party) I ended up writing something like this, and I think it's working so far!

{
   ...
   let preyName = data.ShortName(matches.target);
   var preyJob = '';
   data.party.details.forEach((p) =>
      { if (p.name === matches.target) preyJob = data.party.jobName(p.name); } );
   return output.text({ name: preyName, job: preyJob });
}

@trim21
Copy link
Contributor

trim21 commented Nov 26, 2022

and as we are discussing this, I think we could add a method (like data.info(name: string) -> null | PlayerInfo{ jobID: job; ... } for team player to get info of player @quisquous

@quisquous
Copy link
Owner

and as we are discussing this, I think we could add a method (like data.info(name: string) -> null | PlayerInfo{ jobID: job; ... } for team player to get info of player @quisquous

Is this just data.party.jobName(name: string)?

@trim21
Copy link
Contributor

trim21 commented Nov 27, 2022

maybe return a object with job id and job name and role?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants