ШТ
string.format()
Size: a a a
ШТ
string.format()
ШТ
MT
A
MT
MT
if x>72 and x < 77 and y>19 and y<27 then
..
end
-----
if x>30 and x<34 and y>21 and y<31 then
...
end
OK
if x>72 and x < 77 and y>19 and y<27 then
..
end
-----
if x>30 and x<34 and y>21 and y<31 then
...
end
local function in_range(x, y, range)
return
x > range[1][1] and x < range[1][2]
and
y > range[2][1] and y < range[2][2]
end
if in_range(x, y, {{72, 77}, {19, 27}}) then
do_something()
end
if in_range(x, y, {{30, 34}, {21, 31}}) then
do_another_thing()
end
S
'{0} {1}'.format('Hello', 'World')
У меня на луа есть переменная с хтмлом, нужно динамически изменять в некоторых местах некоторый текст, да, можно было бы туда засунуть переменные, но хочется этот хтмл вывести в начало программы и уже потом его использоватьS
function t(tmpl, tbl)
local function replace(c)
return tbl[c] or '{' .. c .. '}'
end
return tmpl:gsub('{(.-)}', replace)
end
local tmpl = "Hello {bla}!"
local str = t(tmpl, {bla = 'World'})
-->"Hello World!"MT
function interp(s, tab)
return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end))
end
S
S
A
A
A
S
S
local stamp = os.time()
... код скрипта
stamp = os.time() - stamp
print(stamp, stamp/60)