madmatty946 Posted October 23, 2016 Share Posted October 23, 2016 (edited) Hi, I am trying to do the following: * Make an object that can be built in workshop mode and that adds a menu to the workshop terminal if it is hooked up. This works.* When the menu item is clicked on the linked terminal, loop through all workshops and check how many items of a certain type exist in all workshops.* Display the number as a notification. My script compiles but when I exectue the menu point in the terminal nothing happens. Then, after a long time (like sleeping in a bed, leaving the settlement etc) it executes. Can someone explain what's wrong? Here is my script fragment: WorkshopScript[] allWorkshops = WorkshopParent.Workshops as WorkshopScript[] debug.notification("Starting script.") int total = 0 int i = 0 int ccount = 0 while (i < allWorkshops.Length) WorkshopScript curWS = allWorkshops[i] ;how many items are stored here? ccount = curWS.GetItemCount(Item) ;add number to the total count total += ccount i+=1 endWhile debug.notification("Total number is " + total) Game.GetPlayer().AddItem(Item,1) Edited October 23, 2016 by madmatty946 Link to comment Share on other sites More sharing options...
steve40 Posted October 25, 2016 Share Posted October 25, 2016 http://www.creationkit.com/fallout4/index.php?title=Performance_(Papyrus) Link to comment Share on other sites More sharing options...
madmatty946 Posted October 25, 2016 Author Share Posted October 25, 2016 (edited) http://www.creationkit.com/fallout4/index.php?title=Performance_(Papyrus)Could you maybe pinpoint where you think my code has a performance issue? Because the loop goes through O(10) entries and adds up numbers, I don't see why this should take minutes to run. Also, the notification in the first line of the script shows up only after minutes so it seems like the script doesn't event start until quite a while has passed.I honestly don't see where these 10 lines of code should have any performance issues. Edited October 25, 2016 by madmatty946 Link to comment Share on other sites More sharing options...
Recommended Posts