Jump to content

[LE] How do I modify alias property values through MCM?


pxd2050

Recommended Posts

How do I modify alias property values through MCM?
Here's what I did wrong:

Event OnConfigClose()
	Alias_Follower[0].P_RightDist = UseXDist1
	Alias_Follower[0].P_BackDist = UseYDist1
	Alias_Follower[1].P_RightDist = UseXDist2
	Alias_Follower[1].P_BackDist = UseYDist2
	Alias_Follower[2].P_RightDist = UseXDist3
	Alias_Follower[2].P_BackDist = UseYDist3
	Alias_Follower[3].P_RightDist = UseXDist4
	Alias_Follower[3].P_BackDist = UseYDist4
	Alias_Follower[4].P_RightDist = UseXDist5
	Alias_Follower[4].P_BackDist = UseYDist5
	Alias_Follower[5].P_RightDist = UseXDist6
	Alias_Follower[5].P_BackDist = UseYDist6

	Game.SetGameSettingFloat("fAIMinGreetingDistance", (UseXDist1 - 1))
	TMB_GreetingDistance.setvalue(UseXDist1)
	int i = 0
	while i < 6	
		If 	Alias_Follower[i].GetActorReference()
			Alias_Follower[i].GetActorReference().EvaluatePackage()
		EndIf
		i+=1
	endwhile
EndEvent

2021-11-18-205659.png

Edited by pxd2050
Link to comment
Share on other sites

Your approach is like using a record. It does not work for Skyrim papyrus scripting. You have to cast the form (referenalias, objectReference, actor etc.) into a valid script. The result can be used to modify properties in this script. Maybe next code is helpful for you.

 

 

 

; https://forums.nexusmods.com/index.php?/topic/10736913-how-do-i-modify-alias-property-values-through-mcm/

  GlobalVariable PROPERTY TMB_GreetingDistance auto

  ReferenceAlias[] PROPERTY Alias_Follower auto

  Float UseXDist1
  Float UseXDist2
  Float UseXDist3
  Float UseXDist4
  Float UseXDist5
  Float UseXDist6

;-------------------------
FUNCTION myF_DistXY(Int i)
;-------------------------
    TBM_AliasScript ps = Alias_Follower[i] as TBM_AliasScript
    float fx
    float fy

IF ( ps )                        ; Is pointer to script valid?
    IF     (i == 0)
        fx = UseXDist1
        fy = UseYDist1

    ELSEIF (i == 1)
        fx = UseXDist2
        fy = UseYDist2

    ELSEIF (i == 2)
        fx = UseXDist3
        fy = UseYDist3

    ELSEIF (i == 3)
        fx = UseXDist4
        fy = UseYDist4

    ELSEIF (i == 4)
        fx = UseXDist5
        fy = UseYDist5

    ELSEIF (i == 5)
        fx = UseXDist6
        fy = UseYDist6
    ELSE
        RETURN    ; - STOP -    no valid array entry
    ENDIF
;    ----------------------
    ps.P_RightDist = fx
    ps.P_BackDist  = fy
ENDIF
ENDFUNCTION


EVENT OnConfigClose()
    float f = UseXDist1
    Game.SetGameSettingFloat("fAIMinGreetingDistance", f - 1.0)
    TMB_GreetingDistance.SetValue(f)

    int i = 0
    WHILE (i < 6)                                            ; (i < Alias_Follower.Length)
        actor aRef = Alias_Follower[i].GetActorReference()
        IF ( aRef )
            myF_DistXY(i)    
            aRef.EvaluatePackage()
        ENDIF
        i = i + 1
    ENDWHILE
ENDEVENT

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

Your approach is like using a record. It does not work for Skyrim papyrus scripting. You have to cast the form (referenalias, objectReference, actor etc.) into a valid script. The result can be used to modify properties in this script. Maybe next code is helpful for you.

 

 

 

; https://forums.nexusmods.com/index.php?/topic/10736913-how-do-i-modify-alias-property-values-through-mcm/

  GlobalVariable PROPERTY TMB_GreetingDistance auto

  ReferenceAlias[] PROPERTY Alias_Follower auto

  Float UseXDist1
  Float UseXDist2
  Float UseXDist3
  Float UseXDist4
  Float UseXDist5
  Float UseXDist6

;-------------------------
FUNCTION myF_DistXY(Int i)
;-------------------------
    TBM_AliasScript ps = Alias_Follower[i] as TBM_AliasScript
    float fx
    float fy

IF ( ps )                        ; Is pointer to script valid?
    IF     (i == 0)
        fx = UseXDist1
        fy = UseYDist1

    ELSEIF (i == 1)
        fx = UseXDist2
        fy = UseYDist2

    ELSEIF (i == 2)
        fx = UseXDist3
        fy = UseYDist3

    ELSEIF (i == 3)
        fx = UseXDist4
        fy = UseYDist4

    ELSEIF (i == 4)
        fx = UseXDist5
        fy = UseYDist5

    ELSEIF (i == 5)
        fx = UseXDist6
        fy = UseYDist6
    ELSE
        RETURN    ; - STOP -    no valid array entry
    ENDIF
;    ----------------------
    ps.P_RightDist = fx
    ps.P_BackDist  = fy
ENDIF
ENDFUNCTION


EVENT OnConfigClose()
    float f = UseXDist1
    Game.SetGameSettingFloat("fAIMinGreetingDistance", f - 1.0)
    TMB_GreetingDistance.SetValue(f)

    int i = 0
    WHILE (i < 6)                                            ; (i < Alias_Follower.Length)
        actor aRef = Alias_Follower[i].GetActorReference()
        IF ( aRef )
            myF_DistXY(i)    
            aRef.EvaluatePackage()
        ENDIF
        i = i + 1
    ENDWHILE
ENDEVENT

 

 

Thank you for your kind reply. I'll try it later. For me who don't know much English, programming is like a heavenly book. ha-ha

Link to comment
Share on other sites

  • Recently Browsing   0 members

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