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

Implement actions and triggers! #1016

Merged
merged 5 commits into from
Jul 9, 2022
Merged

Implement actions and triggers! #1016

merged 5 commits into from
Jul 9, 2022

Conversation

Pablete1234
Copy link
Member

@Pablete1234 Pablete1234 commented Jun 16, 2022

What are actions? Actions are the next generation of kits. Kits in fact, are a type of action.

Why not just use kits? Kits are always player-scoped, this is not ideal for all features, there's alot of interoperability between kits and actions so this shouldn't be an issue (kits can have player-scoped actions, and kits themselves are a type of player-scoped action), and actions can be scoped-out or scoped-in.

This is mainly a stepping stone towards #881, it is also laying down the ground for #1001, as those will no longer be kits, and will just be actions instead.

Currently the only implemented actions are action (an action with other actions inside), message, switch-scope, and kit

  <kits>
    <kit id="spawn">
      <item slot="0" unbreakable="true" material="stone sword"/>
      <action>
        <message text="You were given a kit!"/>
      </action>
    </kit>
  </kits>
  <actions>
    <action id="do-stuff" scope="player">
      <message text="Sent a chat message!"/>
      <switch-scope outer="player" inner="team">
        <message text="All players on the team are getting this one!"/>
        <switch-scope outer="team" inner="player">
          <kit id="spawn"/>
        </switch-scope>
      </switch-scope>
      <kit>
        <item>diamond</item>
      </kit>
    </action>
    <message id="standalone-text" text="This is a standalone text trigger"/>
    <trigger filter="some-dynamic-filter" action="do-stuff" scope="player"/>
    <trigger filter="another-dynamic-filter" action="standalone-text" scope="player"/>
  </actions>

Update:
triggers have been renamed to actions
when has been renamed to trigger

It makes more sense that "actions" are "triggered" by triggers. The triggers listen for dynamic filters. this was feedback from @Pugzy

Signed-off-by: Pablete1234 <pabloherrerapalacio@gmail.com>
Signed-off-by: Pablete1234 <pabloherrerapalacio@gmail.com>
@Pablete1234
Copy link
Member Author

Pablete1234 commented Jun 19, 2022

Implemented bound inference, so specifying the scope of a trigger isn't required if it can be infered from the parent, the biggest effect is switch-scope only requires inner, as long as the outer can be derived.

Example where it can be infered:

  <actions>
    <actionid="trigger-id" scope="player">
      <switch-scope inner="match">
        <message text="This is match scoped! Converted from player to match"/>
      </switch-scope>
    </action>
  </actions>

Example where it can NOT be inferred (outer is required here, or else it won't work):

  <action>
    <switch-scope id="scope-switch" outer="player" inner="match">
      <message text="This is match scoped! Converted from player to match"/>
    </switch-scope>
    <action id="trigger-id" scope="player">
      <action id="scope-switch"/> <!-- This references the trigger defined above -->
    </action>
  </actions>

Additionally, now the Kit interface fully implements Trigger, because at the end, kits are just a trigger that is scoped to a player. This means you can just define a kit inside a trigger instead of being forced to reference one.

  <action>
    <kit id="a-kit">
      <item>diamond</item>
    </kit>
    <trigger filter="some-filter" action="a-kit" scope="player">
  </action>

In this situation, the trigger is working exactly equally as a <lend kit="a-kit" filter="some-filter"/> would.

Also, Actions now support triggering and untriggering, in the same way removable kits work.

@Pablete1234 Pablete1234 changed the title Implement triggers! Implement actions and triggers! Jun 20, 2022
Signed-off-by: Pablete1234 <pabloherrerapalacio@gmail.com>
Signed-off-by: Pablete1234 <pabloherrerapalacio@gmail.com>
@Pablete1234 Pablete1234 added the ready PR is ready to merge label Jul 7, 2022
@Electroid Electroid merged commit e9a2d1d into dev Jul 9, 2022
@Electroid Electroid deleted the triggers branch July 9, 2022 15:34
@RuedigerLP RuedigerLP mentioned this pull request Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PR is ready to merge
Development

Successfully merging this pull request may close these issues.

3 participants