Does Text Sub Work in JIT?
Posted: Wed Nov 19, 2014 4:31 am
Hi this is a code experiment to draw text one character at a time using dt.
I am using concatenation and the text library.
It does not work anymore like with 5.1, Im thinking they switched the text library.
All libraries are in C right?
The code has no errors. The text just does not draw at all.
Im thinking its because of some syntax sugar referencing the table library... Not yet JIT eh with len and sub statements?
I am using concatenation and the text library.
It does not work anymore like with 5.1, Im thinking they switched the text library.
All libraries are in C right?
Code: Select all
function love.load()
text = {
['t'] = 0,
['c'] = 0,
['n'] = 0,
['speed'] = 10,
['max'] = 217,
['line'] = 31,
['msg'] = "Hello World!",
['cat'] = "",
}
end
function love.update(dt)
function text_loop(dt)--draw text one at a time
text['t'] = text['t'] + (text['speed']*dt)
if text['t'] > 0.2 then-- 0.2 seconds.
text['t'] = 0--add the letter
if text['cat']:len() <= text['max'] and text['cat']:len() <= text['msg']:len() then
text['cat'] = text['cat']..text['msg'].sub(text['msg'],text['c'],text['c'])
text['c'] = text['c'] + 1 --next letter (text count)
text['n'] = text['n'] + 1 --next letter (line count)
if text['n'] == text['line'] then --end of line
text['cat'] = text['cat'].."\n" --draw on new line
text['n'] = 0
end
end
end
end
end
function love.draw()
love.graphics.print(text['cat'],5,420)
end
Im thinking its because of some syntax sugar referencing the table library... Not yet JIT eh with len and sub statements?