anb2004 Posted March 11, 2020 Share Posted March 11, 2020 Don't know if i get the title right but here it goesFirst attempt for making my first MCM config, thought i'll give it try with a simple config for the auto close door for my player house. The MCM script Scriptname _MCMTestAutoDoorCOnfig extends SKI_ConfigBase GlobalVariable Property AutoCloseDoor Auto GlobalVariable Property AutoCloseDoordelay Auto GlobalVariable Property AutoCloseDoorDistance Auto float Property MinTimer = 0.0 AutoReadOnly float Property MaxTimer = 50.0 AutoReadOnly float Property IntervalTimer = 5.0 AutoReadOnly float Property DefaultTimer = 5.0 AutoReadOnly float Property MinDistance = 50.0 AutoReadOnly float Property MaxDistance = 500.0 AutoReadOnly float Property IntervalDistance = 50.0 AutoReadOnly float Property DefaultDistance = 100.0 AutoReadOnly bool Property AutoDoor = False Auto int EnableAutoDoor int EnableAutoDoordelay int EnableAutoDoorDistance Event OnPageReset(string page) SetCursorFillMode(TOP_TO_BOTTOM) AddHeaderOption("Behold The mighty Door") EnableAutoDoor = AddToggleOption("Auto Close Door", AutoDoor) EnableAutoDoorDelay = AddSliderOption("Delay", AutoCloseDoorDelay.GetValue(), AutoCloseDoorDelayFlags()) EnableAutoDoorDistance = AddSliderOption("Distance", AutoCloseDoorDistance.GetValue(), AutoCloseDoorDistanceFlags()) AddHeaderOption("") EndEvent Event OnOptionSelect(Int option) If option == EnableAutoDoor AutoDoor = !AutoDoor SetToggleOptionValue(EnableAutoDoor, AutoDoor) SetOptionFlags(EnableAutoDoorDelay, AutoCloseDoorDelayFlags()) SetOptionFlags(EnableAutoDoorDistance, AutoCloseDoorDistanceFlags()) if (AutoCloseDoor.GetValue() == 0) AutoCloseDoor.SetValue(1) else AutoCloseDoor.SetValue(0) endif EndIf EndEvent Event OnOptionDefault(Int option) If option == EnableAutoDoor AutoDoor = False SetToggleOptionValue(EnableAutoDoor, AutoDoor) elseif option == EnableAutoDoorDelay AutoDoor = False SetSliderOptionValue( EnableAutoDoorDelay, AutoCloseDoorDelay.GetValue() ) elseif option == EnableAutoDoorDistance AutoDoor = False SetSliderOptionValue( EnableAutoDoorDistance, AutoCloseDoorDistance.GetValue() ) EndIf EndEvent Event OnOptionHighlight(int option) if (option == EnableAutoDoor) SetInfoText("Enable Auto Close Door") elseif (option == EnableAutoDoorDelay) SetInfoText("How long the door will auto close") elseif (option == EnableAutoDoorDistance) SetInfoText("Distance between actor and door to avoid auto close") endif EndEvent Event OnOptionSliderOpen(int option) If (Option == EnableAutoDoorDelay) SetSliderDialogStartValue(AutoCloseDoorDelay.GetValue()) SetSliderDialogDefaultValue(DefaultTimer) SetSliderDialogRange(Mintimer, MaxTimer) SetSliderDialogInterval(IntervalTimer) elseIf (Option == EnableAutoDoorDistance) SetSliderDialogStartValue(AutoCloseDoorDistance.GetValue()) SetSliderDialogDefaultValue(DefaultDistance) SetSliderDialogRange(MinDistance, MaxDistance) SetSliderDialogInterval(IntervalDistance) EndIf EndEvent Event OnOptionSliderAccept(int option, float value) If (Option == EnableAutoDoorDelay) AutoCloseDoorDelay.SetValue(value) SetSliderOptionValue(EnableAutoDoorDelay, AutoCloseDoorDelay.GetValue()) elseIf (Option == EnableAutoDoorDistance) AutoCloseDoorDistance.SetValue(value) SetSliderOptionValue(EnableAutoDoorDistance, AutoCloseDoorDistance.GetValue()) EndIf EndEvent int Function AutoCloseDoorDelayFlags() if ( AutoDoor ) return OPTION_FLAG_NONE else return OPTION_FLAG_DISABLED endif EndFunction int Function AutoCloseDoorDistanceFlags() if ( AutoDoor ) return OPTION_FLAG_NONE else return OPTION_FLAG_DISABLED endif EndFunction The auto close door script that i want to attach (Original script by sLoPpYdOtBiGhOlE) Scriptname _MCMTestAutoDoorScript extends ObjectReference Quest Property Config Auto ; MCMTest_AutoDoorConfig Quest GlobalVariable Property AutoCloseDoor Auto ;GlobalVariable Property AutoCloseDoorDelay Auto ;GlobalVariable Property AutoCloseDoorDistance Auto Float Property fDelay = 5.0 Auto {Optionally set Delay before the door closes, default 5.0 secs} Float Property fDistance = 70.0 Auto {Optionally set distance of actors before the door closes so the door doesn't close while an actor in standing in it, default 70.0 units} Event OnActivate(ObjectReference akActionRef) RegisterForSingleUpdate(fDelay) EndEvent Event OnUpdate() If GetOpenState() < 3 If !Game.FindClosestActor(Self.X, Self.Y, Self.Z, fDistance) SetOpen(False) Else RegisterForSingleUpdate(fDelay) EndIf EndIf EndEvent The mcm script is chaotic i know, call me dumb or stupid but that's what i could come up with after hours rummaging any mods that i have and learn from it. Do managed to get the door auto close on & off though (yay :wallbash:). So figured i could do more with those 2 setting for delay and actors distance but there are the part that kind of put me back to square one. Question :1. How can i / is it possible to get each delay & distance float value from the quest script into the door script. How do you transform float into global or vice versa? 2. How to make those 2 delay & distance settings grey out with auto door checkbox uncheck upon first time loading ? just don't know how to connect AutoDoor bool and AutoCloseDoor Global.3. Delay & disatance Slider are working well but both value are set to 1 instead default value that i assigned at first time loading. Wonder why ? Any help will be appreciated but please bear with me, my IQ isn't exactly higher than my toe with scripting. Link to comment Share on other sites More sharing options...
testiger2 Posted March 12, 2020 Share Posted March 12, 2020 1) make a new property in your script xxNameOfScriptYouWantToAccess Property mScript Auto * mScript.myproperty = value ** Or mScript.myFunction() ** * xxNameOfScriptYouWantToAccess is the name that is written behind Scriptname right on the header of the script and not the name of the .psc file When you create a new script you essentially create a new object class along with it and you can then fill the property in the CK to obtain an actual object within your script ** Since you now have an object you can access any properties and functions like you would do with any other object you can't convert a float to a global or vice versa. You make a global in the CK and use it as a property and then use .GetValue() and .SetValue() on the global to work with them. These methods return/request float values though. Also Read the Wikihttps://www.creationkit.com/index.php?title=Variables_and_Properties 2)AutoCloseDoorDelayFlags() and AutoCloseDoorDistanceFlags() do exactly the same you only need 1 and can delete the other You can then rewrite that function so that it takes a float int Function AutoCloseDoorDelayFlags(float fArg) if ( fArg ) ;float is implicitly cast as a bool here where 0 equals false and everything else means true return OPTION_FLAG_NONE else return OPTION_FLAG_DISABLED endif EndFunction you can then call that function like you did with other functions in your script already AutoCloseDoorDelayFlags(AutoCloseDoorDistance.GetValue()) 3)the slider is initialized with this function AddSliderOption("Delay", AutoCloseDoorDelay.GetValue(), AutoCloseDoorDelayFlags()) you pass AutoCloseDoorDelay.GetValue() as the initial value which likely is 1 by default and thenwhen OnSliderOptionAccept() gets calles later you update the value and thats why it will show the correct value the next time I would suggest converting all your AutoReadOnly Properties to Auto and then initialize them with a seperate function on the OnPageReset() event something like this function initVArs() variable1 = global1.GetValue() variable2 = global2.GetValue() ;etc endfunction then instead of calling the globals everytime you call your variables directly which also has the advantage of beeing a bit faster Or if you are comfortable with some "advanced scripting" you can link your variables and the globals through defining custom properties as it is explained here: https://www.creationkit.com/index.php?title=Property_Reference Link to comment Share on other sites More sharing options...
anb2004 Posted March 13, 2020 Author Share Posted March 13, 2020 testiger2 Thank you. Still trying to "absorb" everything you said into my head, gonna take a while but at least you've give me something to start it. Thanks again. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted March 13, 2020 Share Posted March 13, 2020 (edited) Maybe this is working for you. As testiger2 wrote: "make a new property" and "converting all your AutoReadOnly Properties" anb_AutoDoorScript Scriptname anb_AutoDoorScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/8483648-scriptnewbie-how-you-call-float-value-from-a-quest-script/ Quest PROPERTY myQuest auto ; the quest you have attached the MCM menu script anb_AutoDoorMCMConfig ps ; pointer to MCM config script ; -- EVENTs -- EVENT OnCellDetach() UnRegisterForUpdate() gotoState("") ; ### STATE ### ENDEVENT EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef as Actor) ; Update for actors only! gotoState("Action") ; ### STATE ### myF_Update() ENDIF ENDEVENT ;====================================== state Action ;=========== EVENT OnUpdate() IF (self.GetOpenState() >= 3) gotoState("") ; ### STATE ### ELSE myF_FindActor() ENDIF ENDEVENT ;======== endState ; -- FUNCTIONs -- ;-------------------- FUNCTION myF_Update() ;-------------------- ps = myQuest as anb_AutoDoorMCMConfig IF ( ps ) RegisterForSingleUpdate(ps.fAutoCloseDoorDelay) ; first time updating ELSE Debug.Trace(" OnActivate() - cannot find MCM config script! " +self) ENDIF ENDFUNCTION ;----------------------- FUNCTION myF_FindActor() ;----------------------- IF self.GetBaseObject() float fx = self.GetPositionX() float fy = self.GetPositionY() float fz = self.GetPositionZ() IF Game.FindClosestActor(fx,fy,fz, ps.fAutoCloseDoorDistance) gotoState("") ; ### STATE ### self.SetOpen(False) ELSE RegisterForSingleUpdate(ps.fAutoCloseDoorDelay) ; still keep updating ENDIF ENDIF ENDFUNCTION anb_AutoDoorMCMConfig Scriptname anb_AutoDoorMCMConfig extends SKI_ConfigBase ; https://forums.nexusmods.com/index.php?/topic/8483648-scriptnewbie-how-you-call-float-value-from-a-quest-script/ Bool PROPERTY bAutoCloseDoor auto ; [default=False] Float PROPERTY fAutoCloseDoorDelay = 5.0 auto ; [default=5 sec] ; set delay before the door closes Float PROPERTY fAutoCloseDoorDistance = 70.0 auto ; [default=70 units] ; set distance of actors before the door closes so the door does not close while an actor in standing in it Int[] a ; array as options storage ; a[0] = EnableAutoDoor ; a[1] = EnableAutoDoordelay ; a[3] = EnableAutoDoorDistance ; -- FUNCTION -- ;------------------------ Int FUNCTION myF_Option() ;------------------------ IF ( bAutoCloseDoor ) ; TRUE RETURN OPTION_FLAG_NONE ENDIF ;--------- RETURN OPTION_FLAG_DISABLED ENDFUNCTION ; -- EVENTs -- 8 EVENT OnInit() ;=========== parent.OnInit() ; at first call parent event directly a = new Int[3] ENDEVENT EVENT OnConfigInit() ;================= Pages = new String[1] ; *** see parent script "SKI_ConfigBase.psc" Pages[0] = "Config" ENDEVENT EVENT OnPageReset(String page) ;================ IF (Page == "") LoadCustomContent("Imaginary_Image") RETURN ; - STOP - use default content ENDIF ;--------------------- UnLoadCustomContent() IF (page == "Config") SetCursorFillMode(TOP_TO_BOTTOM) AddHeaderOption("Behold The mighty Door") a[0] = AddToggleOption("Auto Close Door", bAutoCloseDoor) a[1] = AddSliderOption("Delay", fAutoCloseDoorDelay, myF_Option()) a[2] = AddSliderOption("Distance", fAutoCloseDoorDistance, myF_Option()) AddHeaderOption("") ENDIF ENDEVENT EVENT OnOptionSelect(Int option) ;=================== IF (CurrentPage == "Config") ; *** see script "SKI_Config_Base.psc" for CurrentPage ELSE RETURN ; - STOP - failsafe ENDIF ;--------------------- IF (option == a[0]) ; EnableAutoDoor bAutoCloseDoor = !bAutoCloseDoor SetToggleOptionValue(a[0], bAutoCloseDoor) RETURN ; - STOP - ENDIF ;--------------------- SetOptionFlags(option, myF_Option()) ENDEVENT EVENT OnOptionHighlight(Int option) ;====================== IF (option == a[0]) ; EnableAutoDoor SetInfoText("Enable Auto Close Door") RETURN ; - STOP - ENDIF ;--------------------- IF (option == a[1]) ; EnableAutoDoorDelay SetInfoText("How long the door will auto close") RETURN ; - STOP - ENDIF ;--------------------- IF (option == a[2]) ; EnableAutoDoorDistance) SetInfoText("Distance between actor and door to avoid auto close") ENDIF ENDEVENT EVENT OnOptionDefault(Int option) ;==================== IF (option == a[0]) ; EnableAutoDoor SetToggleOptionValue(option, bAutoCloseDoor) RETURN ; - STOP - ENDIF ;--------------------- IF (option == a[1]) ; EnableAutoDoorDelay SetSliderOptionValue(option, fAutoCloseDoorDelay) RETURN ; - STOP - ENDIF ;--------------------- IF (option == a[2]) ; EnableAutoDoorDistance SetSliderOptionValue(option, fAutoCloseDoorDistance) ENDIF ENDEVENT ;float Property MinTimer = 0.0 AutoReadOnly ;float Property MaxTimer = 50.0 AutoReadOnly ;float Property IntervalTimer = 5.0 AutoReadOnly ;float Property DefaultTimer = 5.0 AutoReadOnly ;float Property MinDistance = 50.0 AutoReadOnly ;float Property MaxDistance = 500.0 AutoReadOnly ;float Property IntervalDistance = 50.0 AutoReadOnly ;float Property DefaultDistance = 100.0 AutoReadOnly EVENT OnOptionSliderOpen(Int option) ;======================= IF (option == a[1]) ; EnableAutoDoorDelay SetSliderDialogStartValue(fAutoCloseDoorDelay) SetSliderDialogDefaultValue(5.0) SetSliderDialogRange(0.0, 50.0) SetSliderDialogInterval(5.0) RETURN ; - STOP - ENDIF ;--------------------- IF (option == a[2]) ; EnableAutoDoorDistance SetSliderDialogStartValue(fAutoCloseDoorDistance) SetSliderDialogDefaultValue(100.0) SetSliderDialogRange(50.0, 500.0) SetSliderDialogInterval(50.0) ENDIF ENDEVENT EVENT OnOptionSliderAccept(Int option, Float value) ;========================= IF (option == a[1]) ; EnableAutoDoorDelay fAutoCloseDoorDelay = value ELSEIF (option == a[2]) ; EnableAutoDoorDistance fAutoCloseDoorDistance = value ELSE RETURN ; - STOP - unknown option ENDIF ;--------------------- SetSliderOptionValue(option, value) ENDEVENT Edited March 13, 2020 by ReDragon2013 Link to comment Share on other sites More sharing options...
anb2004 Posted March 16, 2020 Author Share Posted March 16, 2020 Maybe this is working for you. As testiger2 wrote: "make a new property" and "converting all your AutoReadOnly Properties" anb_AutoDoorScript Scriptname anb_AutoDoorScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/8483648-scriptnewbie-how-you-call-float-value-from-a-quest-script/ Quest PROPERTY myQuest auto ; the quest you have attached the MCM menu script anb_AutoDoorMCMConfig ps ; pointer to MCM config script ; -- EVENTs -- EVENT OnCellDetach() UnRegisterForUpdate() gotoState("") ; ### STATE ### ENDEVENT EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef as Actor) ; Update for actors only! gotoState("Action") ; ### STATE ### myF_Update() ENDIF ENDEVENT ;====================================== state Action ;=========== EVENT OnUpdate() IF (self.GetOpenState() >= 3) gotoState("") ; ### STATE ### ELSE myF_FindActor() ENDIF ENDEVENT ;======== endState ; -- FUNCTIONs -- ;-------------------- FUNCTION myF_Update() ;-------------------- ps = myQuest as anb_AutoDoorMCMConfig IF ( ps ) RegisterForSingleUpdate(ps.fAutoCloseDoorDelay) ; first time updating ELSE Debug.Trace(" OnActivate() - cannot find MCM config script! " +self) ENDIF ENDFUNCTION ;----------------------- FUNCTION myF_FindActor() ;----------------------- IF self.GetBaseObject() float fx = self.GetPositionX() float fy = self.GetPositionY() float fz = self.GetPositionZ() IF Game.FindClosestActor(fx,fy,fz, ps.fAutoCloseDoorDistance) gotoState("") ; ### STATE ### self.SetOpen(False) ELSE RegisterForSingleUpdate(ps.fAutoCloseDoorDelay) ; still keep updating ENDIF ENDIF ENDFUNCTION anb_AutoDoorMCMConfig Scriptname anb_AutoDoorMCMConfig extends SKI_ConfigBase ; https://forums.nexusmods.com/index.php?/topic/8483648-scriptnewbie-how-you-call-float-value-from-a-quest-script/ Bool PROPERTY bAutoCloseDoor auto ; [default=False] Float PROPERTY fAutoCloseDoorDelay = 5.0 auto ; [default=5 sec] ; set delay before the door closes Float PROPERTY fAutoCloseDoorDistance = 70.0 auto ; [default=70 units] ; set distance of actors before the door closes so the door does not close while an actor in standing in it Int[] a ; array as options storage ; a[0] = EnableAutoDoor ; a[1] = EnableAutoDoordelay ; a[3] = EnableAutoDoorDistance ; -- FUNCTION -- ;------------------------ Int FUNCTION myF_Option() ;------------------------ IF ( bAutoCloseDoor ) ; TRUE RETURN OPTION_FLAG_NONE ENDIF ;--------- RETURN OPTION_FLAG_DISABLED ENDFUNCTION ; -- EVENTs -- 8 EVENT OnInit() ;=========== parent.OnInit() ; at first call parent event directly a = new Int[3] ENDEVENT EVENT OnConfigInit() ;================= Pages = new String[1] ; *** see parent script "SKI_ConfigBase.psc" Pages[0] = "Config" ENDEVENT EVENT OnPageReset(String page) ;================ IF (Page == "") LoadCustomContent("Imaginary_Image") RETURN ; - STOP - use default content ENDIF ;--------------------- UnLoadCustomContent() IF (page == "Config") SetCursorFillMode(TOP_TO_BOTTOM) AddHeaderOption("Behold The mighty Door") a[0] = AddToggleOption("Auto Close Door", bAutoCloseDoor) a[1] = AddSliderOption("Delay", fAutoCloseDoorDelay, myF_Option()) a[2] = AddSliderOption("Distance", fAutoCloseDoorDistance, myF_Option()) AddHeaderOption("") ENDIF ENDEVENT EVENT OnOptionSelect(Int option) ;=================== IF (CurrentPage == "Config") ; *** see script "SKI_Config_Base.psc" for CurrentPage ELSE RETURN ; - STOP - failsafe ENDIF ;--------------------- IF (option == a[0]) ; EnableAutoDoor bAutoCloseDoor = !bAutoCloseDoor SetToggleOptionValue(a[0], bAutoCloseDoor) RETURN ; - STOP - ENDIF ;--------------------- SetOptionFlags(option, myF_Option()) ENDEVENT EVENT OnOptionHighlight(Int option) ;====================== IF (option == a[0]) ; EnableAutoDoor SetInfoText("Enable Auto Close Door") RETURN ; - STOP - ENDIF ;--------------------- IF (option == a[1]) ; EnableAutoDoorDelay SetInfoText("How long the door will auto close") RETURN ; - STOP - ENDIF ;--------------------- IF (option == a[2]) ; EnableAutoDoorDistance) SetInfoText("Distance between actor and door to avoid auto close") ENDIF ENDEVENT EVENT OnOptionDefault(Int option) ;==================== IF (option == a[0]) ; EnableAutoDoor SetToggleOptionValue(option, bAutoCloseDoor) RETURN ; - STOP - ENDIF ;--------------------- IF (option == a[1]) ; EnableAutoDoorDelay SetSliderOptionValue(option, fAutoCloseDoorDelay) RETURN ; - STOP - ENDIF ;--------------------- IF (option == a[2]) ; EnableAutoDoorDistance SetSliderOptionValue(option, fAutoCloseDoorDistance) ENDIF ENDEVENT ;float Property MinTimer = 0.0 AutoReadOnly ;float Property MaxTimer = 50.0 AutoReadOnly ;float Property IntervalTimer = 5.0 AutoReadOnly ;float Property DefaultTimer = 5.0 AutoReadOnly ;float Property MinDistance = 50.0 AutoReadOnly ;float Property MaxDistance = 500.0 AutoReadOnly ;float Property IntervalDistance = 50.0 AutoReadOnly ;float Property DefaultDistance = 100.0 AutoReadOnly EVENT OnOptionSliderOpen(Int option) ;======================= IF (option == a[1]) ; EnableAutoDoorDelay SetSliderDialogStartValue(fAutoCloseDoorDelay) SetSliderDialogDefaultValue(5.0) SetSliderDialogRange(0.0, 50.0) SetSliderDialogInterval(5.0) RETURN ; - STOP - ENDIF ;--------------------- IF (option == a[2]) ; EnableAutoDoorDistance SetSliderDialogStartValue(fAutoCloseDoorDistance) SetSliderDialogDefaultValue(100.0) SetSliderDialogRange(50.0, 500.0) SetSliderDialogInterval(50.0) ENDIF ENDEVENT EVENT OnOptionSliderAccept(Int option, Float value) ;========================= IF (option == a[1]) ; EnableAutoDoorDelay fAutoCloseDoorDelay = value ELSEIF (option == a[2]) ; EnableAutoDoorDistance fAutoCloseDoorDistance = value ELSE RETURN ; - STOP - unknown option ENDIF ;--------------------- SetSliderOptionValue(option, value) ENDEVENT It works :wink:Though the door will start to self close if an actor is within the distance as it was set by distance slider instead blocking the door to self close, but no biggie i'll see if i can get it reverse.Didn't expect for someone to write the code all over for me so thank you. Still working with my own code above to get it working, just for once i can do something right by my own from learning someone else code. Anyway this might a little out of topic, interested with the change texture cycle script from modders resource by Darkfox127, tested and it work, unfortunately Darkfox127 didn't really describe how exactly for setting up a quest to update the global everytime we start the game because texture will revert back to the original. Darkfox127 Script Scriptname PM_Script_ChangeTexture_Cycle extends ObjectReference {Each time this object is activated, it changed texture and cycles through a number of them.} ;Original universal script created by Darkfox127 ;Any potential problems which may arise from this script being changed from the original are the sole responsibility of the mod author making the changes. ;Please be sure to credit if you this in your own published mod. GlobalVariable Property UpdateGlobal Auto {This global is set to 1 upon loading the game allowing for the function to change when this object is activated. A quest set up to start with the game will activate this object and other selected refernces to force the textureset to update.} Int Property CurrentTexture = 1 Auto Hidden ObjectReference Property ObjectToChange Auto {The object you want to changed the textureset of.} String Property NodeName Auto {The name of the node on this mesh we wish to change.} TextureSet Property MyTextureSet_01 Auto {One of the texture sets in the cycle to change this item to.} TextureSet Property MyTextureSet_02 Auto {One of the texture sets in the cycle to change this item to.} TextureSet Property MyTextureSet_03 Auto {One of the texture sets in the cycle to change this item to.} TextureSet Property MyTextureSet_04 Auto {One of the texture sets in the cycle to change this item to.} TextureSet Property MyTextureSet_05 Auto {One of the texture sets in the cycle to change this item to.} TextureSet Property MyTextureSet_06 Auto {One of the texture sets in the cycle to change this item to.} TextureSet Property MyTextureSet_07 Auto {One of the texture sets in the cycle to change this item to.} TextureSet Property MyTextureSet_08 Auto {One of the texture sets in the cycle to change this item to.} Event OnCellLoad() DrapesUpdate() EndEvent Event OnActivate(ObjectReference akActionRef) If UpdateGlobal.GetValue() == 0 If CurrentTexture == 1 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_02, True) CurrentTexture = 2 ElseIf CurrentTexture == 2 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_03, True) CurrentTexture = 3 ElseIf CurrentTexture == 3 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_04, True) CurrentTexture = 4 ElseIf CurrentTexture == 4 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_05, True) CurrentTexture = 5 ElseIf CurrentTexture == 5 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_06, True) CurrentTexture = 6 ElseIf CurrentTexture == 6 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_07, True) CurrentTexture = 7 ElseIf CurrentTexture == 7 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_08, True) CurrentTexture = 8 ElseIf CurrentTexture == 8 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_01, True) CurrentTexture = 1 EndIf Else DrapesUpdate() EndIf EndEvent Function DrapesUpdate() If CurrentTexture == 1 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_01, True) ElseIf CurrentTexture == 2 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_02, True) ElseIf CurrentTexture == 3 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_03, True) ElseIf CurrentTexture == 4 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_04, True) ElseIf CurrentTexture == 5 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_05, True) ElseIf CurrentTexture == 6 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_06, True) ElseIf CurrentTexture == 7 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_07, True) ElseIf CurrentTexture == 8 NetImmerse.SetNodeTextureSet(ObjectToChange, NodeName, MyTextureSet_08, True) EndIf EndFunction Remember doing something similar with my hunter armor texture swap that i tried to get it working back in the day. Any hint what should i do to accomplish that ? Thanks Link to comment Share on other sites More sharing options...
ReDragon2013 Posted March 18, 2020 Share Posted March 18, 2020 two scripts as base for quest with static aliases by using predefined arrays as properties.. maybe it works, it is a suggestion PM_TSCycle_QuestScript Scriptname PM_TSCycle_QuestScript extends Quest {NodeName and TextureSet storage holder} ; https://forums.nexusmods.com/index.php?/topic/8483648-scriptnewbie-how-you-call-float-value-from-a-quest-script/ String[] PROPERTY NodeNameList auto ; name of NiTriShape texture within nif node ; NodeNameList[0] for a0 ; NodeNameList[1] for a1 ; NodeNameList[2] for a2 TextureSet[] PROPERTY a0 auto ; fill with texturesets that will be changed by random ; a0[0] -- default TextureSet ; a0[1] -- alternative textureset 1 ; a0[2] -- alternative textureset 2 ; a0[127] -- alternative textureset 127 ; same comments as above TextureSet[] PROPERTY a1 auto TextureSet[] PROPERTY a2 auto ;TextureSet[] PROPERTY a3 auto ; -- FUNCTIONs -- 2 ; https://www.creationkit.com/index.php?title=HasNode_-_ObjectReference ; https://www.creationkit.com/index.php?title=NetImmerse_Script ;---------------------------------- Int FUNCTION myF_GetLengthTS(Int i) ; external from alias script ;---------------------------------- int n IF (i == 0) n = a0.Length ELSEIF (i == 1) n = a1.Length ELSEIF (i == 2) n = a2.Length ;ELSEIF (i == 3) ; n = a3.Length ELSE Debug.TraceStack(" #1 Invalid number detected! " +i) RETURN -1 ; no matching array of textureset ENDIF ;--------- IF (n < 1) Debug.TraceStack(" #2 Array of textureset is empty! " +i) RETURN -2 ; ENIDF ;--------- IF (n >= NodeNameList.Length) Debug.TraceStack(" #3 Length of textureset array does not match length of NodeNameList! " +i) RETURN -3 ; string array too small ENDIF ;--------- RETURN n ENDFUNCTION ;------------------------------------------------------------- Bool FUNCTION myF_ChangeTS(Int i, ObjectReference oRef, Int T) ; external from alias script ;------------------------------------------------------------- ; oRef = ref from alias ; i = entry within NodeNameList "iPosNNL" ; T = random number in array of TextureSet "iCurrentTS" IF (SKSE.GetValue() > 0.0) ELSE Return False ; SKSE not found! ENDIF ;--------- string s = NodeNameList[i] ; NiTriShape texture nif node IF (oRef) && oRef.HasNode(s) ELSE Return False ; invalid objectRef or node name not found within objectRef ENDIF ;--------- TextureSet TS IF (i == 0) TS = a0[T] ELSEIF (i == 1) TS = a1[T] ELSEIF (i == 2) TS = a2[T] ;ELSEIF (i == 3) ; TS = a3[T] ELSE Debug.TraceStack(" #0 Invalid number detected! " +i) Return False ; no matching textureset ENDIF ;--------- IF ( TS ) ; look at SKSE script "NetImmerse.psc" NetImmerse.SetNodeTextureSet(oRef, s, TS, TRUE) ; first person view Return TRUE ; Well Done! ENDIF ;-------- Return False ; textureset not found! ENDFUNCTION OnActivate() has been removed, only 3D ready events are used PM_TSCycle_AliasScript Scriptname PM_TSCycle_AliasScript extends ReferenceAlias {each time this object will have 3d loaded, it may change the textureset by random} ; https://forums.nexusmods.com/index.php?/topic/8483648-scriptnewbie-how-you-call-float-value-from-a-quest-script/ ; Original universal script created by Darkfox127 ; update by ReDragon 2020 ; Note: ; Any potential problems which may arise from this script being changed from the original ; are the sole responsibility of the mod author making the changes. ; Please be sure to credit by using some script code in your own published mod! Int PROPERTY iPosNNL = -1 auto ; contains the position of entry in quest property "NodeNameList" (array of string) {required!} Int iCurrentTS ; [default=0] Bool bOK ; [default=False] ;Float fLastTimeUpdate ; [default=0.0], another way to use a condition for next textureset change ; -- EVENTs -- 2 ; ############################################################################################################ ; You have to create a quest (with start game enabled) with some prefilled aliases (assigned with this script) ; ############################################################################################################ EVENT OnCellLoad() myF_Update() ENDEVENT EVENT OnUnLoad() IF ( bOK ) myF_Random() ENDIF ENDEVENT ; -- FUNCTIONs -- 2 ;-------------------- FUNCTION myF_Update() ;-------------------- PM_TSCycle_QuestScript ps = self.GetOwningQuest() as PM_TSCycle_QuestScript IF (ps) && ps.myF_ChangeTS(iPosNNL, self.GetReference(), iCurrentTS) bOK = TRUE ;;; fLastTimeUpdate = Utility.GetCurrentRealTime() ENDIF ENDFUNCTION ;-------------------- FUNCTION myF_Random() ; when 3d gets unloaded try to make a random change of textureset ;-------------------- ; IF Utility.RandomInt(0, 1) ; chance of 50.0 percent ; ;IF Utility.RandomInt(0, 2) ; chance of 66.6 percent ; ;IF Utility.RandomInt(-1, 1) ; chance of 33.3 percent ; ELSE ; RETURN ; - STOP - avoid random change of "iCurrentTS" ; ENDIF ; ---------------------- PM_TSCycle_QuestScript ps = self.GetOwningQuest() as PM_TSCycle_QuestScript IF ( ps ) ELSE RETURN ; - STOP - missing quest script! ENDIF ;--------------------- int n = ps.myF_GetLengthTS(iPosNNL) WHILE (TRUE) ; run loop as long as a condition will not fire "return" IF (n < 2) RETURN ; - STOP - property error OR empty (or single entry) array of texture sets ENDIF ; ---------------------- int i = Utility.RandomInt(0, n) IF (i == iCurrentTS) ELSE iCurrentTS = i RETURN ; - STOP - got another entry within array ENDIF ; ---------------------- ENDWHILE ENDFUNCTION Link to comment Share on other sites More sharing options...
anb2004 Posted March 20, 2020 Author Share Posted March 20, 2020 two scripts as base for quest with static aliases by using predefined arrays as properties.. maybe it works, it is a suggestion PM_TSCycle_QuestScript Scriptname PM_TSCycle_QuestScript extends Quest {NodeName and TextureSet storage holder} ; https://forums.nexusmods.com/index.php?/topic/8483648-scriptnewbie-how-you-call-float-value-from-a-quest-script/ String[] PROPERTY NodeNameList auto ; name of NiTriShape texture within nif node ; NodeNameList[0] for a0 ; NodeNameList[1] for a1 ; NodeNameList[2] for a2 TextureSet[] PROPERTY a0 auto ; fill with texturesets that will be changed by random ; a0[0] -- default TextureSet ; a0[1] -- alternative textureset 1 ; a0[2] -- alternative textureset 2 ; a0[127] -- alternative textureset 127 ; same comments as above TextureSet[] PROPERTY a1 auto TextureSet[] PROPERTY a2 auto ;TextureSet[] PROPERTY a3 auto ; -- FUNCTIONs -- 2 ; https://www.creationkit.com/index.php?title=HasNode_-_ObjectReference ; https://www.creationkit.com/index.php?title=NetImmerse_Script ;---------------------------------- Int FUNCTION myF_GetLengthTS(Int i) ; external from alias script ;---------------------------------- int n IF (i == 0) n = a0.Length ELSEIF (i == 1) n = a1.Length ELSEIF (i == 2) n = a2.Length ;ELSEIF (i == 3) ; n = a3.Length ELSE Debug.TraceStack(" #1 Invalid number detected! " +i) RETURN -1 ; no matching array of textureset ENDIF ;--------- IF (n < 1) Debug.TraceStack(" #2 Array of textureset is empty! " +i) RETURN -2 ; ENIDF ;--------- IF (n >= NodeNameList.Length) Debug.TraceStack(" #3 Length of textureset array does not match length of NodeNameList! " +i) RETURN -3 ; string array too small ENDIF ;--------- RETURN n ENDFUNCTION ;------------------------------------------------------------- Bool FUNCTION myF_ChangeTS(Int i, ObjectReference oRef, Int T) ; external from alias script ;------------------------------------------------------------- ; oRef = ref from alias ; i = entry within NodeNameList "iPosNNL" ; T = random number in array of TextureSet "iCurrentTS" IF (SKSE.GetValue() > 0.0) ELSE Return False ; SKSE not found! ENDIF ;--------- string s = NodeNameList[i] ; NiTriShape texture nif node IF (oRef) && oRef.HasNode(s) ELSE Return False ; invalid objectRef or node name not found within objectRef ENDIF ;--------- TextureSet TS IF (i == 0) TS = a0[T] ELSEIF (i == 1) TS = a1[T] ELSEIF (i == 2) TS = a2[T] ;ELSEIF (i == 3) ; TS = a3[T] ELSE Debug.TraceStack(" #0 Invalid number detected! " +i) Return False ; no matching textureset ENDIF ;--------- IF ( TS ) ; look at SKSE script "NetImmerse.psc" NetImmerse.SetNodeTextureSet(oRef, s, TS, TRUE) ; first person view Return TRUE ; Well Done! ENDIF ;-------- Return False ; textureset not found! ENDFUNCTION OnActivate() has been removed, only 3D ready events are used PM_TSCycle_AliasScript Scriptname PM_TSCycle_AliasScript extends ReferenceAlias {each time this object will have 3d loaded, it may change the textureset by random} ; https://forums.nexusmods.com/index.php?/topic/8483648-scriptnewbie-how-you-call-float-value-from-a-quest-script/ ; Original universal script created by Darkfox127 ; update by ReDragon 2020 ; Note: ; Any potential problems which may arise from this script being changed from the original ; are the sole responsibility of the mod author making the changes. ; Please be sure to credit by using some script code in your own published mod! Int PROPERTY iPosNNL = -1 auto ; contains the position of entry in quest property "NodeNameList" (array of string) {required!} Int iCurrentTS ; [default=0] Bool bOK ; [default=False] ;Float fLastTimeUpdate ; [default=0.0], another way to use a condition for next textureset change ; -- EVENTs -- 2 ; ############################################################################################################ ; You have to create a quest (with start game enabled) with some prefilled aliases (assigned with this script) ; ############################################################################################################ EVENT OnCellLoad() myF_Update() ENDEVENT EVENT OnUnLoad() IF ( bOK ) myF_Random() ENDIF ENDEVENT ; -- FUNCTIONs -- 2 ;-------------------- FUNCTION myF_Update() ;-------------------- PM_TSCycle_QuestScript ps = self.GetOwningQuest() as PM_TSCycle_QuestScript IF (ps) && ps.myF_ChangeTS(iPosNNL, self.GetReference(), iCurrentTS) bOK = TRUE ;;; fLastTimeUpdate = Utility.GetCurrentRealTime() ENDIF ENDFUNCTION ;-------------------- FUNCTION myF_Random() ; when 3d gets unloaded try to make a random change of textureset ;-------------------- ; IF Utility.RandomInt(0, 1) ; chance of 50.0 percent ; ;IF Utility.RandomInt(0, 2) ; chance of 66.6 percent ; ;IF Utility.RandomInt(-1, 1) ; chance of 33.3 percent ; ELSE ; RETURN ; - STOP - avoid random change of "iCurrentTS" ; ENDIF ; ---------------------- PM_TSCycle_QuestScript ps = self.GetOwningQuest() as PM_TSCycle_QuestScript IF ( ps ) ELSE RETURN ; - STOP - missing quest script! ENDIF ;--------------------- int n = ps.myF_GetLengthTS(iPosNNL) WHILE (TRUE) ; run loop as long as a condition will not fire "return" IF (n < 2) RETURN ; - STOP - property error OR empty (or single entry) array of texture sets ENDIF ; ---------------------- int i = Utility.RandomInt(0, n) IF (i == iCurrentTS) ELSE iCurrentTS = i RETURN ; - STOP - got another entry within array ENDIF ; ---------------------- ENDWHILE ENDFUNCTION Wow, wonder how your brain works to come up with that complicated code. Your coding is unlike any other code i've ever seen though, quite difficult to understand for beginner like me but i'll get there eventually. Thank you, owe you big time :wink: Link to comment Share on other sites More sharing options...
Recommended Posts