Jump to content

Recommended Posts

Posted (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] := NPCref

let 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 by PrettyMurky
Posted

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

Posted

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.

Posted (edited)
Deleted due the fact that the question was already answered in the response of fg109 in his code example. Thanks everyone! Edited by hawke1133
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...