Watchmaker scroll text lua script
V1.11
(changes: scrolls smoother)
This script will scroll text. It returns a string that consists of the scrolled text. It can scroll any number of texts just call it from the text field.
Call with:
var_textScroll("texthere", integer space to use, integer scroll rate,{dss})
E. G.
var_textScroll("some long bit of text", 6,1,{dss})
The {dss} at the end makes watchmaker update it each tick.
1 is the speed of scrolling. It will scroll faster in the wm emulator than the watch. Higher is faster. 0.5 is slower
6 is how many characters to use
--text scroller: put this function in your main watchface script
--text scroller
var_runTime = {}
function var_textScroll(myText,space,interval)
var_runTime[myText] = var_runTime[myText] or 0
var_runTime[myText] = var_runTime[myText] + 1
local start
local myEnd
if not interval then interval = 1 end
local length= string.len(myText)
--dont scroll
if length <= space then return myText end
local runningTime = var_runTime[myText]
start = ((runningTime) % (length/interval)) * interval
myEnd = start + space
local text = string.sub(myText, start, myEnd)
if myEnd > length then
text = string.sub(text.."..."..myText, 1,space)
end
return text
end
(changes: scrolls smoother)
This script will scroll text. It returns a string that consists of the scrolled text. It can scroll any number of texts just call it from the text field.
Call with:
var_textScroll("texthere", integer space to use, integer scroll rate,{dss})
E. G.
var_textScroll("some long bit of text", 6,1,{dss})
The {dss} at the end makes watchmaker update it each tick.
1 is the speed of scrolling. It will scroll faster in the wm emulator than the watch. Higher is faster. 0.5 is slower
6 is how many characters to use
--text scroller: put this function in your main watchface script
--text scroller
var_runTime = {}
function var_textScroll(myText,space,interval)
var_runTime[myText] = var_runTime[myText] or 0
var_runTime[myText] = var_runTime[myText] + 1
local start
local myEnd
if not interval then interval = 1 end
local length= string.len(myText)
--dont scroll
if length <= space then return myText end
local runningTime = var_runTime[myText]
start = ((runningTime) % (length/interval)) * interval
myEnd = start + space
local text = string.sub(myText, start, myEnd)
if myEnd > length then
text = string.sub(text.."..."..myText, 1,space)
end
return text
end
Pretty cool script, thank you,
ReplyDeleteIt will help with my personal digital watchface for when the location that the weather report is coming from is too long.
One thing, it adds a period to the end of the text, how can I remove it>
I'm getting the whole thing scrolling, not just the text part. What am I doing wrong? Am I putting something in more than one place? I already have one global script in use for colors.
ReplyDelete