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.

Skripts stop reloading properly

Discussion in 'Skript' started by Wynnevir, Jul 25, 2017.

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

    Wynnevir Well-Known Member

    Joined:
    Jul 9, 2017
    Messages:
    1,016
    Likes Received:
    62
    I've had a problem lately, specifically with my functions script, where after maybe 2 or 3 reloads it will say it reloaded but doesn't. The changes are saved in the configuration but do not reflect in game. I have to restart the server to get it to take effect. This seems to only happen with my functions.
    These are simple changes I'm reloading for, like setting test messages to troubleshoot or changing colors of text.
    I'm on MC spigot 1.12
    Skript Bensku's fork 2.2 dev 29.

    Just for visual's sake this is one of the functions I just changed
    [​IMG]
    And even though I saved and reloaded it's still sending the old test messages
    [​IMG]
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    While I'm unsure if it's the correct answer, it's worth pointing out that a function must load before code that calls it.

    So, let's say you load your functions, then load a script that implements that function. This is fine. Now let's say you edit your function, and reload it. That newly edited function was loaded after the script that implements it; therefore, we'll have to reload the scripts that implement it as well.
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Does the loading in order have anything to do with the alphabetical order of the skripts? The file with my functions.sk is under my commands.sk file, though they still work it seems when the functions.sk is reloaded successfully. Well, all but one randomly but let's not complicate thingsXD I'm wondering if it's maybe something with functions itself that causes the skript to not actually reload?
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Perhaps there lies a deeper issue, like you say, but I would suggest a first step of ensuring the functions script loads first everytime; you can do this by prefixing it with a number, like this:

    1functions.sk
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Nope, doesn't seem to do it. Additionally some of the commands that try and call functions from the separate skript throw severe errors in console. Putting the functions above the commands in the same skript makes them all operable, but defeats the point of having them nice and organized in their own little sk file. At least they work this way though, I can only think it must be the function's ability to pull from another skript not working 100% then. I'm going to leave the thread up a bit longer to see if anyone else has experienced it, and if not I think I'm just out of luck XD
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Maybe (but probably not, im just taking a wild guess) you need to reload the functions skript and the skript that calls the function
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Have done both. The commands skript calling the functions skript reloads just fine, all changes take place. It's the functions for some reason when they're in their own skript that say it reloaded fine, but the changes do not take place.
    **Edit: just to be more clear and helpful potentially : I currently I have functions at the top in their own skript called 1functions.sk to keep it up there, and reload that before the commands.sk. The changes just do not happen until server restart for some reason D:
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    have you tried /sk reload all
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    Just tried it a few times and no luck
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    So, are you saying that when you reload the script where you have your functions then the script that's actually using the function it still uses the old function? That's pretty weird.

    Just to be completely sure. Create a new file and call it "1_functionTest.sk" then put the following script on it:

    Code (Skript):
    1. function testingFunctions(optional: int = 1):
    2.   broadcast "1"
    3.   teleport ops to (first element of all worlds)'s spawn
    4.  
    Then create another file and call it "2_functionTest.sk" and put the following script on it:

    Code (Skript):
    1. function testFunctions(optional: int = 1):
    2.   testingFunctions()
    3.   broadcast "3"
    4.   set block at (first element of all worlds)'s spawn to prismarine block
    5.   broadcast "4"
    6.  
    7. command testing:
    8.   trigger:
    9.     testFunctions()
    10.     broadcast "5"
    11.  
    Then, execute "sk reload all" and execute the testing command. After that, add:
    Code (Skript):
    1. broadcast "2"
    to the testingFunctions function and do "sk reload all" and "testing" again.
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    220
    It's very odd and frustrating. Your test will work, but only if I reload all skripts from console. Even putting both of your functions on the same document and reloading from console works.
    Mine, however, does not, even with a reload of all skripts from console. And both of my files work perfectly fine except in this regard.

    This is my 1functions.sk (kindly ignore my inability to make things efficient as of yetXD)
    https://pastebin.com/jwnSBpUw

    And this is the commands file that calls the functions, commands.sk:
    https://pastebin.com/PTtbhQgz

    They're long I suppose, on the GUI one so maybe there's trouble there? It's just commands and functions in each skript just like your example so I can't understand why mine are not reloading.
    The functions specifically too. If I make a change to the commands and reload just that skript OR all skript it takes effect right away.
     
Thread Status:
Not open for further replies.

Share This Page

Loading...