Skip to content

error with "function {@title}name()" on start #2492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Anarchick opened this issue Sep 30, 2019 · 6 comments
Closed

error with "function {@title}name()" on start #2492

Anarchick opened this issue Sep 30, 2019 · 6 comments
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation).

Comments

@Anarchick
Copy link

Anarchick commented Sep 30, 2019

Description

when the server start or after a /reload,
any function using "options" as :
function {@title}f():
will thrown an error and can't be used BUT after a /skript reload all, the function can be used without any error

Steps to Reproduce

use a server spigot or paper 1.14.4 with ONLY skript-2.4Beta7 or 2.4Beta8 with only 1 script .sk

options:
    title: test

on load:
    broadcast "{@title}"

function {@title}f():
    broadcast "<gold>function test"

start the server and look the warn on console.
test the function ( for exemple in chat or console write !testf() ) and it will not work cause the function is not loaded
do a /sk reload all and test the function, it work

Errors / Screenshots

[11:40:54] [Server thread/INFO]: CONSOLE: Reload complete.
[11:40:54] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 5788ms or 115 ticks behind
[11:40:54] [Server thread/INFO]: [Skript] Loading variables...
[11:40:54] [Server thread/INFO]: [Skript] Loaded 11417 variables in 0.1 seconds
[11:40:54] [Server thread/ERROR]: [Skript] undefined option {@title} (survival\test.sk, line 7: function {@title}f():')
[11:40:54] [Server thread/ERROR]: [Skript] Invalid function definition. Please check for typos and make sure that the function's name only contains letters and underscores. Refer to the documentation for more information. (survival\test.sk, line 7: function {@title}f():')
[11:40:54] [Server thread/INFO]: test
[11:40:54] [Server thread/INFO]: [Skript] Loaded 1 script with a total of 1 trigger and 0 commands in 0.19 seconds
[11:40:54] [Server thread/INFO]: [Skript] Finished loading.
>!testf()
[11:40:58] [Server thread/ERROR]: Error in: testf()
[11:40:58] [Server thread/ERROR]: The function 'testf' does not exist.
>sk reload all
[11:41:02] [Server thread/INFO]: [Skript] Reloading the config and all scripts...
>!testf()
[11:41:04] [Server thread/INFO]: Loaded 114161 aliases in 2288ms
[11:41:04] [Server thread/INFO]: test
[11:41:04] [Server thread/INFO]: All scripts loaded without errors.
[11:41:04] [Server thread/INFO]: Loaded 1 script with a total of 1 trigger and 0 commands in 0 seconds
[11:41:04] [Server thread/INFO]: [Skript] Successfully reloaded the config and all scripts.
[11:41:04] [Server thread/INFO]: executing 'testf()'
[11:41:04] [Server thread/INFO]: function test
@FranKusmiruk FranKusmiruk added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation). labels Oct 1, 2019
@bluelhf
Copy link
Contributor

bluelhf commented Mar 25, 2020

This just looks like an issue with reloading your server, which you shouldn't be doing anyways. Can you confirm this also happens with restarts?

@Whimsyturtle Whimsyturtle added the needs testing Needs testing to determine current status or issue validity, or for WIP feature pulls. label Jul 10, 2020
@Whimsyturtle
Copy link
Contributor

Needs testing if it can occur with restarts.

@Nicofisi
Copy link
Member

I've just started a fresh-new 1.16.1 Paper server with v2.5-alpha5 Skript and turned it on with no scripts, then I copy-pasted the script from OP into script.sk and ran /sk reload script then /sk reload script again and the issue does happen:

[13:53:06 INFO]: Enabling Skript v2.5-alpha5
[13:53:06 INFO]: [Skript] Successfully generated the config and the example scripts.
[13:53:08 INFO]: §7[§6Skript§7]§r You're currently running the latest stable version of Skript.
[13:53:11 INFO]: [Skript] Loaded 128140 aliases in 4228ms
[13:53:11 INFO]: [Skript]  ~ created by & © Peter Güttinger aka Njol ~
[13:53:11 INFO]: Running delayed init tasks
[13:53:11 INFO]: [Skript] Loading variables...
[13:53:11 INFO]: [Skript] Loaded 0 variables in 0.0 seconds
[13:53:11 INFO]: [Skript] All scripts loaded without errors.
[13:53:11 WARN]: [Skript] No scripts were found, maybe you should write some ;) (config.sk, line 188: databases:')
[13:53:11 INFO]: [Skript] Finished loading.
[13:53:11 INFO]: Done (7.344s)! For help, type "help"
[13:53:11 INFO]: Timings Reset
[13:53:29 INFO]: §7[§6Skript§7]§r Reloading §6script.sk§r...
[13:53:29 ERROR]: undefined option {@title} (script.sk, line 7: function {@title}f():')
[13:53:29 ERROR]: Invalid function definition. Please check for typos and make sure that the function's name only contains letters and underscores. Refer to the documentation for more information. (script.sk, line 7: function {@title}f():')
[13:53:29 INFO]: test
[13:53:29 INFO]: §7[§6Skript§7]§r §4Encountered 2 errors while reloading §6script.sk§r!
[13:54:01 INFO]: §7[§6Skript§7]§r Reloading §6script.sk§r...
[13:54:01 INFO]: test
[13:54:01 INFO]: §7[§6Skript§7]§r Successfully reloaded §6script.sk§r.

@Nicofisi Nicofisi removed the needs testing Needs testing to determine current status or issue validity, or for WIP feature pulls. label Jul 10, 2020
@TPGamesNL
Copy link
Member

This happens because function signatures are loaded before option section (function signatures are loaded in the structure: https://github.com/SkriptLang/Skript/blob/master/src/main/java/ch/njol/skript/ScriptLoader.java#L930, options are loaded after that: https://github.com/SkriptLang/Skript/blob/master/src/main/java/ch/njol/skript/ScriptLoader.java#L602)

@Anarchick
Copy link
Author

So we have to choose between options: test: f() and function {@title}f() ? Or do you think it can be easily fix ?

@TPGamesNL
Copy link
Member

The fix would probably be to include options in the structure loading, with the added bonus that all the options can be replaced before the script is even loaded, so there won't be the need to use replaceOptions all the time (img)

@TPGamesNL TPGamesNL added the PR available Issues which have a yet-to-be merged PR resolving it label Jul 14, 2021
@APickledWalrus APickledWalrus added completed The issue has been fully resolved and the change will be in the next Skript update. and removed PR available Issues which have a yet-to-be merged PR resolving it labels Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: medium Issues that are detrimental to user experience (prohibitive bugs or lack of useful implementation).
Projects
None yet
Development

No branches or pull requests

8 participants