Jump to content

[LE] SKI UI, Multiply output subtracts 1 from result.


Recommended Posts

I don't know why this is happening, but I have a simple math operation that takes a global variable, multiplies it by 0.1. Normally this outputs like it should, but if I use an MCM programmed for SKI UI to adjust the 0.1 and put it back, it outputs the value by 1 less then it should.

 

This script fragment is the main one that runs this calculation:

 

gTotalPaid.GetValue() = 5,000 * gPercent.GetValue() = 0.1

fTot = (gTotalPaid.GetValue() * gPercent.GetValue())
gTotIncStat.SetValue(fTot)

fTot outputs 500 if untouched, but if I move it up to 0.11 and back to 0.10, it then outputs 499.

 

This isn't the full code, but this is what I use for my SKU UI. These are the important pieces of the code that actually do the adjustments:

 

 

;CODE FRAGMENTS

;----------
;Properties
;----------

float Property fDefPer auto

float fPer

GlobalVariable Property gTotIncStat auto
GlobalVariable Property gInterval auto

int iTot

int _Multiplier
int _ForceMoney

AboveScript property IncQS auto

;---------
;Functions
;---------

event OnPageReset(string page) ;When the meny starts these values are assigned

	iTot = gTotIncStat.GetValue() as int
	fPer = gPercent.GetValue()

	_Multiplier = AddSliderOption("Income Multiplier", fPer, "x{2}") ;This is the slider itself

endEvent


event OnOptionSliderOpen(int option) ;This is how my slider adjust the settings

	SetSliderDialogStartValue(fPer)
	SetSliderDialogDefaultValue(fDefPer)
	SetSliderDialogRange(0.01, 10)
	SetSliderDialogInterval(0.01)

endEvent


event OnOptionSliderAccept(int option, float value) ;This segment will set the percent global to the selected value, and re-run the other code fragment from another script

	gPercent.SetValue(value)
	fPer = value
	SetSliderOptionValue(_Multiplier, fPer, "x{2}")
	IncQS.UpdStatVal()

	iTot = gTotIncStat.GetValue() as int ;Updates the ForceMoney value
	SetTextOptionValue(_ForceMoney, iTot)

endEvent
 

 

 

 

What's weird is it will subtract 1 from only some multiples. Multiples of 0.05 generally subtract 1, but not all. 0.08 will even give me a flat 400.

 

Does anyone know why Papyrus calculates like this? It shouldn't be rounding up/down since 0.10 should be outputting whole numbers. It just takes 1 away from the result on some multiplier values for seemingly no reason.

Edited by xWilburCobbx
Link to comment
Share on other sites

Ok new development... It's got to be something SKI UI is doing. If I set the value by using the OnOptionDefault() function with a float value that is set to 0.1, it will work normally.

float Property fDefPer = 0.1 auto

event OnOptionDefault(int option)

	gPercent.SetValue(fDefPer)
	fPer = fDefPer
	SetSliderOptionValue(_Multiplier, fPer, "x{2}")
	IncQS.UpdStatVal()
	iTot = gTotIncStat.GetValue() as int ;Updates the ForceMoney value
	SetTextOptionValue(_ForceMoney, iTot)
	
endEvent

Something about SKI UI's slider system is probably outputting strange values.

Edited by xWilburCobbx
Link to comment
Share on other sites

  • Recently Browsing   0 members

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