drkaii Posted March 22, 2012 Share Posted March 22, 2012 (edited) This is a bit of code that cycles through a list of local NPCs that was built previously, and sets the value rTarget to the previous or next in the list, depending on which key you press. I have checked that the list builds correctly, and that the variables end up correct too. So if there are 4 in the list, IRefsListTotal = 4. If IsKeyPressed iKeyPress == 0 set iKeyPress to 0 If IsKeyPressed NextTargetKey set iKeyPress to NextTargetKey set iSetting to 1 set iRefsListCounter to iRefsListCounter + 1 If iRefsListCounter >= iRefsListTotal ;I checked this value, it is correct set iRefListCount to 0 EndIf set rTarget to ListGetNthForm RefsList iRefListCount set iPlayerTarget to -1 set iCentered to -1 rTarget.PMS bluepulse 3 PlaySound Bell 1 ShowMessage NewTarget rTarget rTarget set iRefreshValues to 1 EndIf If IsKeyPressed PrevTargetKey set iKeyPress to PrevTargetKey set iSetting to 1 set iRefsListCounter to iRefsListCounter - 1 If iRefsListCounter < 0 set iRefsListCounter to iRefsListTotal - 1 ;I checked this value, it is correct EndIf set rTarget to ListGetNthForm RefsList iRefListCount set iPlayerTarget to -1 set iCentered to -1 rTarget.PMS bluepulse 3 PlaySound Bell 1 ShowMessage NewTarget rTarget rTarget set iRefreshValues to 1 EndIf EndIf ;All the variable names are correct, all the references are correct. It is definitely this part of my script that is causing the problems. The whole code is over 600 lines long, so there is a possibility that this part mucks up something elsewhere, but it seems unlikely. My understanding of lists could be the problem, so I post this here in case anyone else can spot something obvious. As soon as I click either the PrevTargetKey or the NextargetKey, the game crashes. Any ideas? Cheers Edited March 22, 2012 by drkaii Link to comment Share on other sites More sharing options...
rickerhk Posted March 22, 2012 Share Posted March 22, 2012 Nothing real obvious. Just covering some bases here -The only thing I see out of the ordinary is you are passing ref variables to the showmessage function, which is expecting a short or a float. If it's there just for debugging you can use this instead: printc "Target is %n %i ",rTarget, rTarget Are you obtaining iRefsListTotal with ListGetCount? I know if you go past the end of the form list you will crash. Also, if rTarget is Null, rtarget.pms is likely to crash. The pms object itself could be causing it. I've had that happen to me. Also, when you launch the game, you can type:scof "Mydebugfile.txt" Then sprinkle printc commands before and after functions where you think it might crash. The last line in the text file will give you a hint most of the time. You have to type the scof command every time you launch the game. Link to comment Share on other sites More sharing options...
Recommended Posts