Struckur Posted April 10, 2018 Share Posted April 10, 2018 (edited) I'm trying to use the "FindAllReferencesOfType" function to list nearby objects but regardless of the type I use the result is always an empty array: Form property TYPETOFIND auto mandatory Event OnActivate(ObjectReference akActionRef) ObjectReference[] objs = Self.FindAllReferencesOfType(TYPETOFIND, 200.0) Debug.MessageBox( objs.length) EndEvent I've tried setting "TYPETOFIND" to several values in the creation kit UI such as 'STATIC' > 'ShackMetalWallFlat01'. Then built a lot of that object, but regardless the count I get back is always 0. I'm probably missing something simple and obvious so any help is appreciated! Edited April 10, 2018 by Struckur Link to comment Share on other sites More sharing options...
Reneer Posted April 10, 2018 Share Posted April 10, 2018 (edited) Your distance / radius variable is way too small. Try something like 5000 and go down from there. Edited April 10, 2018 by Reneer Link to comment Share on other sites More sharing options...
Struckur Posted April 10, 2018 Author Share Posted April 10, 2018 Your distance / radius variable is way too small. Try something like 5000 and go down from there.Well that was an embarrassingly obvious issue, thanks! Link to comment Share on other sites More sharing options...
shatsnazzle Posted April 10, 2018 Share Posted April 10, 2018 check out this for a cool unit size comparisonhttps://www.creationkit.com/index.php?title=Unit Link to comment Share on other sites More sharing options...
Struckur Posted April 10, 2018 Author Share Posted April 10, 2018 I don't suppose anyone knows a way to make that code more generic so it finds all static objects in the radius, not just ones of a single type? Link to comment Share on other sites More sharing options...
LeahTheUnknown Posted April 10, 2018 Share Posted April 10, 2018 FindAllReferencesOfType can target a formlist, so you could load all the statics you want to detect into one of those... Link to comment Share on other sites More sharing options...
Struckur Posted April 10, 2018 Author Share Posted April 10, 2018 (edited) FindAllReferencesOfType can target a formlist, so you could load all the statics you want to detect into one of those...Yep the only hesitation I have there is I'm hoping to find all statics, including those added by other mods, so potentially statics that I can't know the type of ahead of time. Essentially I'm working on a copy/paste mod that records all the objects in a given area when the player hits the copy activator and creates a new copy of all those objects when the player hits the paste activator. (This is already working in a primitive form) But I haven't been able to get the copy script to detect everything the player could have built in the area. Simplified Example: Scriptname ClipboardCopyPylonScript extends ObjectReference Const Form Property TYPETOFIND Auto Const ClipboardQuest Property CLIPBOARD_QUEST Auto Const Event OnActivate(ObjectReference akActionRef) CLIPBOARD_QUEST.Clear() ObjectReference[] objs = Self.FindAllReferencesOfType(TYPETOFIND, 5000.0) CLIPBOARD_QUEST.Copy(objs, Self) EndEvent Scriptname ClipboardPastePylonScript extends ObjectReference Const ClipboardQuest Property CLIPBOARD_QUEST Auto Const Event OnActivate(ObjectReference akActionRef) CLIPBOARD_QUEST.Paste(Self) EndEvent Scriptname ClipboardQuest extends Quest int[] CLIPBOARD_OBJECT float[] CLIPBOARD_POS_X float[] CLIPBOARD_POS_Y float[] CLIPBOARD_POS_Z float[] CLIPBOARD_SCALE float[] CLIPBOARD_ANGLE_X float[] CLIPBOARD_ANGLE_Y float[] CLIPBOARD_ANGLE_Z int clipboardIndex Function Clear() clipboardIndex = 0 EndFunction Function Copy(ObjectReference[] objs, ObjectReference baseObj) float sin = Math.sin(baseObj.GetAngleZ()) float cos = Math.cos(baseObj.GetAngleZ()) int i = 0 While (i < objs.length) CLIPBOARD_OBJECT[clipboardIndex] = objs[i].GetBaseObject().GetFormID() CLIPBOARD_SCALE[clipboardIndex] = objs[i].GetScale() CLIPBOARD_ANGLE_X[clipboardIndex] = objs[i].GetAngleX() CLIPBOARD_ANGLE_Y[clipboardIndex] = objs[i].GetAngleY() CLIPBOARD_ANGLE_Z[clipboardIndex] = objs[i].GetAngleZ() - baseObj.GetAngleZ() float relativeX = objs[i].X - baseObj.X float relativeY = objs[i].Y - baseObj.Y CLIPBOARD_POS_X[clipboardIndex] = relativeX * cos - relativeY * sin CLIPBOARD_POS_Y[clipboardIndex] = relativeY * cos + relativeX * sin CLIPBOARD_POS_Z[clipboardIndex] = objs[i].Z - baseObj.Z clipboardIndex += 1 i += 1 EndWhile Debug.MessageBox("Copied " + i + " Item(s).") EndFunction Function Paste(ObjectReference baseObj) float sin = Math.sin(-baseObj.GetAngleZ()) float cos = Math.cos(-baseObj.GetAngleZ()) int i = 0 While (i < clipboardIndex) Form objForm = Game.GetForm(CLIPBOARD_OBJECT[i]) ObjectReference newObj = baseObj.PlaceAtMe(objForm) float relativeX = CLIPBOARD_POS_X[i] * cos - CLIPBOARD_POS_Y[i] * sin float relativeY = CLIPBOARD_POS_Y[i] * cos + CLIPBOARD_POS_X[i] * sin newObj.MoveTo(baseObj, relativeX, relativeY, CLIPBOARD_POS_Z[i]) newObj.SetScale(CLIPBOARD_SCALE[i]) newObj.SetAngle(CLIPBOARD_ANGLE_X[i], CLIPBOARD_ANGLE_Y[i], CLIPBOARD_ANGLE_Z[i] + baseObj.GetAngleZ()) i += 1 EndWhile Debug.MessageBox("Pasted " + i + " Item(s).") EndFunction Event OnInit() CLIPBOARD_OBJECT = new int[128] CLIPBOARD_POS_X = new float[128] CLIPBOARD_POS_Y = new float[128] CLIPBOARD_POS_Z = new float[128] CLIPBOARD_SCALE = new float[128] CLIPBOARD_ANGLE_X = new float[128] CLIPBOARD_ANGLE_Y = new float[128] CLIPBOARD_ANGLE_Z = new float[128] clipboardIndex = 0 Debug.MessageBox("Clipboard Quest Initialized") EndEvent Edited April 10, 2018 by Struckur Link to comment Share on other sites More sharing options...
Recommended Posts