1. 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!


    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to determine the number of animals at the specified coordinates

Discussion in 'Skript' started by asdf, May 20, 2018.

Thread Status:
Not open for further replies.
  1. asdf

    asdf Member

    Feb 4, 2017
    Likes Received:
    I used a translator.

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

    %{;;s}% is #

    Code (Skript):
    1. options:
    2.     prefix: &eAnimal&f>
    4. command /animal [<text>]:
    5.     permission: lom.op
    6.     trigger:
    7.         if arg-1 is not set:
    8.             send "{@prefix} /animal wand &c-> &fGive a wand."
    9.             send "{@prefix} /animal check &c-> &fcheck number of animal"
    10.         else if arg-1 is "wand":
    11.             set {_wand} to feather named "&cAnimal Check Wand" with lore "Left click: select pos %{;;s}%1||Right click: select pos %{;;s}%2"
    13.             give 1 of {_wand} to player
    15.             send "{@prefix} Left click: select pos %{;;s}%1"
    16.             send "{@prefix} Right click: select pos %{;;s}%2"
    17.         else if arg-1 is "check":
    18.             if {animalcheck.pos1} is not set:
    19.                 send "{@prefix} please select pos %{;;s}%1"
    20.             else if {animalcheck.pos2} is not set:
    21.                 send "{@prefix} please select pos %{;;s}%2"
    22.             else:
    23.                 set {_animals} to 0
    24.                 loop all entities:
    25.                     set {_loc} to loop-entity's location
    27.                     set {_animals} to number of cows in {animalcheck.pos1} and {animalcheck.pos2}
    28.                 send "Number of animals : %{_animals}%"
    30.                 delete {animalcheck.pos1}
    31.                 delete {animalcheck.pos2}
    33. on leftclick:
    34.     if player has permission "lom.op":
    35.         set {_wand} to feather named "&cAnimal Check Wand" with lore "Left click: select pos %{;;s}%1||Right click: select pos %{;;s}%2"
    36.         if player's tool is {_wand}:
    37.             cancel event
    38.             set {_click} to event-location
    39.             if {_click} is not set:
    40.                 stop
    41.             else:
    42.                 cancel event
    43.                 set {animalcheck.pos1} to event-location
    44.                 send "{@prefix} First position set to %event-location%"
    46. on rightclick:
    47.     if player has permission "lom.op":
    48.         set {_wand} to feather named "&cAnimal Check Wand" with lore "Left click: select pos %{;;s}%1||Right click: select pos %{;;s}%2"
    49.         if player's tool is {_wand}:
    50.             cancel event
    51.             set {_click} to event-location
    52.             if {_click} is not set:
    53.                 stop
    54.             else:
    55.                 cancel event
    56.                 set {animalcheck.pos2} to event-location
    57.                 send "{@prefix} Second position set to %event-location%"
  2. Mr_Simba

    Mr_Simba King of the Pridelands

    Dec 9, 2016
    Likes Received:
    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.
Thread Status:
Not open for further replies.

Share This Page