Alternate Entity Targetting System

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

CormanYT

Active Member
Jan 6, 2018
122
5
18
SKRIPT VERSION: 2.3.2 (since I'm too lazy to update)
SKRIPT AUTHOR: Bensku: Leading Continuation of Skript
MINECRAFT VERSION: 1.12.2

Hello, I'm Corman. I currently face an issue on how to make an alternative entity targeting system.
Code:
on entity target:
    if entity's name contains "%entity's target%":
        cancel event
        delete entity's target
This is the code I've had with NO ERRORS. However, the code had errors when I tried to make an alternative targeting system. My goal is to make an entity target another entity which meets these conditions:
- The entity is NOT a player
- The entity is in a radius of 50 from the first entity
- The entity is a mob
- The entity does not contain the first part of its the main entity's name
(This means if it is "CormanYT Doubler" it cannot target "CormanYT Skeleton")
- If the entity is a villager and there are other entities to choose, pick those entities first.

This might seem a bit confusing to people who don't get what I'm trying to accomplish, so here's some example code that shows what I'm trying to accomplish (although it isn't working code).

Code:
on entity target:
    if entity's name contains "%entity's target%":
        cancel event
        delete entity's target
        loop all entities in radius 50 of entity:
            loop-entity isn't a player
            set {_this::*} to entity's name split at " "
            loop-entity's name doesn't contain "%{_this::2}%"
            loop-entity is a mob
            if loop-entity is a villager:
                set {_villager} to loop-entity
            else:
                set {_entity} to loop-entity
        if {_entity} is set:
            set entity's target to loop-entity
        else if {_villager} is set:
            set entity's target to loop-entity

I got no help from the Skript Discord, tried as much as I could on my own, and there's no really anything on the docs. If someone could help me, please do. I can explain this further if I have to.
 
Status
Not open for further replies.