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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    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.

Solved Signature of Function is null when return type is asked

Discussion in 'Skript' started by JadedDragoon, Feb 7, 2017.

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

    JadedDragoon Member

    Joined:
    Feb 5, 2017
    Messages:
    6
    Likes Received:
    2
    Skript Version: 2.2-dev23
    Skript Author: Bensku
    Minecraft Version: 1.11.2
    ---
    Full Code:

    Code (Skript):
    1.  
    2. options:
    3.    bedClickSpeed:   1 second
    4.    homeCooldown:   15 minutes
    5.    dmgCooldown:   15 seconds
    6.  
    7. command /sethome:
    8.    description: Set your home
    9.    permission: skript.homes.sethome
    10.    executable by: players
    11.    trigger:
    12.        set {homes.%player%.location} to location of player
    13.        message "Your home has been set to <grey>%location of player%<reset>"
    14.  
    15. command /home:
    16.    description: Teleport yourself to your home
    17.    permission: skript.homes.home
    18.    executable by: players
    19.    trigger:
    20.        if {homes.%player%.location} is not set:
    21.            message "You have not set your home yet!"
    22.            stop trigger
    23.        if checkCD(player) is false:
    24.            stop
    25.        message "Going home..."
    26.        teleport player to {homes.%player%.location}
    27.        set {homes.%player%.lasthometp} to now
    28.  
    29. on rightclick on bed_block:
    30.    if player does not have permission "skript.homes.bedhome":
    31.        stop
    32.    #if player can use bedhome, disable standard bed behavior to keep usage consistent
    33.    cancel event
    34.    if {homes.%player%.firstclick} was more than {@bedClickSpeed}:
    35.        set {homes.%player%.firstclick} to now
    36.        stop
    37.    if player cannot build at the clicked block:
    38.        message "You cannot use this bed for your home."
    39.        stop
    40.    set {homes.%player%.location} to location of player
    41.    message "Your home has been set to this spot."
    42.  
    43. on respawn:
    44.    if player does not have permission "skript.homes.respawnhome":
    45.        stop
    46.    if {homes.%player%.location} does not exist:
    47.        message "You have not set a home! Using default respawn."
    48.        stop
    49.    teleport player to {homes.%player%.location}
    50.  
    51. #intercept multiverse spawn command and apply cooldown
    52. on command "/mv":
    53.    if arguments is "spawn":
    54.        if checkCD(player) is false:
    55.            cancel event
    56.            stop
    57.        set {homes.%player%.lasthometp} to now
    58.  
    59. function checkCD(p: player) :: boolean:
    60.    if {_p} does not have permission "skript.homes.nocooldown":
    61.        if {shared.%{_p}%.lastdamaged} was less than {@dmgCooldown} ago:
    62.            message "You cannot flee while taking damage!" to {_p}
    63.            return false
    64.        if {homes.%{_p}%.lasthometp} was less than {@homeCooldown} ago:
    65.            set {_waited} to difference between {homes.%{_p}%.lasthometp} and now
    66.            message "You must wait %difference between {@homeCooldown} and {_waited}% before using this command again." to {_p}
    67.            return false
    68.    return true
    69.  
    The variable "shared.%player%.lastdamaged" is set in another script:

    Code (Skript):
    1. on damage of player:
    2.     set {shared.%victim%.lastdamaged} to now
    Errors on Reload:

    Code (Skript):
    1.  
    2. >skript reload homes.sk
    3. [06:46:16 INFO]: [Skript] Reloading homes.sk...
    4. [06:46:16 ERROR]: #!#!
    5. [06:46:16 ERROR]: #!#! [Skript] Severe Error:
    6. [06:46:16 ERROR]: #!#! Could not load homes.sk
    7. [06:46:16 ERROR]: #!#!
    8. [06:46:16 ERROR]: #!#! If you're developing an add-on for Skript this likely means that you have done something wrong.
    9. [06:46:16 ERROR]: #!#! If you're a server admin however please go to https://github.com/bensku/Skript/issues/
    10. [06:46:16 ERROR]: #!#! and check whether this error has already been reported.
    11. [06:46:16 ERROR]: #!#! If not please create a new ticket with a meaningful title, copy & paste this whole error into it (or use paste service),
    12. [06:46:16 ERROR]: #!#! and describe what you did before it happened and/or what you think caused the error.
    13. [06:46:16 ERROR]: #!#! If you think that it's a trigger that's causing the error please post the trigger as well.
    14. [06:46:16 ERROR]: #!#! By following this guide fixing the error should be easy and done fast.
    15. [06:46:16 ERROR]: #!#!
    16. [06:46:16 ERROR]: #!#! Stack trace:
    17. [06:46:16 ERROR]: #!#! ch.njol.skript.SkriptAPIException: Signature of function is null when return type is asked!
    18. [06:46:16 ERROR]: #!#!     at ch.njol.skript.lang.function.FunctionReference.getReturnType(FunctionReference.java:201)
    19. [06:46:16 ERROR]: #!#!     at ch.njol.skript.lang.function.ExprFunctionCall.getReturnType(ExprFunctionCall.java:56)
    20. [06:46:16 ERROR]: #!#!     at ch.njol.skript.conditions.CondCompare.init(CondCompare.java:172)
    21. [06:46:16 ERROR]: #!#!     at ch.njol.skript.conditions.CondCompare.init(CondCompare.java:132)
    22. [06:46:16 ERROR]: #!#!     at ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:249)
    23. [06:46:16 ERROR]: #!#!     at ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:176)
    24. [06:46:16 ERROR]: #!#!     at ch.njol.skript.lang.Condition.parse(Condition.java:83)
    25. [06:46:16 ERROR]: #!#!     at ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:833)
    26. [06:46:16 ERROR]: #!#!     at ch.njol.skript.lang.TriggerSection.<init>(TriggerSection.java:56)
    27. [06:46:16 ERROR]: #!#!     at ch.njol.skript.lang.Conditional.<init>(Conditional.java:46)
    28. [06:46:16 ERROR]: #!#!     at ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:840)
    29. [06:46:16 ERROR]: #!#!     at ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:513)
    30. [06:46:16 ERROR]: #!#!     at ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:271)
    31. [06:46:16 ERROR]: #!#!     at ch.njol.skript.SkriptCommand.onCommand(SkriptCommand.java:167)
    32. [06:46:16 ERROR]: #!#!     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    33. [06:46:16 ERROR]: #!#!     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
    34. [06:46:16 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_11_R1.CraftServer.dispatchCommand(CraftServer.java:650)
    35. [06:46:16 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_11_R1.CraftServer.dispatchServerCommand(CraftServer.java:636)
    36. [06:46:16 ERROR]: #!#!     at net.minecraft.server.v1_11_R1.DedicatedServer.aM(DedicatedServer.java:437)
    37. [06:46:16 ERROR]: #!#!     at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:400)
    38. [06:46:16 ERROR]: #!#!     at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:675)
    39. [06:46:16 ERROR]: #!#!     at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:574)
    40. [06:46:16 ERROR]: #!#!     at java.lang.Thread.run(Thread.java:745)
    41. [06:46:16 ERROR]: #!#!
    42. [06:46:16 ERROR]: #!#! Version Information:
    43. [06:46:16 ERROR]: #!#!   Skript: 2.2-dev23
    44. [06:46:16 ERROR]: #!#!   Bukkit: 1.11.2-R0.1-SNAPSHOT
    45. [06:46:16 ERROR]: #!#!   Minecraft: 1.11.2
    46. [06:46:16 ERROR]: #!#!   Java: 1.8.0_121 (Java HotSpot(TM) 64-Bit Server VM 25.121-b13)
    47. [06:46:16 ERROR]: #!#!   OS: Linux amd64 3.13.0-107-generic
    48. [06:46:16 ERROR]: #!#!
    49. [06:46:16 ERROR]: #!#! Running CraftBukkit: false
    50. [06:46:16 ERROR]: #!#!
    51. [06:46:16 ERROR]: #!#! Current node: if checkCD(player) is false: (homes.sk, line 59)
    52. [06:46:16 ERROR]: #!#! Current item: null
    53. [06:46:16 ERROR]: #!#!
    54. [06:46:16 ERROR]: #!#! Thread: Server thread
    55. [06:46:16 ERROR]: #!#!
    56. [06:46:16 ERROR]: #!#! End of Error.
    57. [06:46:16 ERROR]: #!#!
    58. [06:46:16 INFO]: [Skript] Successfully reloaded homes.sk.
    59.  
    Other Useful Info:

    Simply trying to reduce code reproduction in this script. Since I use the cooldown check in two different events it made sense to make a function of it so code would remain consistent if I changed the check.

    Addons using (including versions):
    SkQuery 3.5.5-Lime
    MundoSK 1.7.4

    Troubleshooting:

    Have you tried searching the docs? Yes
    Have you tried searching the forums? Yes
    What other methods have you tried to fix it? Reverted my changes to an older copy of the script, went to bed, slept on it, and tried again... same result. Given the catchall "return true" at the end of the function and the fact that the function does not have a "stop" statement in it anywhere I have no idea how this function is returning null.
    --- Double Post Merged, Feb 7, 2017, Original Post Date: Feb 7, 2017 ---
    Oh god, don't tell me it was that simple...:emoji_cry:

    Functions must be declared higher in the script that when they are used. I assumed since options were preprocessed on script load then functions would be too.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...