Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
GetDataChest() returns nil
Moderator: CCGHQ Admins
GetDataChest() returns nil
by thefiremind » 13 Feb 2013, 16:08
In an attempt to code my own implementation of soulbond, I found a problem that I can't understand. Sometimes all goes well, while sometimes SCRIPT_LOG.TXT warns me of an "attempt to index a nil value" exactly on the lines where I use GetDataChest() on another card. Did anybody face this problem and eventually invented a solution?
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
Re: GetDataChest() returns nil
by thefiremind » 20 Mar 2013, 16:19
I forgot to delete this topic after I found the real reason why it happens: when you call ObjectDC() from the object itself, if the data chest hasn't been initialised yet, the function takes care of that and returns the data chest after initialisation. When you call GetDataChest() from another card, if the data chest hasn't been initialised yet, the function ignores the problem and returns nil.
In short, you can access the object data chest of card "A" from card "B" only if you accessed it at least once from card "A" itself.
In short, you can access the object data chest of card "A" from card "B" only if you accessed it at least once from card "A" itself.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests