PrettyMurky Posted April 24, 2011 Share Posted April 24, 2011 (edited) I am trying to get my mod to keep an array of information on recent NPCs, in which I use the FormID to check if a new NPC is already dealy with. Essentially: let Array [0] [0] := NPCreflet TempRef := Array [0] [0]if TempRef == NPCref message "it is working"endif Obviously that is not what it will be doing eventually, but to achieve that, I need the mechanics therein to work. Sadly, they do not. I need to know how to add a formID to an array in a way that I can check back later (with a While count < limit , if Array [count] [0] == NPCref) to see if it is in there. Can anyone help with this please? Edit:The title to this post is meant to be 'References within Arrays', but it's too late to change that now it seems... Edited April 24, 2011 by PrettyMurky Link to comment Share on other sites More sharing options...
fg109 Posted April 24, 2011 Share Posted April 24, 2011 What do you mean that it doesn't work? Are you unable to compile it or what? Here are some things that might be wrong with your code: 1. There aren't supposed to be any spaces in Array[0][0].2. Array[0][0] refers to the first element in the array "Array[0]", which is itself the first element in the array "Array".3. Array variables usually need to be initialized with the "ar_Construct" function. So you might want to change your code to something like this: let Array := ar_Constuct Array let Array[0] := ar_Construct array let Array[0][0] := NPCref let TempRef := Array[0][0] if TempRef == NPCref message "it is working" endif Link to comment Share on other sites More sharing options...
PrettyMurky Posted April 24, 2011 Author Share Posted April 24, 2011 Sorry. I guess I could have been clearer. It is compiling, and the game loads fine. However I'm not getting the "it is working" message. Although looking at your correction. I didn't realise that I have to do another ar_Construct array for each nested array. I'll try that now, and see how it works. Link to comment Share on other sites More sharing options...
PrettyMurky Posted April 24, 2011 Author Share Posted April 24, 2011 Beautiful! Works fine now. Kids. The moral of this story is: Arrays within arrays need to be constructed, not just their parent arrays! Thanks fg109! Link to comment Share on other sites More sharing options...
hawke1133 Posted April 30, 2011 Share Posted April 30, 2011 (edited) Deleted due the fact that the question was already answered in the response of fg109 in his code example. Thanks everyone! Edited April 30, 2011 by hawke1133 Link to comment Share on other sites More sharing options...
Recommended Posts