Author Topic: Could use a lil help with a few scripts.  (Read 1288 times)

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Could use a lil help with a few scripts.
« Reply #30 on: September 23, 2011, 09:30:21 pm »


               Well unfortunately this didn't work. It still stops working after a short while. Really odd that it works for a short while after a restart, but then just stops. There has to be something that is interfering with that is delayed for a little while after a restart before it executes.
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Could use a lil help with a few scripts.
« Reply #31 on: September 25, 2011, 04:20:05 am »


               I was thinking about your bug, and I think it comes down to who the script is being executed on.  In the standard OnActivateItem, the module is the one executing the item script, since it's OBJECT_SELF, and that's where the even variable is being store.

 In your script, the PC is the one the script is being executed on, so they become OBJECT_SELF in the activation script, and that's where the event ID is checked.

To test, try manually setting the variable like this:
SetLocalInt (oPC,"X2_L_LAST_ITEM_EVENT", X2_ITEM_EVENT_ACTIVATE);

between these lines in your script:

SetUserDefinedItemEventNumber(X2_ITEM_EVENT_ACTIVATE);
// <=---  Insert SetLocalInt command here, before the ExecuteScript call is made, to test.
PrintString( "[ mod_onactivate ] Calling " + sTag + " for item: " + GetName( oItem ));
ExecuteScript( sTag, oPC );
               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Could use a lil help with a few scripts.
« Reply #32 on: September 25, 2011, 09:59:40 am »


               Hmm, ty FB, I could give this a shot as this version is much more in alignment with the original intent than the workaround (or alternate version) I am currently using. However, if I try this, you say I could test this, but I am not sure what results I would be looking for?
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Could use a lil help with a few scripts.
« Reply #33 on: September 25, 2011, 10:10:54 am »


               Well, adding the variable won't change anything else, it's simply a variable on the PC that'll be overwritten next time they're OBJECT_SELF in an event call. "Testing" in this case just means to try it, and see if the item still stops working after awhile.

The other way to test would be to change the execution to OBJECT_SELF, but that might affect other scriptsdoing the testing that way. That's why I figured the direct setting of the variable was the better way to try.


Edit:  It looks like X2_ITEM_EVENT_SPELLCAST_AT runs with the PC as OBJECT_SELF, so that might be the event that was triggering that made (or makes, if setting the variable manually doesn't fix it) it stop.
               
               

               


                     Modifié par Failed.Bard, 25 septembre 2011 - 09:18 .
                     
                  


            

Legacy_Axe_Murderer

  • Full Member
  • ***
  • Posts: 199
  • Karma: +0/-0
Could use a lil help with a few scripts.
« Reply #34 on: September 25, 2011, 08:44:21 pm »


               Are you sure the script isn't getting called? I'd put some kind of debug output into it to be positive it actually stops running. Maybe it's running but some condition exists after a time which prevents the stuff you're doing in the script from having any effect. You need to debug the script and trace the value of all the variables in it to ensure the line that's supposed to do whatever isn't happening is truly not getting executed, and why...or if it is what parameter values are you sending it that's causing it to fail.
               
               

               
            

Legacy_Lazarus Magni

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
Could use a lil help with a few scripts.
« Reply #35 on: September 26, 2011, 12:13:24 am »


               Well this seems to work Faided.Bard! Thank you very much. Will take some more extensive testing to be sure, but so far so good as I haven't been able to reproduce the bug yet. Thank you everyone!