IsharaMeradin Posted March 24, 2020 Share Posted March 24, 2020 The big issue with scripts is when a lot of them are running at the same time. Your script might only fire once under certain circumstances but other scripts might be triggered at the same moment. When a lot is trying to happen stack dumps can occur. The game will seem to continue just fine but behind the scenes some things may not have done what they were supposed to do. This can cause issues down the road depending upon what was supposed to happen. The important thing is to be smart about your scripting. If you are using a player alias script to determine when a specific object is added to the player inventory, an inventory event filter is very important. Otherwise your script will run for EVERY object added. Even if you have appropriate checks in place to stop execution should the object not be what you want, the damage is already done -- your script will be processing with every thing else and contributing to any potential stack dumps. But to answer the question, no. A large number of scripts is not a direct correlation to causing the game to crash or have issues with save files. If that were the case, people would be having issues in much greater numbers with just the base game. I highly doubt that there is a single mod that provides as many scripts as the game itself. It boils down to how smart / careful the coding was done rather than the sheer number of scripts. Link to comment Share on other sites More sharing options...
aoh125 Posted March 24, 2020 Author Share Posted March 24, 2020 (edited) Alright thanks for attempting to clear that up for me (im kinda thick headed so not sure i get all of what you said lol). I realize in your second paragraph you are speaking of player alias's but just in an attempt to see if im over complicating or playing it safer i modified my current script to use a formlist filter and see if im getting the right idea here. Now would it be safer/less likly to cause issues by doing it this way or is it just extra scripting that isnt really needed in this case. ObjectReference Property BMI_BB1Ref Auto ;Bulk Book ref Perk Property BMI_TradecertificatePerk Auto Actor Property PlayerRef Auto Formlist Property BMI_BooksFormList Auto Book Property BMI_TradeCertificate01 Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akNewContainer == PlayerREF && BMI_BooksFormList.HasForm(BMI_TradeCertificate01) PlayerRef.AddPerk(BMI_TradecertificatePerk) BMI_BB1Ref.Enable() EndIf EndEvent This was the original ObjectReference Property BMI_BB1Ref Auto ;Bulk Book ref Perk Property BMI_TradecertificatePerk Auto Actor Property PlayerRef Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akNewContainer == PlayerREF PlayerRef.AddPerk(BMI_TradecertificatePerk) BMI_BB1Ref.Enable() EndIf EndEvent Sorry for my ignorance and frequent questions but i dont want to make mods that hinder peoples gameplay experiences. Edited March 24, 2020 by aoh125 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 24, 2020 Share Posted March 24, 2020 OnContainerChanged is an event that runs specifically when the object holding that script changes container. Unless there are a lot of objects with such a script attached being dumped into a container one after another, this should not cause any issue. Your original should be fine. The other is unnecessary. Tho depending upon purpose, if you only need this to run the first time the book enters the player inventory, then you may want to consider utilizing states so that it runs the first time to apply the perk and enable the object but doesn't try to do so again should the player stash the book and retrieve it later. Link to comment Share on other sites More sharing options...
aoh125 Posted March 24, 2020 Author Share Posted March 24, 2020 (edited) Yea that thought had crossed my mind about it changing inventory and readding the perk or well attempting to. The objects are set to not respawn so that shouldnt be effected but any time the book changes inventories it will set or try to set the global again atm. I doubt it would mess up that value to anything else but might cause unforeseen issues. Havent tried doing states for anything yet but is something i have been looking into recently. Might try something a bit simpler though. Using an int property and just setting it above 0 the first time so that it fails any future attempts when changing inventories. Just altered it with the int added ObjectReference Property BMI_BB1Ref Auto ;Bulk Book ref Perk Property BMI_TradecertificatePerk Auto Actor Property PlayerRef Auto Int Property ROVar = 0 Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akNewContainer == PlayerREF && ROVar == 0 PlayerRef.AddPerk(BMI_TradecertificatePerk) BMI_BB1Ref.Enable() ROVar = 1 Debug.Notification("working?") EndIf EndEvent Seems to be doing the trick. (: Edited March 24, 2020 by aoh125 Link to comment Share on other sites More sharing options...
NexusComa Posted March 24, 2020 Share Posted March 24, 2020 When I 1st started to mod Skyrim being a programmer in real life the 1st thing I did was over script a mod. It was to the point I did notice a "lag" type effect on my scripts. That really was a drag and made me start looking around for way to optimize them to work better or at least smoother. Didn't find anything that helped. I'm talking over 100 scripts running in the same mod. Then one day I was looking at one of the programmers that made some of the games scripts. If you really look at them you can tell they were made by a few different people. But one persons style is very different than the rest. He/she also had very long complicated scripts. With many in the same area. The big difference was how he/she set up where the script is "resting" with the way states and functions were used. Here is my Craps game script from my mod The Enchanted Ship in a Bottle. Instead of letting the script sit on the Event OnActivate as most scripts do. I've adopted that programmers style.Scriptname Ship00_Craps Extends ObjectReference;*Craps * By: NexusComa ;* nexusmods.comSound Property DiceRoll AutoObjectReference Property Cup AutoObjectReference Property Dice_11 AutoObjectReference Property Dice_12 AutoObjectReference Property Dice_13 AutoObjectReference Property Dice_14 AutoObjectReference Property Dice_15 AutoObjectReference Property Dice_16 AutoObjectReference Property Dice_21 AutoObjectReference Property Dice_22 AutoObjectReference Property Dice_23 AutoObjectReference Property Dice_24 AutoObjectReference Property Dice_25 AutoObjectReference Property Dice_26 AutoObjectReference Property R1 AutoObjectReference Property R2 AutoMiscObject Property Gold001 AutoActor Property PlayerRef AutoInt Property GFD AutoInt GF ;Gold FlagInt KF ;Kick FlagInt WF ;Win FlagInt RC ;Roll CounterInt RT ;Roll TargetInt D1 ;rnd Dice 1Int D2 ;rnd Dice 2Float RX ;1di Rnd XFloat RY ;1di Rnd YInt DR ;2Di Rnd flagFloat DX ;2Di X offsetFloat DY ;2Di Y offsetImport DebugImport UtilityEvent OnInit() GoToState("Done")EndEvent;------------Event OnActivate(ObjectReference akActionRef) If(akActionRef==(PlayerRef)) Self._Craps() If(WF==(1)) PlayerRef.AddItem(Gold001, (GF*2)) ;* Add Gold Endif EndifEndEvent;------------Function _Craps() If(KF==(0)) KF=(1) WF=(0) RC=(0) GF=(0) RT=(0) GF=(GFD) Cup.Disable() If(PlayerRef.GetItemCount(Gold001)>=(GF)) PlayerRef.RemoveItem(Gold001, GF) ;* Take While RC<=(3) RC+=(1) Self._Roll() If(D1+D2)!=(2) If(RC==(1)) RT=(D1+D2) If(D1+D2)==(7) Wait(4.0) PlayerRef.AddItem(Gold001, (GF*2)) ;* Add Gold Self._Roll() If(D1+D2)!=(2) If(D1+D2)==(11) WF=(1) RC=(4) Else WF=(0) RC=(4) Endif Else Notification("Snake Eyes") WF=(0) RC=(4) Endif Endif Else If(RT==(D1+D2)) WF=(1) RC=(4) Endif Endif Else Notification("Snake Eyes") WF=(0) RC=(4) Endif Wait(4.0) EndWhile Else Notification("50 gold bet, Not enough gold to play this game") Wait(4.0) Endif R1.Disable() R2.Disable() Cup.Enable() KF=(0) EndifEndFunction;------------Function _Place() RX=(RandomFloat(2280.0, 2300.0)) RY=(RandomFloat(2460.0, 2490.0)) R1.SetPosition(RX, RY, 247.83) R1.SetAngle(0.0, 0.0, RandomFloat(0.0, 315.0)) DR=(RandomInt(0, 1)) If(DR==(0)) DX=(RandomFloat(4.0, 9.0)) DY=(RandomFloat(4.0, 9.0)) Else DX=(RandomFloat(-9.0, -4.0)) DY=(RandomFloat(-9.0, -4.0)) EndIf RX=RX+(DX) RY=RY+(DY) R2.SetPosition(RX, RY, 247.83) R2.SetAngle(0.0, 0.0, RandomFloat(0.0, 315.0)) R1.Enable() Wait(0.1) R2.Enable()EndFunction;------------Function _Roll() R1.Disable() R2.Disable() DiceRoll.Play(Self) Wait(1.5) D1=(RandomInt(1, 6)) If(D1==(1)) R1=(Dice_11) ElseIf(D1==(2)) R1=(Dice_12) ElseIf(D1==(3)) R1=(Dice_13) ElseIf(D1==(4)) R1=(Dice_14) ElseIf(D1==(5)) R1=(Dice_15) ElseIf(D1==(6)) R1=(Dice_16) Endif D2=(RandomInt(1, 6)) If(D2==(1)) R2=(Dice_21) ElseIf(D2==(2)) R2=(Dice_22) ElseIf(D2==(3)) R2=(Dice_23) ElseIf(D2==(4)) R2=(Dice_24) ElseIf(D2==(5)) R2=(Dice_25) ElseIf(D2==(6)) R2=(Dice_26) Endif Self._Place()EndFunction;;State Done ;do nothingEndState;As you can see this is a very complex script (for a Skyrim script). But by using the Goto Done right off the bat style it hardly leaves a footprint on the stack. My ship mod is running 100's of scripts like this at the same time ...But the stack acts like there hardly nothing being ran at all. This works so well it's shocking. Clearly the programmer that did it this way knew a bit more about how the stack is called than the rest. Also whenyou're not in the cell where the scripts are they totally sit idle in the done state. Some may disagree here but ... "this is the way" ... :thumbsup: Link to comment Share on other sites More sharing options...
NexusComa Posted March 24, 2020 Share Posted March 24, 2020 I got It! ... little bit of brain damage but I'll live ...1st go watch this SKSE INFOAnd here is the script snip ... you will need to add a one time flag variable like you was doing ... Actor Property PlayerRef Auto Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) If akNewContainer == PlayerREF Input.TapKey(1) ; 1 is the esc key Utility.Wait(0.1) ; a bit quick but it worked for me. may want to go a bit longer ... like 0.5 Input.TapKey(1) EndIfEndEvent Link to comment Share on other sites More sharing options...
NexusComa Posted March 24, 2020 Share Posted March 24, 2020 @IsharaMeradin you were right but that will not shut all menus. Books and player inventory work with that method. From my tests. Link to comment Share on other sites More sharing options...
aoh125 Posted March 24, 2020 Author Share Posted March 24, 2020 (edited) Didnt actually try your enchanted ship in a bottle mod but did watch the review vid you have linked. Thing looks rather tight and can tell by the attention to detail that you put a ton of effort into making it. Judging strictly by the gameplay i witnessed i think it would be a bit tight for my liking (no offense just a lot of tiny spaces to get threw) but holy everything has a toggle from what i seen lol. Going to check out that vid you linked a couple posts back now. been working on adding a player home castle thing to my black marker island for the past several hours. Thanks for taking the time to pull out that info and writing up that script ot try if i manage to get skse scripts running on my ck. Oh almost forgot, that dice script does look pretty elaborate xD. The one from windstad mine (think it was called) was the one i have been eyeballing trying to get a solid idea of how states work. Yea i seen that tut. Well seen probably about 70-90% of his in general. His and a few other peoples vids are the main reason i can do anything half decent with modding skyrim. I wouldnt have had the drive or devotion to learn if i had to read threw written tutorials since im more of a visual learner. I had already tried that meathod of install but appreciate the efforts just the same xD Edited March 24, 2020 by aoh125 Link to comment Share on other sites More sharing options...
NexusComa Posted March 24, 2020 Share Posted March 24, 2020 There is a Ship Scripts download. It's full of home style scripts and techniques. You may want to check it out and the ship. There is so much more there than you may think. I have more time now that I'm retired (little too much in fact) but only had time to work on that mod on the weekends back then, So it took me 4+ years. So much work perfecting it. There isn't a single clipping object anyplace and the wine stills work great. Also re-wrote the bottle storage scripts (that didn't work in Skyrim) and got them working like the bookcases. If you seen that thing in the Creation Kit you would freak how much is really there. The Ship is actually huge puzzle. You have to kinda work for it and it dramatically changes the more you figure out. It's also set up to be a preset to make home mods. You're more than welcome to unpack the bsa, load it up in the kit and take a look. Definitely a fun hobby to put together. That craps game is pretty cool ... other than it will rob you blind ...I actually worked on closing a menu like that for about a week and never did figure it out. So your post was like unfinished business to me. That video explains how to get the scripts working for skse pretty good and that code snip I posted for you works perfectly. Just what you asked for. From all the research I've done to figure that out I'm pretty sure that is the only way to do it. I really like how you were willing to put in the time to work on that on your own and keep pushing to figure it out. I get tired of people wanting you to do all the work for them. You know they are not learning anything ... So for people like you I'm more than willing to put in the time to help. Anyways thanks for the puzzle It was fun! Link to comment Share on other sites More sharing options...
aoh125 Posted March 24, 2020 Author Share Posted March 24, 2020 The tutorial is extremely straight forward about how to get skse scripts working in the ck. The fact that for w.e reason doing as he outlines isnt working for me has me at a total loss as to why so ive kind of set that aside in favor of just working on clutter and filling in the worldspace/interiors i have made. Without having opened your mod or played it i can tell it has tons of depth to it. Just seeing tents unroll and having to turn on the fire to access the cooking pot and the buttons.... so many buttons. Im sure its an amazing mod and i likely will give it a download and have a look. Glad you enjoyed the puzzle and finally won your battle against this old enemy d: . Least i know that once i do get skse scripting to work for me i already have the code i need hammered out , which is awesome. I hear you on the folks just wanting to kick back and get a script or w.e the case may be made for them. I had managed to work threw loads of modding/scripting issues threw research before i ever made a post on here. Usually prefer to figure it out myself or dig out the info myself since im more likely to remember it next time or be able to find it again if i need it at the very least. Not sure what made this specific issue be the one i finally broke down and asked about on the forums lol. Link to comment Share on other sites More sharing options...
Recommended Posts