Error Trap just logged an Unhandled Reference, and it's about my Online Center mod, hence I'm more than interested in what this could mean
I'm uploading it as I type.
P.S. The interaction mentioned in the error, was being used by a Sim, then I saved and when I reloaded the game, the Sim completed the interaction normally, while Error Trap reported the script error.
Unhandled Reference for my mod
Your "Relationships" list is storing a reference to the Sim object for "Keenan Pulliam".
However that object has since been deleted from the game. "Keenan Pulliam" may still exist as a sim, but the object being stored in the list is not valid any longer.
If you really need to persist a list of "Sim" objects via your interaction, then it is not really a big deal. Though I'm not sure what your code does if the user chooses that particular sim now that they are no longer valid.
Interesting, I use the same method EA uses in their "Chat" interaction. But I'm thinking the problem lies in this :
<!-- ws:start:WikiTextCodeRule:0:
<pre class="text"> if (this.Relationships == null)<br/> {<br/> this.Relationships = new List<Sim>();<br/> }<br/> else<br/> {<br/> this.Relationships.Clear();<br/> }<br/> this.Relationships.AddRange(PlumbBookHandler.FindRelationships(this.Actor));<br/></pre>
-->
<style type="text/css"><!--
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.text {font-family:monospace;}
.text .imp {font-weight: bold; color: red;}
.text span.xtra { display:block; }
-->
</style><pre class="text">
if (this.Relationships == null)
{
this.Relationships = new List<Sim>();
}
else
{
this.Relationships.Clear();
}
this.Relationships.AddRange(PlumbBookHandler.FindRelationships(this.Actor));
</pre>
It's the first time I saw this error and the last thing I changed was this one, where I keep the list and just clear it when done.
So, you think I should use a List<SimDescription> instead? I will give it a try, thanks
<!-- ws:start:WikiTextCodeRule:0:
<pre class="text"> if (this.Relationships == null)<br/> {<br/> this.Relationships = new List<Sim>();<br/> }<br/> else<br/> {<br/> this.Relationships.Clear();<br/> }<br/> this.Relationships.AddRange(PlumbBookHandler.FindRelationships(this.Actor));<br/></pre>
-->
<style type="text/css"><!--
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.text {font-family:monospace;}
.text .imp {font-weight: bold; color: red;}
.text span.xtra { display:block; }
-->
</style><pre class="text">
if (this.Relationships == null)
{
this.Relationships = new List<Sim>();
}
else
{
this.Relationships.Clear();
}
this.Relationships.AddRange(PlumbBookHandler.FindRelationships(this.Actor));
</pre>
It's the first time I saw this error and the last thing I changed was this one, where I keep the list and just clear it when done.
So, you think I should use a List<SimDescription> instead? I will give it a try, thanks
Just to make sure :
<!-- ws:start:WikiTextCodeRule:0:
<pre class="text"> foreach (Sim otherSim in actors)<br/> {<br/> if (Relationship.Get(actor, otherSim, false) != null)<br/> {<br/> SimDescription otherDesc = otherSim.SimDescription as SimDescription;<br/> if (otherDesc != null && otherDesc.CreatedSim != null && !list.Contains(otherDesc))<br/> {<br/> list.Add(otherDesc);<br/> }<br/> }<br/> }<br/></pre>
-->
<style type="text/css"><!--
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.text {font-family:monospace;}
.text .imp {font-weight: bold; color: red;}
.text span.xtra { display:block; }
-->
</style><pre class="text">
foreach (Sim otherSim in actors)
{
if (Relationship.Get(actor, otherSim, false) != null)
{
SimDescription otherDesc = otherSim.SimDescription as SimDescription;
if (otherDesc != null && otherDesc.CreatedSim != null && !list.Contains(otherDesc))
{
list.Add(otherDesc);
}
}
}
</pre>
It's just a portion but is this what you meant?
<!-- ws:start:WikiTextCodeRule:0:
<pre class="text"> foreach (Sim otherSim in actors)<br/> {<br/> if (Relationship.Get(actor, otherSim, false) != null)<br/> {<br/> SimDescription otherDesc = otherSim.SimDescription as SimDescription;<br/> if (otherDesc != null && otherDesc.CreatedSim != null && !list.Contains(otherDesc))<br/> {<br/> list.Add(otherDesc);<br/> }<br/> }<br/> }<br/></pre>
-->
<style type="text/css"><!--
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.text {font-family:monospace;}
.text .imp {font-weight: bold; color: red;}
.text span.xtra { display:block; }
-->
</style><pre class="text">
foreach (Sim otherSim in actors)
{
if (Relationship.Get(actor, otherSim, false) != null)
{
SimDescription otherDesc = otherSim.SimDescription as SimDescription;
if (otherDesc != null && otherDesc.CreatedSim != null && !list.Contains(otherDesc))
{
list.Add(otherDesc);
}
}
}
</pre>
It's just a portion but is this what you meant?
ErrorTrap does not see "code", it sees the [Persistable] objects you save to the save-file.
So it sees the information you store in your classes member fields. In this case the "Relationships" field you mentioned in the second last post.
A "List<SimDescription> Relationships" member field would be preferable in my mind. Should save you running into logs from ErrorTrap.
Personally, I'm not a huge fan of any reference to a "Sim" object EA uses, and they like to use them a lot in their code.
"Sim" objects are deleted far too readily by the game (they are deleted whenever a homeless sim "goes home", and any time a sim is hard-reset by my mods), and are always popping up in referencing logs.