Hello again guys.
I know I am asking a lot of questions about Lua these days, and I often realize I could have resolved my issues with more research, and for this I do apologize.
This said, I am hitting a problem that I can't explain.
I have this function called by another function. Actually it initially was my Defeat Player function.
When it was called, its thread crashed. So I replaced its content with a couple of UI natives to test hiding my custom frames.
To test it easily, I added a chat command to execute the function :
No need to explain the globals used here as they are pretty explicit and that the command actually works
p is the triggering player of the chat event.
Now here is my new problematic function :
Well as you can see I added a print. Strange thing is the function works great without the print.
So out of despair i changed it this way :
...and removed the "p" in the call, but this still crashes... this is killing me guys, how can a simple print call crash a function, this makes no sense !!!
Note : putting anything else inside the print brackets, like another string or a global variable led to the same result.
I initially thought there was a fault in my chat commands trigger, but no, the other commands work great, for example I added a victory command that starts my victory function and that one works perfectly !!!
All this Lua behavior is completely killing me, where am I supposed to make sense of this ?
I even thought I accidentally created a global variable with the same name as the function but after checking my whole map script, the only time DefeatPlayer appears is when it is called.
I am trying to learn Lua with a lot of good will, but this defeats any will....
Help ?
EDIT : Changing the name of the function did not solve this...
EDIT 2 :
How do you experienced Lua programmers actually manage to debug your code for errors ?
I know I am asking a lot of questions about Lua these days, and I often realize I could have resolved my issues with more research, and for this I do apologize.
This said, I am hitting a problem that I can't explain.
I have this function called by another function. Actually it initially was my Defeat Player function.
When it was called, its thread crashed. So I replaced its content with a couple of UI natives to test hiding my custom frames.
To test it easily, I added a chat command to execute the function :
Lua:
if (command=="+defeat") and (PlayerName[HostNumber]=="Macadamia") then
DefeatPlayer(p)
end
No need to explain the globals used here as they are pretty explicit and that the command actually works
p is the triggering player of the chat event.
Now here is my new problematic function :
Lua:
function DefeatPlayer(p)
local pn=GetPlayerId(p)+1
local t=CreateTimer()
BlzFrameSetVisible(Parent, false)
BlzFrameSetVisible(BarsParent, false)
print(pn)
end
Well as you can see I added a print. Strange thing is the function works great without the print.
So out of despair i changed it this way :
Lua:
function DefeatPlayer()
-- local pn=GetPlayerId(p)+1
-- local t=CreateTimer()
-- BlzFrameSetVisible(Parent, false)
-- BlzFrameSetVisible(BarsParent, false)
print('ok')
end
...and removed the "p" in the call, but this still crashes... this is killing me guys, how can a simple print call crash a function, this makes no sense !!!
Note : putting anything else inside the print brackets, like another string or a global variable led to the same result.
I initially thought there was a fault in my chat commands trigger, but no, the other commands work great, for example I added a victory command that starts my victory function and that one works perfectly !!!
All this Lua behavior is completely killing me, where am I supposed to make sense of this ?
I even thought I accidentally created a global variable with the same name as the function but after checking my whole map script, the only time DefeatPlayer appears is when it is called.
I am trying to learn Lua with a lot of good will, but this defeats any will....
Help ?
EDIT : Changing the name of the function did not solve this...
EDIT 2 :
How do you experienced Lua programmers actually manage to debug your code for errors ?
Last edited: