Page 1 of 1

A possible way to debug without the old good script log

PostPosted: 22 Oct 2016, 20:38
by thefiremind
I don't know if anybody knew this already, but I found how to get an error string that tells you what's wrong with your code.
Code: Select all
local status, err = pcall(function()
   -- Write here the code that you want to debug
end)
After running this, if there was an error, the err variable will contain a string just like the ones we were finding on DotP2013's SCRIPT_LOG.TXT, which you can display through a player message or a query.

I should warn you, though: I'm afraid it hangs the game with any code that produces no errors (the application still runs, but the duel doesn't progress). For this reason I think it's good only when you need to test a single function in search for the correct arguments.

Feel free to add any additional information you find.

Re: A possible way to debug without the old good script log

PostPosted: 26 Oct 2016, 00:10
by Tejahn
Do you have a screenshot of how this is displayed? A demonstration of sorts?

Re: A possible way to debug without the old good script log

PostPosted: 26 Oct 2016, 08:38
by thefiremind
Put this on a card (while using my message function):
Code: Select all
local status, err = pcall(function()
   EffectController():GetManaPool(1)
end)
TFM_MessageBox(err)
The message will be that GetManaPool has too many or too few parameters (because it doesn't need any).

But if you do this:
Code: Select all
local status, err = pcall(function()
   EffectController():GetManaPool()
end)
TFM_MessageBox(err)
then the game will hang, because there are no errors.

Re: A possible way to debug without the old good script log

PostPosted: 26 Oct 2016, 15:17
by Tejahn
Will test. Thanks!

Re: A possible way to debug without the old good script log

PostPosted: 31 Oct 2016, 13:24
by Splinterverse2
This sounds interesting. Does it provide different info than the log does or does it just show it in a different place?

Re: A possible way to debug without the old good script log

PostPosted: 31 Oct 2016, 13:41
by thefiremind
Splinterverse2 wrote:This sounds interesting. Does it provide different info than the log does or does it just show it in a different place?
It's exactly the same as the log, which doesn't get created anymore in Magic Duels so it's a quite important discovery.

Re: A possible way to debug without the old good script log

PostPosted: 31 Oct 2016, 15:36
by Splinterverse2
thefiremind wrote:
Splinterverse2 wrote:This sounds interesting. Does it provide different info than the log does or does it just show it in a different place?
It's exactly the same as the log, which doesn't get created anymore in Magic Duels so it's a quite important discovery.
Wow. I had no idea you didn't have the log in Duels. I can't live without that. I wouldn't complete anything. Glad you found this.

Re: A possible way to debug without the old good script log

PostPosted: 31 Oct 2016, 16:00
by thefiremind
Well, if there's a syntax mistake the current action will stop running, so if in game you don't see happening what's supposed to happen, you know there's probably an error somewhere: it's a matter of looking back at the code and spotting what's wrong. The "pcall" discovery can certainly help, but not much: I still need to enclose the code in it, then test the card again, and hope that it doesn't hang the game before the error is encountered.