А еще можно просто писать данные в текстовый файл - и читать его асинхронно внешним софтом!
На основе этого метода работает моя система пульта для TS. Единственный на рынке желдорсим, который позволяет оживить приборную доску.
Call( "SendConsistMessage", MSGID, test1test2test3,1 )
if ( msg == MSGID ) then
test1 = tonumber(string.sub(argument, 1, 5))
test2 = tonumber(string.sub(argument, 6,10))
test3 = tonumber(string.sub(argument, 11, 15))
local message = test1..":"..test2..":"..test3
Call ("SendConsistMessage", MSGID, message, 1)
if (msg == MSGID) then
local table_tests = string.split (argument, ":")
test1 = tonumber (table_tests[1])
test2 = tonumber (table_tests[2])
test3 = tonumber (table_tests[3])
end
function string:split(delimiter)
local result = { }
local from = 1
local index = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
result[index] = string.sub(self, from , delim_from - 1)
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
index = index + 1
end
result[index] = string.sub(self, from)
return result
end
function To_Bin (num)
local temp, bin, i = 0, {}, 0
repeat
temp = num
num = math.floor(num / 2)
table.insert (bin, 1, (temp - num * 2) ~= 0 and "1" or "0")
i = i + 1
until num == 0
bin = string.rep("0", 32 - i)..table.concat(bin)
return bin
end
function BitXOR (a, b)
a = To_Bin (a)
b = To_Bin (b)
local res = {}
for i = 1, 32 do
table.insert (res, string.sub (a, i, i) == string.sub (b, i, i) and "0" or "1")
end
return tonumber (table.concat(res), 2)
end
function BitNOT (num)
num = To_Bin (num)
local res = {}
for i = 1, 32 do
table.insert (res, string.sub (num, i, i) == "1" and "0" or "1")
end
return tonumber (table.concat(res), 2)
end
function BitAND (a, b)
a = To_Bin (a)
b = To_Bin (b)
local res = {}
for i = 1, 32 do
table.insert (res, (string.sub (a, i, i) == "1" and string.sub (b, i, i) == "1") and "1" or "0")
end
return tonumber (table.concat(res), 2)
end
function BitOR (a, b)
a = To_Bin (a)
b = To_Bin (b)
local res = {}
for i = 1, 32 do
table.insert (res, (string.sub (a, i, i) == "1" or string.sub (b, i, i) == "1") and "1" or "0")
end
print (table.concat(res))
return tonumber (table.concat(res), 2)
end
function rshift (x, by)
return math.floor (x / 2 ^ by)
end
function lshift (x, by)
return x * 2 ^ by
end
function reverse (s)
local table_char = {}
for i = 1, string.len (s) do
table.insert (table_char, 1, string.sub (s, i, i))
end
return table.concat(table_char)
end
function mod (a, b)
return a - (math.floor(a/b)*b)
end
A, B, C, D = 10, 40, 30, 20
max = math.max (A, B, C, D)
local a, b, c, d = 10, 40, 30, 20
max = (a > b and a > c and a > d) and a or (b > c and b > d) and b or c > d and c or d
Skif писал(а):
if max_count > 500000 then
end
if max_count < 500000 then
end
if max_count == 500000 then
end
if max_count > 500000 then
elseif max_count < 500000 then
else
end
Вернуться в [RW] Другие вопросы
Сейчас этот форум просматривают: hellishfire и гости: 0