antstubell Posted May 16, 2021 Share Posted May 16, 2021 I don't need to give all the details of what I am doing just that the script I am using for some reason doesn't access the Function. I've checked multiple times that the globals required to be set to 1 are set to 1 using getglobalvalue xxxxxxx. Am I script=blind... again!Thanks for any help. GlobalVariable Property Skull01Set AutoGlobalVariable Property Skull02Set AutoMessage Property MyMenu AutoObjectReference Property LeftAct AutoObjectReference Property RightACT AutoEvent OnActivate(ObjectReference akActionRef)Int iButton = MyMenu.Show() ; Shows menuIf iButton == 0; leftLeftACT.Activate(self); activate left activatorSelf.Disable()Utility.Wait(5); wait for translation to endSelf.Enable()ElseIf (iButton == 1); rightRightACT.Activate(self); activate right activatorSelf.Disable()Utility.Wait(5); wait for translation to endSelf.Enable()EndIfAllSkullsSet()EndEvent;------------------------------------------------------------------------------------Function AllSkullsSet()If (Skull01Set.GetValue() == 1) && (Skull02Set.GetValue() == 1)debug.notification("All Skulls In Place.")Self.Delete()EndifEndFunction Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 16, 2021 Share Posted May 16, 2021 I see no reason why it should not work. I presume you intend for this to trigger during the same activation as the placement of the last item. It could be that because the global is being updated on a separate script that it hasn't made its way to the current script yet. Have you tried activating this object for a third time to see if the function runs? You may want to try a small single update rather than a function. This might allow the script to "catch up" and recognize the change in global value properly. Link to comment Share on other sites More sharing options...
antstubell Posted May 16, 2021 Author Share Posted May 16, 2021 (edited) The global has plenty of time. Player turns a skull at one end of a room to the required angle, message says "Correct Angle", I check global and it's 1. Player then moves to other side of room does the same with a different skull message says "Correct Angle", I check global and it's 1. Both now 1 but function doesn't run. Maybe I should check the function before displaying the menu? I dunno. EDIT: Something wrong with another script. Function is working when one of the values is 0. Debugging required.I've attached one of the scripts that does the skull rotation. This is the left movement script. A different activator turns it right. I could have combined scripts but as you see I have enough trouble. ; control left rotationFloat Property PosX1 AutoFloat Property PosY1 AutoFloat Property PosZ1 AutoFloat Property RotX1 AutoFloat Property RotY1 AutoFloat Property RotationVal AutoFloat Property SpeedVal AutoFloat Property Time AutoFloat Property ReqAngleValue Auto; set to angle we want to succeedFloat Property AngleValueCentre Auto; 270Float Property AngleValueRight Auto; 225Float Property AngleValueLeft Auto; 315GlobalVariable Property MyGlobal AutoObjectReference Property TranslateRef AutoObjectReference Property SFXhere AutoSound Property SFX AutoEvent OnActivate(ObjectReference akActionRef)Float CurrentAngleZ = TranslateRef.GetAngleZ(); get left right Z angleif (CurrentAngleZ == AngleValueRight); 225RtoC()EndIfif (CurrentAngleZ == AngleValueCentre); 270CtoL()EndIfif (CurrentAngleZ == AngleValueLeft); 315debug.notification("Can’t Do That")EndIfSetTheGlobal()EndEvent; --------- From Right to Centre -------------------Function RtoC();debug.notification("Right To Centre")TranslateRef.TranslateTo(PosX1, PosY1, posZ1, RotX1, RotY1, (AngleValueCentre), SpeedVal, RotationVal)SFX.Play(SFXhere)Utility.Wait(Time);debug.notification("Turned1")EndFunction; --------- From Centre to Left -------------------Function CtoL();debug.notification("Centre To Left")TranslateRef.TranslateTo(PosX1, PosY1, posZ1, RotX1, RotY1, (AngleValueLeft), SpeedVal, RotationVal)SFX.Play(SFXhere)Utility.Wait(Time);debug.notification("Turned2")EndFunction; --------- Set Global -------------------Function SetTheGlobal()Float CurrentAngleZ = TranslateRef.GetAngleZ()if (CurrentAngleZ == ReqAngleValue)debug.notification("Angle We Want")MyGlobal.SetValue(1)EndIfif (CurrentAngleZ != ReqAngleValue)MyGlobal.SetValue(0)EndIf Edited May 16, 2021 by antstubell Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 16, 2021 Share Posted May 16, 2021 Shouldn't be an issue but you never know...1 does equal 1.0 but perhaps something fishy is going on, try using floats instead of ints in your GetValue and SetValue statements. And in case you haven't in this particular scenario, test on a new game just to rule out any left over data in the save file. Otherwise, I really don't know. It all looks okay. Link to comment Share on other sites More sharing options...
antstubell Posted May 18, 2021 Author Share Posted May 18, 2021 (edited) This is driving me mad, mainly because I signed out and Nexus can't send password resets to Hotmail accounts - so had to wait for a manual reply and a reset from Nexus.Anyway something strange happening and I am sure your wisdom can throw some light on it. The video shows what I mean but basically - when skulls are in place the left skull requires an 'extra' turn for the message 'All Skulls In Place' to appear. The extra turn still makes the global 1 but why is it needed?. Take a look and see what you think and thanks for your time.SkullTurn.mp4 - OneDrive (live.com) Edited May 18, 2021 by antstubell Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 18, 2021 Share Posted May 18, 2021 Only thing that I can think of is that while the global is being updated, it isn't being updated fast enough for the final function. Thus another turn is required. Try doing a small update registration instead of directly calling a function. This might force it to recognize the updated values. Yes, we can see that the value has updated when you test in the console. But at that point, the final function has already failed. The fact that it works on an additional turn would indicate that the value isn't updated fast enough. To prove this you can put in a fail message to display when either of the global variables is not at the correct value. If that message displays, then you know that the function is running before the value gets updated. Link to comment Share on other sites More sharing options...
antstubell Posted May 19, 2021 Author Share Posted May 19, 2021 As you said the timing is out for the function. I adjusted a couple of Utility.Wait lines and it works. Thank you. Link to comment Share on other sites More sharing options...
AnishaDawn Posted May 23, 2021 Share Posted May 23, 2021 If the thing being activated is the object itself that this script is placed on, you can also use OnTranslationComplete() to handle the enabling and not have to use a wait at all. Link to comment Share on other sites More sharing options...
Recommended Posts