Full Version : OnTarget update properties
xmlspawner >>Q&A >>OnTarget update properties


<< Prev | Next >>

Lord Hog Fred- 08-13-2006
I am trying to update the XmlValue of an object once an item has been targetted, I have tried severeal different things and none of them seem to work.

This is the code I am using:
CODE

XmlValue a = (XmlValue)XmlAttach.FindAttachment(from, typeof(XmlValue), "Points");

XmlValue b = (XmlValue)XmlAttach.FindAttachment(m_PointStone, typeof(XmlValue), "PointsTaken");

  if ( targeted is PointToken )
  {
   PointToken token = (PointToken)targeted;
   
   int tokens = ((PointToken)targeted).Amount;
   
   if(a != null)
   {
      // found the attachment so add 15 to the Value property
      a.Value += (1 * tokens);
      token.Delete();
   }

   if(b != null)
   {
      b.Value += (1 * tokens);
   }
  }


m_PointStone is the item I am trying to update the value on but it doesn't seem to be working. It updates the XmlValue on the player fine but it isn't updating the value on the stone the target is derived from.
Any ideas?
Thanks smile.gif,


ArteGordon- 08-13-2006
looks ok to me.

I would double check the value of m_PointStone to make sure it points to what you think it does. Then I would double check to make sure the attachment is actually on the stone and has the exact name you are using ("PointsTaken"). I'm guessing its just a typo in the name.

XmlValue b = (XmlValue)XmlAttach.FindAttachment(m_PointStone, typeof(XmlValue), "PointsTaken");

Lord Hog Fred- 08-13-2006
Thanks Arte, I was looking in the wrong place the Stone script wasn't producing the target with the right variables tis working fine now smile.gif.