Tutorial by: finder17


Example Skript script for creating and using custom mechanics in Skript-Nexo
This script demonstrates how to create a custom "toasty" mechanic that sets players on fire when they interact with it
Note: Once created, this mechanic can be used in Nexo configs by referencing its ID:
Example in items.yml:

items:
  toasty_sword:
        material: DIAMOND_SWORD
        name: "&6Toasty Sword"
    lore:
       - "&eThis sword is extremely hot!"
    mechanics:
        - toasty

Create the custom mechanic when the server starts


  on load:
    # Create a new mechanic with the ID "toasty"
    create nexo mechanic with id "toasty"

    # Set properties for the mechanic
    set property "damage" of mechanic "toasty" to 5
    set property "enabled" of mechanic "toasty" to true
    set property "duration" of mechanic "toasty" to 3 seconds

# Event to handle when a player interacts with an object that has the toasty mechanic
  on interact with mechanic "toasty":
      # This code will run when a player interacts with an object that has the "toasty" mechanic
      send "§6You feel a warm sensation!" to player

    # Get the damage and duration properties
    set {_damage} to property "damage" of mechanic "toasty"
    set {_duration} to property "duration" of mechanic "toasty"

    # Apply effects based on the mechanic's properties
    if player is sneaking:
        # Reduced effect when sneaking
        set {_damage} to {_damage} / 2
        set {_duration} to {_duration} / 2
        send "§e(Sneaking reduced the effect)" to player

    # Apply heat effect (using potion effect instead of fire)
    ignite player for {_duration}

    # Apply damage
    damage player by {_damage}

    # You can add additional logic here if needed
    if player's tool is a water bucket:
        send "§bThe water cooled down the toasty mechanic!" to player
        cancel even

Did you find finder17's tutorial helpful?


You must be logged in to comment