Jump to content

Global Variable keeps getting reset to 0


Recommended Posts

Posted

I'm trying to use a global variable in two different scripts, one which exists for MCM, and the other as part of a mod. In both script's properties, I've set the property to be the global variable object, but whenever I go to look at the variable (use it in either the mod or MCM script), it keeps going back to 0.

 

My MCM script looks like this:

Scriptname vkjMCM extends SKI_ConfigBase

GlobalVariable Property vkjOverburdenValue Auto

Int OID_vkjOverburdenValue

Event OnPageReset(string page)
SetCursorFillMode(TOP_TO_BOTTOM)
SetCursorPosition(0)
AddHeaderOption("Lola Options")
AddEmptyOption()
OID_vkjOverburdenValue = AddSliderOption("Overburden Trigger Percentage", vkjOverburdenValue.GetValue(),"{0}%")
AddToggleOption("Hello world?", true)
endEvent

Event OnOptionHighlight(Int Option)
	if(Option == OID_vkjOverburdenValue)
		SetInfoText("Carry Weight Percentage for triggering the Go-To-Town-Binding event")
	Endif
EndEvent

Event OnOptionSliderOpen(Int Option)
	if(Option == OID_vkjOverburdenValue)
		SetSliderDialogStartValue(vkjOverburdenValue.GetValue())
		SetSliderDialogDefaultValue(80)
		SetSliderDialogRange(50,150)
		SetSliderDialogInterval(1)
	Endif
EndEvent

Event OnOptionSliderAccept(Int Option, Float Value)
	if(option == OID_vkjOverburdenValue)
			vkjOverburdenValue.setValue(Value)
			SetSliderOptionValue(Option,Value,"{0}%")
	Endif
EndEvent

and the script which uses my mod looks like this:

Scriptname vkjMQ extends Quest  Conditional

;blah blah blah

GlobalVariable Property vkjOverburdenValue Auto

;blah blah

Event OnInit()
EndEvent

Event OnUpdate()
EndEvent

State Running
	Event OnBeginState()
		;debug.notification("registered for update")
		RegisterForUpdate(eventPeriod)
	EndEvent

	Event OnUpdate() 

                ;blah blah		

		float iw = PlayerRef.GetActorValue("InventoryWeight")
		float cw = PlayerRef.GetActorValue("CarryWeight")
		int ovb = vkjOverburdenValue.getValueInt()
		debug.notification("GlobalOvb is: " + ovb)
		IsOverburdened = (iw > cw * (ovb/100.0))

                ;blah blah
	endEvent
EndState

like, what am I doing wrong? The papyrus script says that it can't get the value of a None object, but the object exists in the global variables

Posted

Ok, weirdness of weirdness:

 

So, I changed the variable name internally by simply removing the vkj in the front, and then attached it to the same global variables. I did this in both scripts, and the problem went away.

 

Odd, but solved.

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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