JunkV3nd0r Posted September 24, 2018 Share Posted September 24, 2018 (edited) Hi,Short version is, I'm trying to add a check to one of the construction objects that make a chemistry table (workshop_co_CraftingChemsB) so thatIF: the Settlement has 0 settlersTHEN: Their is no perk costs to make the benchELSE: the bench has the normal perk costs.the long version is I'm not sure how to do this with the condition options as they seem to just compare stats and they all group together into a giant IF statement. I'm also not sure if the conditions update on attempted use, or if they are set at the beginning of the game, possibly meaning I'll have to get a little more creative to accomplish this. but if anyone can point me in the right direction that would be great.Thanks in advance. HORRRAY! We did it! IT works!So to recap:made global variable set to 0.Made or condition on workbench that it can be crafted if that global variable is 0made quest that runs on start to plug into event workshop enter menu.When event is fired variable changes to number of settlers in the workshop linked to the workbench we just activated.Using THIS code: Scriptname SMO_QuestTestScript extends Quest GlobalVariable Property pMyPopulation Auto Const Mandatory Keyword Property pLocTypeWorkshop Auto Const Mandatory WorkshopParentScript Property pWorkshopParent Auto Const Mandatory Event OnQuestInit() RegisterForCustomEvent(pWorkshopParent , "WorkshopEnterMenu") EndEvent Event WorkshopParentScript.WorkshopEnterMenu(WorkshopParentScript P, Var[] b) ObjectReference pPlayerRef = Game.GetPlayer() If pPlayerRef.GetcurrentLocation().Haskeyword(pLocTypeWorkshop) WorkshopScript WorkshopREF = pWorkshopParent.GetWorkshopFromLocation(pPlayerRef.GetcurrentLocation()) If (WorkshopREF.OwnedByPlayer == TRUE) If(WorkshopREF.GetBaseValue(pWorkshopParent .WorkshopRatings[pWorkshopParent .WorkshopRatingPopulation].resourceValue) > 0) pMyPopulation.SetValue(WorkshopREF.GetBaseValue(pWorkshopParent .WorkshopRatings[pWorkshopParent .WorkshopRatingPopulation].resourceValue)) Else pMyPopulation.SetValue(0) EndIf EndIf EndIf EndEventand if the value is still 0 you can craft a chem bench without the CHARISMA perks!THANK YOU ALL SO MUCH! XDIs their something I have to do like close this forum posting now? Edited September 27, 2018 by JunkV3nd0r Link to comment Share on other sites More sharing options...
icestormng Posted September 24, 2018 Share Posted September 24, 2018 Well, you can specify whether these conditions are concatenated with AND or with OR. They are evaluated whenever you open the workbench/workshop menu. Just like with resources.If you're in the workshop menu and add some material via console the menu doesn't reflect that. If you open it up again it does. Link to comment Share on other sites More sharing options...
markyrocks Posted September 24, 2018 Share Posted September 24, 2018 If there isn't a function that is available that meets your specific needs then you can always attach a script to the object and through some kinda event call if statements from there. Or use a quest to set various stages for different conditions and do other things based on those conditions. Link to comment Share on other sites More sharing options...
SKKmods Posted September 24, 2018 Share Posted September 24, 2018 There is no conditional lookup for settlement population. That totally needs a script to set a variable you can use a condition on. This involves some complex script lookups and an unknown trigger, so not one to try and start with. If you know how to make and attach a script to something that will provide an appropriate event to fire it, try: ObjectReference Property pPlayerREF Auto Const Mandatory GlobalVariable Property pMyPopulation Auto Const Mandatory Keyword Property pLocTypeWorkshop Auto Const Mandatory WorkshopParentScript Property pWorkshopParent Auto Const Mandatory EVENT NeedToFindAnObjectEventToRegisterForToFireThis() If pPlayerRef.GetcurrentLocation().Haskeyword(pLocTypeWorkshop) WorkshopScript WorkshopREF = pWorkshopParent.GetWorkshopFromLocation(pPlayerRef.GetcurrentLocation()) If (WorkshopREF.OwnedByPlayer == TRUE) pMyPopulation.SetValue(WorkshopREF.GetBaseValue(WorkshopRatings[WorkshopRatingPopulation].resourceValue)) Else pMyPopulation.SetValue(9999) EndIfElse pMyPopulation.SetValue(9999) EndIf EndEvent So in the constructable object you can use the condition GetGlobalValue on MyPopulation == 0 OR the usual perk OR. Link to comment Share on other sites More sharing options...
JunkV3nd0r Posted September 25, 2018 Author Share Posted September 25, 2018 WOAH! That's a lot of info, Thank you all so much! It all so much good info and helps A LOT thanks :DBefore I read this I was thinking about just copying the chem table and giving it different conditions, but now I see the conditions have more versatility then I thought originally, plus all the scripting info (including an actual script THANK YOU! Skk50) gives new ideas.Right now I guess I have to hunt for a event to fire off all this info for. at first I thought of firing it when you open the workshop menu (if theirs an even for that) but It may not update like icestorm said earlier until you open it, close it, and open it again (though typing that all out makes me feel like maybe not? I should look for an open workshop menu event and test it) which would be annoying but ALSO give you acses to the no charisma recipe in a populated steelment after you opened it somewhere else. Now I'm thinking about looking for an on player update event (though that might be too load heavy) and looking for the bool that tells the game toEither: Open the workshop menuOR: stay and third person and rotate the camerabecause if that;s true then.... oh wait then it would do it over and over and over....... HRmmmm. might need some different or more bools....Still I'mma work on it and see what I can come up with. THANK YOU ALL AGAIN! Link to comment Share on other sites More sharing options...
markyrocks Posted September 25, 2018 Share Posted September 25, 2018 (edited) You can definitely use onmenuopencloseevent. The only issue is that the constructable object has a static recipe and theres probably no easy way to change it dynamically. So the cheap work around is going to be to either return the items it cost to build to the player inventory given the population count. Or like you said make a duplicate item with a different recipe. You can dynamically add or remove items from the workshop menu via a quest stage via conditions. Youd basically use the menu event to check the population, if its 0 yourquest.setstage(10)Else yourquest.reset(). The conditions on the item would be for the regular workbench getstage() < 10.00 (select your quest) The conditions on the duplicate item would be Getstage()==10. Edit. Ya I don't think you have to duplicate the entire bench just the constructable object. Edited September 25, 2018 by markyrocks Link to comment Share on other sites More sharing options...
JunkV3nd0r Posted September 26, 2018 Author Share Posted September 26, 2018 (edited) Ok did some more work,Also thank you markyrocks for giving me the onmenuopencloseevent though I'm still not sure how to implement it...I added a global var and added an OR condition to the workbench saying that that var had to be 0 so that the workbench could be crafted and it WORKED! I could craft it without the CHR perk!Setting the Var is slightly more tricky. I'm still not sure how to register events in fallout by themselves (if that statement even makes any sense, at this point I'm not confident about that) so to try and test the functionality of the script: I saw that workshops have an activator around them showing where the workshop functions work called something like WorkshopSandbox in most cases, so I clicked on the one for starlight drive inn and added a script to set the global variable to the amount of people at starlight (0) during an event.The even I used was OnInit and for some reason it would set when I wasn't any where near starlight and when I finally had the idea to check the variable number it was set to 7? So I'm assuming OnInit happens when the game first sets up or at least when the object in question first sets up so I'm going to change it to on activate and see what happens.Though even if this does work (Which I hop it does fingers crossed) It still means I have to go to every single workshop and implement this script (Which, MEh? not that bad), which means it won't work for any mod added wokshops (ok that kinda stinks) So I should try and look how to plug into the workshop menu. I guess I can plug into the workshop workbench but would that still work for if you accesses the menu by holding down the third person button?EDIT:OK! So I ended up tweaking the script that SKK50 gave me. It looks like this now: Scriptname SOM_foodtestscript extends activemagiceffect GlobalVariable Property pMyPopulation Auto Const Mandatory Keyword Property pLocTypeWorkshop Auto Const Mandatory WorkshopParentScript Property pWorkshopParent Auto Const Mandatory Event OnInit() ObjectReference pPlayerRef = Game.GetPlayer() If pPlayerRef.GetcurrentLocation().Haskeyword(pLocTypeWorkshop) WorkshopScript WorkshopREF = pWorkshopParent.GetWorkshopFromLocation(pPlayerRef.GetcurrentLocation()) If (WorkshopREF.OwnedByPlayer == TRUE) If(WorkshopREF.GetBaseValue(pWorkshopParent .WorkshopRatings[pWorkshopParent .WorkshopRatingPopulation].resourceValue) > 0) pMyPopulation.SetValue(WorkshopREF.GetBaseValue(pWorkshopParent .WorkshopRatings[pWorkshopParent .WorkshopRatingPopulation].resourceValue)) Else pMyPopulation.SetValue(0) EndIf EndIf EndIf EndEvent Only problem is that that's a script I installed onto a consumable. I didn't get it to work with the "plugging into the workshop sandbox activator" idea, and I haven't found a way to plug into the opening of the workshop menu yet.BUT STILL! That's a lot of Progress and a lot of Functioning mod! So I'll look into plugging into to that opening menu function. I'll check back here if anyone has any ideas and if I get frustrated I'll probably post another topic XDAlso if anyone is waiting on me to post just this idea as a mod, I probably won't unless asked too. This is just me working on a function of a larger mod idea I had, though my track record at finishing these things is terrible so, Fingers crossed! Edited September 26, 2018 by JunkV3nd0r Link to comment Share on other sites More sharing options...
markyrocks Posted September 26, 2018 Share Posted September 26, 2018 Oninit() is really only used for like one time events. It would probably be a lot easier to like superficially add the specific perk to the player temporarily given specific conditions and removed after the fact than whatever it is you're trying to do. Take my above advice make a quest. Think of a quest as like the home base for your mod. Setting quest stages are basically keeping track of different happenings in the mod. It took me awhile to figure this out but it was probably some of the best advice I got. You're talking about a global variable...they are not const. They change all the time given specific conditions. But if x happens setstage(10)...once it's set it's not going to change unless you change it. Link to comment Share on other sites More sharing options...
markyrocks Posted September 26, 2018 Share Posted September 26, 2018 (edited) Event Oninit()(Self as scriptobject).registerformenuopencloseevent("WorkshopMenu")Endevent ;edit, this script would get attached to the quest!!!!! Event (self as scriptobject).OnMenuOpenCloseEvent(string asMenuName, bool abOpening) if (asMenuName == "LockpickingMenu") if (abOpening) Debug.Trace("Lockpicking menu is open!") endif endif endEvent Edited September 26, 2018 by markyrocks Link to comment Share on other sites More sharing options...
SKKmods Posted September 26, 2018 Share Posted September 26, 2018 Just unpacked my Global Workshop storage mod for you as that contains the cleverness you need. Its complex so will need to share scripts via gdrive or something but in outline it will be a start game enabled quest with a script that: OnQuestInit() Loop through all workshops, if player owned RegisterForRemoteEvent(WorkshopREF, "OnWorkshopMode") and RegisterForCustomEvent(pWorkshopParentScript, "WorkshopPlayerOwnershipChanged") so WorkshopParentScript.WorkshopPlayerOwnershipChanged(WorkshopParentScript akSender, Var[] akArgs) If PlayerOwned RegisterForRemoteEvent(WorkshopREF, "OnWorkshopMode") then Event ObjectReference.OnWorkshopMode(ObjectReference ThisWorkshopRef, bool bStart) to do your thing Link to comment Share on other sites More sharing options...
Recommended Posts