Skip to content
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

local functions can be called as events #2137

Closed
Helianthella opened this issue Jul 18, 2018 · 2 comments · Fixed by #2142
Closed

local functions can be called as events #2137

Helianthella opened this issue Jul 18, 2018 · 2 comments · Fixed by #2142
Labels
component:core:scriptengine Affecting the script engine or the script commands severity:3-medium Issues with GM commands, script commands, and other commonly used features type:bug Issue is a bug or describes an incorrect behavior that should be fixed

Comments

@Helianthella
Copy link
Member

Helianthella commented Jul 18, 2018

since local function names and labels are both stored in the same strdb it is possible to call a local function as if it were an event when it has a name that begins with On

// define a function in MyNPC
function OnMyFunction {
	debugmes("hello!");
	return;
}

// then it can be called from anywhere:
donpcevent("MyNPC::OnMyFunction");
[Debug]: script debug : 0 110000354 : hello!
[Warning]: script:run_func: return without callfunc or callsub!

This affects not just custom events but rather every single event calls (oninit, onlogin, mob death, timers, clock, woe, …) since they all use the same functions



We should either make it illegal or officially support it, which would be a great idea as we could get rid of most labels and use functions everywhere. As syntax for the event string we could use

MyNPC::MyFunction()

so if parentheses are found it is a function call, else it is a normal label call

@Helianthella Helianthella added type:bug Issue is a bug or describes an incorrect behavior that should be fixed component:core:scriptengine Affecting the script engine or the script commands severity:3-medium Issues with GM commands, script commands, and other commonly used features labels Jul 18, 2018
@AnnieRuru
Copy link
Contributor

at this moment we can use a floating npc then donpcevent
not really urgent to implement this ...

@Helianthella
Copy link
Member Author

this is far from urgent, I just put severity 3 because it is defined as Script command not behaving accordingly to what's expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:core:scriptengine Affecting the script engine or the script commands severity:3-medium Issues with GM commands, script commands, and other commonly used features type:bug Issue is a bug or describes an incorrect behavior that should be fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants