1lytics

Value shifting/rotation

gkShiftLogicValueUp

The gkShiftLogicValueUp function performs shift (rotation) of logic value in "Up" direction. Input can be -1 (undefined), 0 or 1. Function adds 1 to input value and return result of that operation. If result is greater than 1, function returns -1.

newVal = gkShiftLogicValueUp(val)

Parameters

  • val - value to rotate/shift.

Usage sample

-- displays -1, 0, 1, -1
val = -1
gkMessageBox("info", 'Val: ' .. val)
val = gkShiftLogicValueUp(val)
gkMessageBox("info", 'Val: ' .. val)
val = gkShiftLogicValueUp(val)
gkMessageBox("info", 'Val: ' .. val)
val = gkShiftLogicValueUp(val)
gkMessageBox("info", 'Val: ' .. val)

gkShiftLogicValueDown

The gkShiftLogicValueDown function performs shift (rotation) of logic value in "Down" direction. Input can be -1 (undefined), 0 or 1. Function substracts 1 from input value and return result of that operation. If result is less than -1, function returns 1.

newVal = gkShiftLogicValueDown(val)

Parameters

  • val - value to rotate/shift.

Usage sample

-- displays -1, 1, 0, -1
val = -1
gkMessageBox("info", 'Val: ' .. val)
val = gkShiftLogicValueDown(val)
gkMessageBox("info", 'Val: ' .. val)
val = gkShiftLogicValueDown(val)
gkMessageBox("info", 'Val: ' .. val)
val = gkShiftLogicValueDown(val)
gkMessageBox("info", 'Val: ' .. val)