How to determine the number of animals at the specified coordinates

  • 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 comminuty!

    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.

asdf

Member
Feb 4, 2017
13
0
0
42
I used a translator.

The number of cattle will continue to be zero when coded below.
What should I do?

%{;;s}% is #


code_language.skript:
options:
    prefix: &eAnimal&f>
   
command /animal [<text>]:
    permission: lom.op
    trigger:
        if arg-1 is not set:
            send "{@prefix} /animal wand &c-> &fGive a wand."
            send "{@prefix} /animal check &c-> &fcheck number of animal"
        else if arg-1 is "wand":
            set {_wand} to feather named "&cAnimal Check Wand" with lore "Left click: select pos %{;;s}%1||Right click: select pos %{;;s}%2"
           
            give 1 of {_wand} to player
           
            send "{@prefix} Left click: select pos %{;;s}%1"
            send "{@prefix} Right click: select pos %{;;s}%2"
        else if arg-1 is "check":
            if {animalcheck.pos1} is not set:
                send "{@prefix} please select pos %{;;s}%1"
            else if {animalcheck.pos2} is not set:
                send "{@prefix} please select pos %{;;s}%2"
            else:
                set {_animals} to 0
                loop all entities:
                    set {_loc} to loop-entity's location

                    set {_animals} to number of cows in {animalcheck.pos1} and {animalcheck.pos2}
                send "Number of animals : %{_animals}%"
               
                delete {animalcheck.pos1}
                delete {animalcheck.pos2}
               
on leftclick:
    if player has permission "lom.op":
        set {_wand} to feather named "&cAnimal Check Wand" with lore "Left click: select pos %{;;s}%1||Right click: select pos %{;;s}%2"
        if player's tool is {_wand}:
            cancel event
            set {_click} to event-location
            if {_click} is not set:
                stop
            else:
                cancel event
                set {animalcheck.pos1} to event-location
                send "{@prefix} First position set to %event-location%"
               
on rightclick:
    if player has permission "lom.op":
        set {_wand} to feather named "&cAnimal Check Wand" with lore "Left click: select pos %{;;s}%1||Right click: select pos %{;;s}%2"
        if player's tool is {_wand}:
            cancel event
            set {_click} to event-location
            if {_click} is not set:
                stop
            else:
                cancel event
                set {animalcheck.pos2} to event-location
                send "{@prefix} Second position set to %event-location%"
 
You don't need to use a variable like {;;s} to insert #, you can just put in two in a row, for example you can do "##1" to show #1.

You'll need a somewhat more involved solution for this, I don't think there's a simple effect to count the number of entities in a square box. You'll need to compare their coordinates individually (X, Y, and Z) to see if they're between the coordinates of your selected box.
 
Status
Not open for further replies.