Skript Argument

Discussion in 'Spigot Plugin Help' started by Terrick, May 23, 2015.

  1. Looking to find out how to make an argument on Skript to create output for a right click on a block with an item other than the ones I choose for a different output?

    Such as,

    on rightclick on grass without shovel
    send "you need a shovel to right click this" to player


    Something like that?

    Thanks!


    Also a skript to define a region where certain skripts won't work?
    Like removing a silk touch skript from a spawn region defined by worldguard.
     
  2. You can't check what a player is holding in the event, but you can do so right afterwards and then do things based on that:

    Code (Text):
    on right click on grass:
            if player is not holding any shovel:
                    send "you need a shovel to right click this" to player
                    # note, you may want to "cancel event" here to stop them actually clicking
            else:
                    # do stuff when they have a shovel              
    Note: didn't actually load it up and test.
     
    #2 Absentee23, May 23, 2015
    Last edited: May 23, 2015
    • Like Like x 1
    • Winner Winner x 1

  3. I was trying to remember the phrasing for 'any shovel' and then I come back to post and ninja'd
     
    • Funny Funny x 1
  4. This worked, thanks.

    Any advice on the second part?
     
  5. It really depends on what you're doing, but you can add a check to each of those scripts to check they are/aren't in a certain region. Here's how I do it/how I've seen it recommended (Skript's regions support is not great, but it works :p)

    Code (Text):
            set {_regions} to "%regions at player%"
            if {_regions} contains "regionname":
                    # player is in regionname, so stop because we don't want them doing stuff in this region
                    stop
            else:
                    # player is NOT in regionname, so continue going through the script
                    # silktouch away!
    You can't just write another skript to stop other skripts from working in a region, but you can modify those skripts to not continue their function when a player is/isn't in a region.
     
    • Like Like x 1
  6. Let's imagine I'm doing right click on grass to pick up a grass block, but not in protected regions named "shop".

    on right click on grass:
    if player is in shop:
    else:
    give player a grass block

    if {_regions} contains "shop":
    player is in shop
    else:
    player is NOT in shop

    ?
     
  7. "shop" needs to be in quotes, and you have to set {_regions} to "%regions at player%" first, but otherwise yes. You have to set the {_regions} variable in each event, not just once. so:
    Code (Text):
    on right click on grass:
            set {_regions} to "%regions at player%"
            if {_regions} contains "shop":
                    #player is in shop region
    Any variable that starts with an underscore (like {_regions} ) is a local variable, and will be lost after that event completes. If you want that value to be saved, remove the _, BUT you don't want to do that in this case. You want to check the region in every event.
     
    • Like Like x 1
  8. So I have to define the set region argument within each argument I create?

    Fairly new to skript, so I don't see why the check for the region is within that skript? Or how I'd create the "give" argument within it?
     
  9. I think you need to get the terminology down before you confuse yourself:

    This is an event, theres a list of all of them at that link:
    Code (Text):
    on right click:
    This is an effect, theres a list of all of them at that link:
    Code (Text):
    give 1 grass block to the player
    This is an expression, theres a list of all of them at that link:
    Code (Text):
    player is holding any shovel
    This is a LOCAL variable (it will not be saved, and can only be used in the event it is defined in; the link contains info about variables in skript):
    Code (Text):
    {_region}
    This is a normal variable (it will be saved to your variables storage file and you can call it from different events; the link contains info about variables in skript):
    Code (Text):
    {region}
    "arguments" are what you pass to commands:
    Code (Text):
    /msg player message
    /command argument1 argument2
    There's a bunch of documentation here, and even more here (which includes Skript's add-ons too), that will teach you the basics.

    The way
     
    • Like Like x 1

  10. Well while terminology isn't my strong suit with things I just started using, I still don't quite understand how to add the response to my clicking while not in the region as opposed to in the region :/
    I understand the check needs to be in place, but can't I have a separate skript for checking for each of my regions then other skripts that use this check.
     
  11. You have to add the region check to every event where you want the outcome to change based on what region they are in.

    Read my example:
    Code (Text):
    on right click on grass:
            set {_regions} to "%regions at player%"
            if {_regions} contains "shop":
                    #player is in shop region
     
    Where it says "#player is in shop region", thats where you would put your code to do IF they are in the region "shop." You could also change it to "if {_regions} does not contain "shop"" and put your code to run if they AREN'T in the shop region. You could add an "else:" section under it if you want to do something if they ARE in the region, OR do something else if the AREN'T in the region.

    one script can't change what another script is doing.
     
    #11 Absentee23, May 23, 2015
    Last edited: May 23, 2015
    • Like Like x 1
  12. Okay so I need region info in each skript I wish to disallow in specific regions.
    Got it, thanks :D
     
  13. Yup, and not just once in each skript, you need to check in each event. (sorry if thats what you meant, thats why the terminology is important)
     
    • Agree Agree x 1