inomoz Posted October 4, 2017 Share Posted October 4, 2017 (edited) Skyrim SE, Newbie in mod making, quest script: Hi, I'm trying find way to temprorary place objects (alchemy items, like cheese), then wait some time, then delete them. This code works: ObjectReference cheese1 = Game.GetPlayer().PlaceAtMe(Game.GetForm(0x00064b33)) .... ObjectReference cheese3 = Game.GetPlayer().PlaceAtMe(Game.GetForm(0x00064b33)) utility.wait(5) cheese1.Delete() ... cheese3.Delete() It's laggy and not optimal.. I tryed use some like this ObjectReference cheeses = Game.GetPlayer().PlaceAtMe(Game.GetForm(0x00064b33), 50) utility.wait(5) ;cheeses.Disable() cheeses.Delete() Not working, objects not deleting, as I undesrtand this objects become not unic and I can't delete them? I tried use arrays - no success... Edited October 4, 2017 by inomoz Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 4, 2017 Share Posted October 4, 2017 (edited) You cannot store a stack of objects within a single variable. If you are wanting to spawn 50 of an object and then delete them, you'll need to do a different approach. Here is an untested array approach. ;property and variable declarations ObjectReference[] CheeseArray ;events and functions Event OnInit() CheeseArray = new ObjectReference[50] EndEvent ;some event SpawnAndStoreInArray(Game.GetFormFromFile(0x00064b33,"Skyrim.esm"),50) Utility.wait(5) DeleteAndRemoveFromArray(50) ;end some event Function SpawnAndStoreInArray(Form MyObj, Int Total) Int Index = 0 While Index < Total CheeseArray[Index] = Game.GetPlayer().PlaceAtMe(MyObj) Index += 1 EndWhile EndFunction Function DeleteAndRemoveFromArray(Int Total) Int Index = 0 While Index < Total ObjectReference CheeseObj = CheeseArray[Index] CheeseObj.Delete() CheeseArray[Index] = NONE Index += 1 EndWhile EndFunctionCreates the array in the OnInit eventRetrieves the desired object from the game and sends it along with desired amount to the SpawnAndStoreInArray functionAssigns a new instance of the object to each index of the array.waits some timeSends the desired amount to the DeleteAndRemoveFromArrray functionRetrieves the desired object reference from the array and deletes itFinally, gives the current entry an empty value EDIT: See later post for reason. Edited October 4, 2017 by IsharaMeradin Link to comment Share on other sites More sharing options...
inomoz Posted October 4, 2017 Author Share Posted October 4, 2017 (edited) Thank you!I created similar arrays solution, but forgot something (CheeseArray[index] = NONE). I'll check your solution Edited October 4, 2017 by inomoz Link to comment Share on other sites More sharing options...
inomoz Posted October 4, 2017 Author Share Posted October 4, 2017 Spawn not worked, I little changed functions: SpawnAndStoreInArray((Game.GetFormFromFile(0x00064b33,"Skyrim.esm")),50)... Function SpawnAndStoreInArray(Form MyObj, Int Total)... Some like this Thanks again Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 4, 2017 Share Posted October 4, 2017 Realized that I had a mistake in there right before going to bed but I had already turned the computer off. Decided to wait till morning to correct it. Seems you've already resolved it as that is exactly what I needed to correct. Editing the above post anyway... Link to comment Share on other sites More sharing options...
Recommended Posts