LeahTheUnknown Posted April 8, 2018 Share Posted April 8, 2018 I am trying to update my Backbreaker - Big Junk mod by rebuilding the mod from the ground up (I know a lot more about mod-making now). However, I wanted to give the six or seven people still using the original a patch to update the junk they have already collected. I created a chem that has the following script. However, nothing actually happens and I get this as a result: Scriptname updatebigjunk extends activemagiceffect Group ArraysAndSuch MiscObject[] Property NewJunkArray Auto FormList Property OldJunkList Auto Message Property CompleteMessage Auto MiscObject[] Property ScrapArray Auto Potion Property UpdateChem Auto endGroup Group AutoStuff MiscObject Property C_Wood_Scrap Auto MiscObject Property C_Cloth_Scrap Auto MiscObject Property C_Concrete_Scrap Auto MiscObject Property C_Steel_Scrap Auto MiscObject Property C_Oil_Scrap Auto MiscObject Property C_Rubber_Scrap Auto Container Property WorkshopWorkbench Auto endGroup Event OnEffectStart(Actor None1, Actor None2) Actor Player = Game.GetPlayer() Player.AddItem(UpdateChem, 1, TRUE) ObjectReference Target = Game.FindClosestReferenceOfType(WorkshopWorkBench, Player.GetPositionX(), Player.GetPositionY(), Player.GetPositionZ(), 5000) Float TotalItemCount = 0 Int ReplaceNo = 0 Int Counter2 = 0 While Counter2 < 124 ReplaceNo = Target.GetItemCount(OldJunkList.GetAt(Counter2)) TotalItemCount = TotalItemCount + ReplaceNo Target.RemoveItem(OldJunkList.GetAt(Counter2), ReplaceNo, TRUE) Target.AddItem(NewJunkArray[Counter2], ReplaceNo, TRUE) Counter2 += 1 endwhile int Tabulate if Target.GetItemCount(ScrapArray[1]) > 0 Tabulate = Target.GetItemCount(ScrapArray[1]) TotalItemCount = TotalItemCount + Tabulate Target.RemoveItem(ScrapArray[1], Tabulate, TRUE) Target.AddItem(C_Concrete_Scrap, 12 * Tabulate, TRUE) endIf if Target.GetItemCount(ScrapArray[2]) > 0 Tabulate = Target.GetItemCount(ScrapArray[1]) TotalItemCount = TotalItemCount + Tabulate Target.RemoveItem(ScrapArray[2], Tabulate, TRUE) Target.AddItem(C_Steel_Scrap, 8 * Tabulate, TRUE) Target.AddItem(C_Oil_Scrap, 3 * Tabulate, TRUE) Target.AddItem(C_Rubber_Scrap, 2 * Tabulate, TRUE) endIf if Target.GetItemCount(ScrapArray[3]) > 0 Tabulate = Target.GetItemCount(ScrapArray[1]) TotalItemCount = TotalItemCount + Tabulate Target.RemoveItem(ScrapArray[3], Tabulate, TRUE) Target.AddItem(C_Cloth_Scrap, 2 * Tabulate, TRUE) endIf if Target.GetItemCount(ScrapArray[4]) > 0 Tabulate = Target.GetItemCount(ScrapArray[1]) TotalItemCount = TotalItemCount + Tabulate Target.RemoveItem(ScrapArray[4], Tabulate, TRUE) Target.AddItem(C_Wood_Scrap, 8 * Tabulate, TRUE) endIf CompleteMessage.Show(TotalItemCount) EndEvent Any help would be greatly appreciated, I've been tearing my hair out for two hours on this thing. ~GKX Link to comment Share on other sites More sharing options...
akiras404 Posted April 8, 2018 Share Posted April 8, 2018 I don't think this will solve your problem, but your Tabulate = Target.GetItemCount(ScrapArray[1])always counting ScrapArray[1] (not ScrapArray[2], ScrapArray[3], ScrapArray[4]). "nothing actually happens" means, you checked workshop after using chem and nothing in inventory changed?Did you try using chem repeatedly? (I suspect somehow you got wrong container.) Link to comment Share on other sites More sharing options...
shatsnazzle Posted April 8, 2018 Share Posted April 8, 2018 (edited) I haven't looked too much into the workshop container system but it looks like a lot of the WorkshopWorkBench references (I didn't check all of them) are linked to a dummy chest underground or behind a wall. Maybe give that container a shot? keyword property WorkshopLinkContainer auto ObjectReference DummyContainerREF = YourWorkshopWorkbench.GetLinkedRef(WorkshopLinkContainer)Also if you want a reference to each of the workshops all at once you could check the RefCollectionAlias in WorkshopParent quest. The WorkshopParentScript has a pointer to it called WorkshopsCollection. WorkshopParentScript property WorkshopParent auto int counter while counter < WorkshopParent.WorkshopsCollection.GetCount() objectreference YourWorkshopWorkbench = WorkshopParent.WorkshopsCollection.GetAt(counter) ;do stuff counter = counter + 1 endwhileHowever in the RefCollectionAlias, Home Plate does not meet the conditions to be included because its location seems to be lacking the necessary keyword so you'll have to add an extra few lines to get that reference too. Edited April 10, 2018 by shatsnazzle Link to comment Share on other sites More sharing options...
kitcat81 Posted April 8, 2018 Share Posted April 8, 2018 (edited) This is a script I used to get all workshop actors and add them to ref collection. Though some actors seem to disappear when unloaded... so the accuracy is only near to 90% , it still allows to obtain all workshops and run functions on them. You can try and adjust it for your needs. WorkshopScript[] workshopArray = WorkshopParent.Workshops int index = 0 while index < WorkshopArray.Length If WorkshopArray[index].OwnedByPlayer==true ObjectReference[] workshopNPCs = WorkshopParent.GetWorkshopActors(WorkshopArray[index] as WorkshopScript) If workshopNPCs mycount = mycount+workshopNPCs.length WorkshopActors.AddArray(workshopNPCs) Endif Endif index += 1 endWhile Edited April 8, 2018 by kitcat81 Link to comment Share on other sites More sharing options...
LeahTheUnknown Posted April 8, 2018 Author Share Posted April 8, 2018 I don't think this will solve your problem, but your Tabulate = Target.GetItemCount(ScrapArray[1])always counting ScrapArray[1] (not ScrapArray[2], ScrapArray[3], ScrapArray[4]). Yeah, I caught this after I posted... WorkshopWorkBench references (I didn't check all of them) are linked to a dummy chest underground or behind a wall. Maybe give that container a shot? Aaand this might be it. I hadn't thought of that. it still allows to obtain all workshops and run functions on them. Not a bad idea, tbh. Would be a lot quicker if it did all the workshops at once. Thanks for the suggestions and tips, folks! ~GKX Link to comment Share on other sites More sharing options...
LeahTheUnknown Posted April 8, 2018 Author Share Posted April 8, 2018 (edited) Ok, the script works, but now I have a different problem: I fill in NewJunkArray with the MiscObject forms from Big Junk Redux, then the game blanks the array because it can't find the items in the Transition plugin. When I copy the forms over with FO4Edit (from both Big Junk plugins), the script looks for the forms from the transition patch, and doesn't actually replace anything from 2.5. I'm about to give up and just merge the two Big Junk plugins, making it an optional file for people who had the old mod. Edit: That doesn't work, either. The old junk still goes away when I remove the old plugin. sigh ~GKX Edited April 8, 2018 by GenghisKhanX Link to comment Share on other sites More sharing options...
kitcat81 Posted April 8, 2018 Share Posted April 8, 2018 (edited) Ok, the script works, but now I have a different problem: I fill in NewJunkArray with the MiscObject forms from Big Junk Redux, then the game blanks the array because it can't find the items in the Transition plugin. When I copy the forms over with FO4Edit (from both Big Junk plugins), the script looks for the forms from the transition patch, and doesn't actually replace anything from 2.5. I'm about to give up and just merge the two Big Junk plugins, making it an optional file for people who had the old mod. Edit: That doesn't work, either. The old junk still goes away when I remove the old plugin. sigh ~GKXif you mean that the objects you want to find are from another plugin , you can use GetFormFromFile function. And also IsPluginInstalled. I understand it that you want to help people to avoid losing components when undating your mod. If so, you can make an update for the old mod that would be the same old plugin, but with the chem that allows to scrap all stuff before uninstalling. So they have to install that update and then replace it with new rebuild version. Edited April 8, 2018 by kitcat81 Link to comment Share on other sites More sharing options...
Recommended Posts