Is it a good idea to use string map arrays to associate references? Feel free to discuss your opinion, too.
The idea is to mark some location with a marker reference. An AI package tracks the reference, affecting behavior of a creature.
For each creature that the mod changes, give it a unique marker. (One marker for each creature.)
Basic idea:
ref creature ; some selected creature by external scriptref markerRef ; marker the AI package targetsarray_var markers ; the association between creatures and markers!array_var itemshort newMarkerif eval !(markers) ; array not initialised before let markers := ar_Construct StringMapendifForEach item <- markers ; check if this creature has a marker already associated if eval creature := item["key"] let markerRef := item["value"] ; already has one, get marker else let newMarker := 1 ; doesn't have one, lets give the creature a new marker endifloopif newMarker let markerRef := CloneForm xMarkerRef ; xMarkerRef is the one created in the CS Editor let markers[creature] := markerRef ; associate the creature with the marker let newMarker := 0endif; do stuff with markermarkerRef.MoveTo player; update creature AIif eval !(creature.GetIsCurrentPackage somePkgWithMarker) creature.AddScriptPackage somePkgWithMarker creature.EvaluatePackageendif
This doesn't work. The error goes like: "Invalid operands for operator [."
To make it work you have to do like this:
let markers[$(creature)] := markerRef
The problem is, when calling toString (or the "$" sign) on a reference, it takes the object name if it has one. However, different objects may have the same name.
I just want to associate two objects by taking their references.
It is meant to pass the object ID (or ref) to the StringMap array and check if there is one. If $(creature) passes a string with the name instead of the ID, then it's not good.
What do you propose?