Page 1 of 1

GetDataChest() returns nil

PostPosted: 13 Feb 2013, 16:08
by thefiremind
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?

Re: GetDataChest() returns nil

PostPosted: 20 Mar 2013, 15:47
by BETenner
Are you sure the card isn't nil?

Re: GetDataChest() returns nil

PostPosted: 20 Mar 2013, 16:19
by thefiremind
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.