Jump to content

If, ElseIf, Else conditions not counting correctly


antstubell

Recommended Posts

You want to modify your Skyrim.ini file in the documents folder or wherever it might be located for the profile used by your mod manager (if using one). Keep in mind that if the game gets updated or the files verified by Steam, these changes will need to be redone (unless using a mod manager profile instance). Creating a SkyrimCustom.ini file is supposed to be an option but I personally never got that to work with original Skyrim. And opted to use the Mod Organizer profile instances to hold any INI modifications instead.

 

Change these default lines:

[Papyrus]
fPostLoadUpdateTimeMS=500.0
bEnableLogging=0
bEnableTrace=0
bLoadDebugInformation=0

To the following:

[Papyrus]
bEnableLogging=1
bEnableProfiling=0
bEnableTrace=1
bLoadDebugInformation=1
fPostLoadUpdateTimeMS=2000

For information on what these specific setting do, see here: https://www.creationkit.com/index.php?title=INI_Settings_(Papyrus)

You can opt to not change the fPostLoadUpdateTimeMS. That setting was changed by BethINI and brings it in line with game consoles.

 

The log files (no more than 4 total as older ones will be overwritten) will appear in "Documents > My Games > [skyrim or Fallout 4 game in question] > Logs > Script" Some mods will have a troubleshooting option or automatically create a separate trace log that will appear in a "User" folder inside the script folder.

 

To interpret errors, warnings and other information that you see not directly associated with your own trace statements, see here:

https://www.creationkit.com/index.php?title=Papyrus_Runtime_Errors

https://www.afkmods.com/index.php?/topic/4129-skyrim-interpreting-papyrus-log-errors/

Link to comment
Share on other sites

So I should add bEnableProfiling=0 because it's not there.

If you won't be changing the value from default (i.e. 0) it does not need to be added. Again that was something put in by BethINI. It adds all the possible settings because they do allow users to make advanced changes if they wish.

Link to comment
Share on other sites

About your source code, see next code changes maybe its helpful.

 

antShrineObjectScript

 

Scriptname antShrineObjectScript extends ObjectReference
; https://forums.nexusmods.com/index.php?/topic/10469948-if-elseif-else-conditions-not-counting-correctly/

 ;GlobalVariable Property SMTgv_ShrineNorth auto
 ;GlobalVariable Property SMTgv_ShrineEast  auto
 ;GlobalVariable Property SMTgv_ShrineSouth auto
 ;GlobalVariable Property SMTgv_ShrineWest  auto
 ;GlobalVariable Property SMTgv_ShrineTempValHolder Auto

  GlobalVariable PROPERTY SMTgv_ShrineActCount    auto        ; int counter
  GlobalVariable PROPERTY SMTgv_ShrineActivated01 auto
  GlobalVariable PROPERTY SMTgv_ShrineActivated02 auto
  GlobalVariable PROPERTY SMTgv_ShrineActivated03 auto
  GlobalVariable PROPERTY SMTgv_ShrineRaiseBeam   auto        ; bool

  String PROPERTY Text  auto
  String PROPERTY Text2 auto

  Sound PROPERTY SFX1 auto
  Sound PROPERTY SFX2 auto
  Sound PROPERTY SFX3 auto

  ObjectReference PROPERTY SndMarker1 auto
  ObjectReference PROPERTY SndMarker2 auto
  ObjectReference PROPERTY SndMarker3 auto

  ObjectReference PROPERTY PreDisObj01 auto
  ObjectReference PROPERTY LSource     auto

  ObjectReference PROPERTY TranslateRef auto
  ObjectReference PROPERTY BeamRaise    auto

; set constant values here
  Float PROPERTY Adelay          auto
  Float PROPERTY RotationVal     auto
  Float PROPERTY SpeedVal        auto
  Float PROPERTY TimeQuarterTurn auto    ; InputMovement
  Float PROPERTY TimeHalfTurn    auto    ; InputMovement

;------------------- your shrine setting is
;      E         2
;   S --- N   3 --- 1
;      W         4

;------------------- normal compass direction
;      N
;   W --- E
;      S

; statue starts facing south

  Int Property InputRotZVal  auto    ; [default=0.0], RotZ statue angle when facing this shrine
  Int Property IsWest  = 270 auto    ; 360° - 90
  Int Property IsSouth = 180 auto    ; 360° - 180
  Int Property IsEast  =  90 auto    ; 360° - 270
  Int Property IsNorth =   0 auto

  Float Property PosX1 Auto
  Float Property PosY1 Auto
  Float Property PosZ1 Auto

  Float Property RotX1 Auto
  Float Property RotY1 Auto
  Float Property RotZ1 Auto

 ;GlobalVariable Property MyGlobal Auto
 ;Int Property Val auto


; -- EVENTs --

EVENT OnCellLoad()
    Debug.Trace(" OnCellLoad(" +self.IsEnabled()+ ") - has been called for.. " +self)    ; what is going on here
ENDEVENT

EVENT OnUnLoad()
    Debug.Trace(" OnUnLoad(" +self.IsEnabled()+ ") - has been called for.. " +self)      ; what is going on here
ENDEVENT


EVENT OnActivate(ObjectReference akActionRef)
    Debug.Notification(Text)

IF (InputRotZVal == TranslateRef.GetAngleZ() as Int)
    ; this will not show until the activator is re-enabled
    debug.notification("Already Facing This Way")

    myF_Lights()
    SFX3.Play(SndMarker3)
    self.Disable()
ELSE
    ; statue is not already in the place, where we are activating it from
    self.Disable()
    myF_Action()

    debug.notification("Check 3 digits and activate?")
    myF_TryBeam()
ENDIF
ENDEVENT


; -- FUNCTIONs -- 4

;--------------------
FUNCTION myF_Lights()
;--------------------
    PreDisObj01.Disable()           ; light shrine
    LSource.Enable()                ; shrine light source
    int i = SFX1.Play(SndMarker1)   ; candle ignite sound
ENDFUNCTION


;--------------------
FUNCTION myF_Action()
;--------------------
    Debug.Notification("Assigning a Value.")

;;;    SMTgv_ShrineTempValHolder.SetValueInt(i)    ; *** init temp holder
;----------------------------
    SMTgv_ShrineActCount.Mod(1)                           ;* increase by 1

    IF     (SMTgv_ShrineActivated01.GetValueInt() == 0)   ; if the value from globalVar is not set
        SMTgv_ShrineActivated01.SetValueInt(i)            ; then set the current shrine activation value

    ELSEIF (SMTgv_ShrineActivated02.GetValueInt() == 0)
        SMTgv_ShrineActivated02.SetValueInt(i)

    ELSEIF (SMTgv_ShrineActivated03.GetValueInt() == 0)
        SMTgv_ShrineActivated03.SetValueInt(i)
    ENDIF

    Utility.Wait(0.5)
;----------------------------
;;;    SMTgv_ShrineTempValHolder.SetValueInt(0)    ; *** resets temp holder

    myF_Lights()
    Utility.Wait(0.5)

    Debug.notification(Text2)
;;;    MyGlobal.SetValue(Val)        ; set global value for this shrine  ???

    myF_Translate(n)
    Utility.Wait(1.0)

    SFX3.Play(SndMarker3)            ; play >> SFX3

    IF (SMTgv_ShrineActCount.GetValueInt() == 3)
        SMTgv_ShrineActCount.SetValueInt(0)                ;* reset to Zero, shrine activation counter
    ENDIF
ENDFUNCTION


;---------------------
FUNCTION myF_TryBeam()  ; go to check digits
;---------------------
IF (SMTgv_ShrineRaiseBeam.GetValue() == 0)

    ; shrine activation order is:
    ; 2 - east
    ; 1 - north
    ; 4 - west

    IF (SMTgv_ShrineActivated01.GetValue() == 2) && (SMTgv_ShrineActivated02.GetValue() == 1) && (SMTgv_ShrineActivated03.GetValue() == 4)

        SMTgv_ShrineRaiseBeam.SetValue(1)
        Utility.Wait(Adelay)
        BeamRaise.Activate(self as ObjectReference)
    ENDIF

ENDIF
ENDFUNCTION


;-----------------------
FUNCTION myF_Translate()
;-----------------------
    int i = TranslateRef.GetAngleZ() as Int ; get rotation angle

; now get the sfx play time
    float f

    IF     (InputRotZVal == IsNorth)        ; north - 1
;        ----------------
        IF (i == IsSouth)
            f = TimeHalfTurn
        ELSE ;IF (i == IsEast) || (i == IsWest)
            f = TimeQuarterTurn
        EndIf
    
    ELSEIF (InputRotZVal == IsEast)         ; east  - 2
;        ----------------
        IF (i == IsWest)
            f = TimeHalfTurn
        ELSE ;IF (i == IsNorth) || (i == IsSouth)
            f = TimeQuarterTurn
        ENDIF

    ELSEIF (InputRotZVal == IsSouth)        ; south - 3
;        ----------------
        IF (i == IsNorth)
            f = TimeHalfTurn
        ELSE ;IF (i == IsEast) || (i == IsWest)
            f = TimeQuarterTurn
        ENDIF
    
    ELSE ;IF (InputRotZVal == IsWest)       ; west  - 4
;        ----------------
        IF (i == IsEast)
            f = TimeHalfTurn
        ELSE ;If (i == IsNorth) || (i == IsSouth)
            f = TimeQuarterTurn
        ENDIF
    ENDIF

; now recycle "i" for sound instance
    i = SFX2.Play(SndMarker2)        ; play >> SFX2

    TranslateRef.TranslateTo(PosX1,PosY1,PosZ1, RotX1,RotY1,RotZ1, SpeedVal, RotationVal)
    Utility.Wait(f)

    Sound.StopInstance(i)            ; stop << SFX2
ENDFUNCTION

 

 

 

edited second version

antShrineObjectScript

 

Scriptname antShrineObjectScript extends ObjectReference
; https://forums.nexusmods.com/index.php?/topic/10469948-if-elseif-else-conditions-not-counting-correctly/

 ;GlobalVariable Property SMTgv_ShrineNorth auto
 ;GlobalVariable Property SMTgv_ShrineEast  auto
 ;GlobalVariable Property SMTgv_ShrineSouth auto
 ;GlobalVariable Property SMTgv_ShrineWest  auto
 ;GlobalVariable Property SMTgv_ShrineTempValHolder Auto

  GlobalVariable PROPERTY SMTgv_ShrineActCount    auto        ; int counter
  GlobalVariable PROPERTY SMTgv_ShrineActivated01 auto
  GlobalVariable PROPERTY SMTgv_ShrineActivated02 auto
  GlobalVariable PROPERTY SMTgv_ShrineActivated03 auto
  GlobalVariable PROPERTY SMTgv_ShrineRaiseBeam   auto        ; bool

  String PROPERTY Text  auto
  String PROPERTY Text2 auto

  Sound PROPERTY SFX1 auto
  Sound PROPERTY SFX2 auto
  Sound PROPERTY SFX3 auto

  ObjectReference PROPERTY SndMarker1 auto
  ObjectReference PROPERTY SndMarker2 auto
  ObjectReference PROPERTY SndMarker3 auto

  ObjectReference PROPERTY PreDisObj01 auto
  ObjectReference PROPERTY LSource     auto

  ObjectReference PROPERTY TranslateRef auto
  ObjectReference PROPERTY BeamRaise    auto

; set constant values here
  Float PROPERTY aDelay          auto
  Float PROPERTY RotationVal     auto
  Float PROPERTY SpeedVal        auto
  Float PROPERTY TimeQuarterTurn auto    ; InputMovement
  Float PROPERTY TimeHalfTurn    auto    ; InputMovement

;------------------- your shrine setting is
;      E         2
;   S --- N   3 --- 1
;      W         4

;------------------- normal compass direction
;      N
;   W --- E
;      S

; statue starts facing south

  Int Property InputRotZVal  auto    ; [default=0.0], RotZ statue angle when facing this shrine
  Int Property IsWest  = 270 auto    ; 360° - 90
  Int Property IsSouth = 180 auto    ; 360° - 180
  Int Property IsEast  =  90 auto    ; 360° - 270
  Int Property IsNorth =   0 auto

  Float Property PosX1 Auto
  Float Property PosY1 Auto
  Float Property PosZ1 Auto

  Float Property RotX1 Auto
  Float Property RotY1 Auto
  Float Property RotZ1 Auto

 ;GlobalVariable Property MyGlobal Auto
 ;Int Property Val auto


; -- EVENTs --

EVENT OnCellLoad()
    Debug.Trace(" OnCellLoad(" +self.IsEnabled()+ ") - has been called for.. " +self)    ; what is going on here
ENDEVENT

EVENT OnUnLoad()
    Debug.Trace(" OnUnLoad(" +self.IsEnabled()+ ") - has been called for.. " +self)      ; what is going on here
ENDEVENT


EVENT OnActivate(ObjectReference akActionRef)
    Debug.Notification(Text)
    self.Disable()                        ; switch OFF

    IF myF_IsEqual()
        ; this will not show until the activator is re-enabled
        debug.notification("Already Facing This Way")
        myF_Lights()
        myF_SFX3()
    ELSE
        ; statue is not already in the place, where we are activating it from
        myF_Action()
        debug.notification("Check 3 digits and activate?")
        myF_TryBeam()
    ENDIF
ENDEVENT


; -- FUNCTIONs -- 5

;--------------------------
Bool FUNCTION myF_IsEqual()
;--------------------------
    RETURN (InputRotZVal == TranslateRef.GetAngleZ() as Int)
ENDFUNCTION


;--------------------
FUNCTION myF_Lights()
;--------------------
    PreDisObj01.Disable()    ; light shrine
    LSource.Enable()         ; shrine light source
    SFX1.Play(SndMarker1)    ; candle ignite sound, returns int
ENDFUNCTION


;------------------
FUNCTION myF_SFX3()
;------------------
    SFX3.Play(SndMarker3)    ; retuns int
ENDFUNCTION


;---------------------
FUNCTION myF_TryBeam()  ; go to check digits
;---------------------
IF (SMTgv_ShrineRaiseBeam.GetValue() == 0)

    ; shrine activation order is:
    ; 2 - east
    ; 1 - north
    ; 4 - west

    IF (SMTgv_ShrineActivated01.GetValue() == 2) && (SMTgv_ShrineActivated02.GetValue() == 1) && (SMTgv_ShrineActivated03.GetValue() == 4)

        SMTgv_ShrineRaiseBeam.SetValue(1)
        Utility.Wait(aDelay)
        BeamRaise.Activate(self as ObjectReference)

    ENDIF
ENDIF
ENDFUNCTION


;--------------------
FUNCTION myF_Action()
;--------------------
    Debug.Notification("Assigning a Value.")
    SMTgv_ShrineActCount.Mod(1)                            ;* increase by 1

    int i = TranslateRef.GetAngleZ() as Int      ; get rotation angle
    float T
    float f

; =1= now get the sfx play time

    IF     (InputRotZVal == IsNorth)             ; - north -
        T = 1                                    ; SMTgv_ShrineTempValHolder.SetValue(1)
;       ----------------
        IF (i == IsSouth)
            f = TimeHalfTurn
        ELSE ;IF (i == IsEast) || (i == IsWest)
            f = TimeQuarterTurn
        EndIf
    
    ELSEIF (InputRotZVal == IsEast)              ; - east -
        T = 2                                    ; SMTgv_ShrineTempValHolder.SetValue(2)
;       ----------------
        IF (i == IsWest)
            f = TimeHalfTurn
        ELSE ;IF (i == IsNorth) || (i == IsSouth)
            f = TimeQuarterTurn
        ENDIF

    ELSEIF (InputRotZVal == IsSouth)             ; - south -
        T = 3                                    ; SMTgv_ShrineTempValHolder.SetValue(3)
;       ----------------
        IF (i == IsNorth)
            f = TimeHalfTurn
        ELSE ;IF (i == IsEast) || (i == IsWest)
            f = TimeQuarterTurn
        ENDIF
    
    ELSE ;IF (InputRotZVal == IsWest)            ; - west -
        T = 4                                    ; SMTgv_ShrineTempValHolder.SetValue(4)
;       ----------------
        IF (i == IsEast)
            f = TimeHalfTurn
        ELSE ;If (i == IsNorth) || (i == IsSouth)
            f = TimeQuarterTurn
        ENDIF
    ENDIF

; =2= if value from globalVar is Zero then set value of current shrine

    IF     (SMTgv_ShrineActivated01.GetValue() == 0)
        SMTgv_ShrineActivated01.SetValue( T )            ; first shrine

    ELSEIF (SMTgv_ShrineActivated02.GetValue() == 0)
        SMTgv_ShrineActivated02.SetValue( T )            ; second shrine

    ELSEIF (SMTgv_ShrineActivated03.GetValue() == 0)
        SMTgv_ShrineActivated03.SetValue( T )            ; third shrine
    ENDIF

; =3= switch lights

    Utility.Wait(0.5)
    myF_Lights()
    Utility.Wait(0.5)

; =4= now recycle "i" for sound instance
    i = SFX2.Play(SndMarker2)        ; play >> SFX2

    TranslateRef.TranslateTo(PosX1,PosY1,PosZ1, RotX1,RotY1,RotZ1, SpeedVal, RotationVal)
    Utility.Wait(f)            ; ** f **

    Debug.notification(Text2)
;;;    MyGlobal.SetValue(Val)                                ; set global value for this shrine  ???

    Sound.StopInstance(i)            ; stop << SFX2
    Utility.Wait(1.0)

;;;    SFX3.Play(SndMarker3)         ; play >> SFX3
    myF_SFX3()

    IF (SMTgv_ShrineActCount.GetValue() == 3)
        SMTgv_ShrineActCount.SetValue(0)                ;* reset to Zero, shrine activation counter
    ENDIF
ENDFUNCTION

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

@ReDragon. I copied and pasted your script 'as is' and compiled. Got these errors.

 

E:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\SMTshrineElvenScript2.psc(122,44): variable i is undefined
E:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\SMTshrineElvenScript2.psc(122,32): type mismatch on parameter 1 (did you forget a cast?)
E:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\SMTshrineElvenScript2.psc(125,44): variable i is undefined
E:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\SMTshrineElvenScript2.psc(125,32): type mismatch on parameter 1 (did you forget a cast?)
E:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\SMTshrineElvenScript2.psc(128,44): variable i is undefined
E:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\SMTshrineElvenScript2.psc(128,32): type mismatch on parameter 1 (did you forget a cast?)
E:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\SMTshrineElvenScript2.psc(141,18): variable n is undefined
E:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\SMTshrineElvenScript2.psc(141,4): too many arguments passed to function
No output generated for SMTshrineElvenScript2, compilation failed.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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