function drawtext(str, xo, yo, scl, fade, spacing, pal)
	local palidx = 0
	if type(pal)=="number" then
		palidx = pal
	end

	xx = xo
	for i = 1, #str do
		local c = string.byte(str:sub(i,i))
		
		local digit = 100 + c - 48
		if (c >= 65) then
			digit = 110 + c - 65
		elseif (c == 58) then -- :
			digit = 141
		elseif (c == 47) then -- /
			digit = 142	
		elseif (c == 32) then
			digit = 0
		elseif (c == 33) then -- !
			digit = 138	
		elseif (c == 63) then -- !
			digit = 139
		elseif (c == 46) then -- .
			digit = 136
		elseif (c == 44) then -- ,
			digit = 137	
		elseif (c == 39) then -- ''
			digit = 144
		elseif (c == 45) then -- -
			digit = 145
		end

		if digit ~= 0 then
			rotatesprite(xx, yo, scl, 0,   digit,   fade, palidx, 2,    0,0,1,1);
		end

		xx = xx + spacing * scl
	end

end

function drawtimer(str, xo, yo, scl, fade)
	drawtext(str,xo,yo,scl,fade, 16.0)
end


-- poellittye
function replace_char(pos, str, r)
    return str:sub(1, pos-1) .. r .. str:sub(pos+1)
end
