Jump to content

Why is this Function not working?


antstubell

Recommended Posts

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 Auto
GlobalVariable Property Skull02Set Auto
Message Property MyMenu Auto
ObjectReference Property LeftAct Auto
ObjectReference Property RightACT Auto

Event OnActivate(ObjectReference akActionRef)
Int iButton = MyMenu.Show() ; Shows menu
If iButton == 0; left
LeftACT.Activate(self); activate left activator
Self.Disable()
Utility.Wait(5); wait for translation to end
Self.Enable()

ElseIf (iButton == 1); right
RightACT.Activate(self); activate right activator
Self.Disable()
Utility.Wait(5); wait for translation to end
Self.Enable()

EndIf

AllSkullsSet()

EndEvent
;------------------------------------------------------------------------------------
Function AllSkullsSet()
If (Skull01Set.GetValue() == 1) && (Skull02Set.GetValue() == 1)
debug.notification("All Skulls In Place.")
Self.Delete()
Endif
EndFunction

 

Link to comment
Share on other sites

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

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 rotation

Float Property PosX1 Auto
Float Property PosY1 Auto
Float Property PosZ1 Auto
Float Property RotX1 Auto
Float Property RotY1 Auto

Float Property RotationVal Auto
Float Property SpeedVal Auto
Float Property Time Auto

Float Property ReqAngleValue Auto; set to angle we want to succeed
Float Property AngleValueCentre Auto; 270
Float Property AngleValueRight Auto; 225
Float Property AngleValueLeft Auto; 315
GlobalVariable Property MyGlobal Auto
ObjectReference Property TranslateRef Auto
ObjectReference Property SFXhere Auto
Sound Property SFX Auto

Event OnActivate(ObjectReference akActionRef)

Float CurrentAngleZ = TranslateRef.GetAngleZ(); get left right Z angle

if (CurrentAngleZ == AngleValueRight); 225
RtoC()
EndIf

if (CurrentAngleZ == AngleValueCentre); 270
CtoL()
EndIf

if (CurrentAngleZ == AngleValueLeft); 315
debug.notification("Can’t Do That")
EndIf

SetTheGlobal()

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)
EndIf


if (CurrentAngleZ != ReqAngleValue)
MyGlobal.SetValue(0)
EndIf

 

Edited by antstubell
Link to comment
Share on other sites

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

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 by antstubell
Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...