Percentage Display (CMS)
From The Official Visionaire Studio: Adventure Game Engine Wiki
* to do *
This script is taken from my volume control script (which I've not added to the wiki, yet). Essentially it takes the counts the amount of characters in val & then splits each character (number) into a separate animation which the number (0 to 9) determines which frame should be active for each animation; if value is less than 3 or 2 then it will automatically set the animation to the last frame which should contain a blank image, which is used to hide the animation/digit from the screen.
Main Script
-- to do...
function setPerc(val)
if string.len(val) < 3 then -- check digit value less than 3 & if so, hide the invalid digits
for i = (string.len(val) + 1), 3 do -- actual digit value (+1) to max digit value
getObject("ActiveAnimations[percVal_" .. i .. "]"):setValue(VAnimationFirstFrame, 11) -- blank animation frame
getObject("ActiveAnimations[percVal_" .. i .. "]"):setValue(VAnimationLastFrame, 11) -- blank animation frame
end
end
for i = 1, string.len(val) do -- set the frame value to match the digit number
getObject("ActiveAnimations[percVal_" .. i .. "]"):setValue(VAnimationFirstFrame, string.sub(val, i, i) + 1) -- set animation frame to digit value (+1)
getObject("ActiveAnimations[percVal_" .. i .. "]"):setValue(VAnimationLastFrame, string.sub(val, i, i) + 1) -- set animation frame to digit value (+1)
end
end