It is currently 15 Aug 2018, 03:26
   
Text Size

A possible way to debug without the old good script log

Moderators: Xander9009, CCGHQ Admins

A possible way to debug without the old good script log

Postby thefiremind » 22 Oct 2016, 20:38

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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life. Don't expect answers to PMs.
User avatar
thefiremind
Programmer
 
Posts: 3513
Joined: 07 Nov 2011, 10:55
Has thanked: 117 times
Been thanked: 715 times

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

Postby Tejahn » 26 Oct 2016, 00:10

Do you have a screenshot of how this is displayed? A demonstration of sorts?
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times

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

Postby thefiremind » 26 Oct 2016, 08:38

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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life. Don't expect answers to PMs.
User avatar
thefiremind
Programmer
 
Posts: 3513
Joined: 07 Nov 2011, 10:55
Has thanked: 117 times
Been thanked: 715 times

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

Postby Tejahn » 26 Oct 2016, 15:17

Will test. Thanks!
Tejahn
 
Posts: 430
Joined: 14 May 2013, 01:35
Has thanked: 25 times
Been thanked: 25 times

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

Postby Splinterverse2 » 31 Oct 2016, 13:24

This sounds interesting. Does it provide different info than the log does or does it just show it in a different place?
Splinterverse2
 
Posts: 52
Joined: 20 Sep 2016, 13:52
Has thanked: 13 times
Been thanked: 0 time

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

Postby thefiremind » 31 Oct 2016, 13:41

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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life. Don't expect answers to PMs.
User avatar
thefiremind
Programmer
 
Posts: 3513
Joined: 07 Nov 2011, 10:55
Has thanked: 117 times
Been thanked: 715 times

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

Postby Splinterverse2 » 31 Oct 2016, 15:36

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.
Splinterverse2
 
Posts: 52
Joined: 20 Sep 2016, 13:52
Has thanked: 13 times
Been thanked: 0 time

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

Postby thefiremind » 31 Oct 2016, 16:00

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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life. Don't expect answers to PMs.
User avatar
thefiremind
Programmer
 
Posts: 3513
Joined: 07 Nov 2011, 10:55
Has thanked: 117 times
Been thanked: 715 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 1 guest


Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 10 minutes)
Most users ever online was 279 on 11 Jul 2013, 22:03

Users browsing this forum: No registered users and 1 guest

Login Form