Solved Weird functionality. Need help.

  • 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.

Conciulls13

New Member
Apr 29, 2018
7
1
0
23
Skript Version (do not put latest): Skript 2.3.2
Skript Author: Bensku
Minecraft Version: 1.13.2
---
Full Code:
Code:
player picking up diamond pickaxe:
    if item is not enchanted with fortune:
        send "Pass a" to player
    if allowedToObtain(player, item, "fortune") is false:
        cancel event

function allowedToObtain(p: player, i: item, e1: string) :: boolean:
    if {_i} is not enchanted with {_e1}:
        send "Pass b" to {_p}
        return true
    return false


Errors on Reload:
Nill

Console Errors: (if applicable)
Nill

Addons using (including versions):
None

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? No
What other methods have you tried to fix it? I have eliminated everything irrelevant to this very process.

Explanation: When a player picks up a diamond pickaxe enchanted with fortune, this code sends the message "Pass B" which should not send based on the conditions. It also has the seemingly exact conditions as the message "Pass A", which is not sent.
What's occurring here is either a mystery or going right over my head. Help is greatly appreciated!
 
e1 is a string, not an enchantment
Could you explain further? I am not aware that enchantments are processed like event values.
[doublepost=1548515011,1548514653][/doublepost]Actually... don't bother. You're absolutely right. Thanks!! :emoji_joy:
Code:
player picking up diamond pickaxe:
    if item is not enchanted with fortune:
        send "Pass a" to player
    if allowedToObtain(player, item, fortune) is false:
        cancel event

function allowedToObtain(p: player, i: item, e1: enchantment) :: boolean:
    if {_i} is not enchanted with {_e1}:
        send "Pass b" to {_p}
        return true
    return false
 
  • Like
Reactions: TPGamesNL
Status
Not open for further replies.