It is currently 23 Jul 2019, 01:09
   
Text Size

GetDataChest() returns nil

Moderators: Xander9009, CCGHQ Admins

GetDataChest() returns nil

Postby 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...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 717 times

Re: GetDataChest() returns nil

Postby BETenner » 20 Mar 2013, 15:47

Are you sure the card isn't nil?
BETenner
 
Posts: 36
Joined: 07 Mar 2013, 14:20
Has thanked: 7 times
Been thanked: 4 times

Re: GetDataChest() returns nil

Postby 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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 717 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 2 guests


Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 10 minutes)
Most users ever online was 287 on 31 Mar 2019, 04:11

Users browsing this forum: No registered users and 2 guests

Login Form