There's nothing that will allow you to do that right.. But I can't see why you would want to?
function RST_and_LAP (event, imsg)
common code for rst and lap
if (event = ISP_RST) then
rst specific code
end
another common code for rst and lap
if (event = ISP_LAP) then
lap specific code
end
yet another common code for rst and lap
end
evt_bind(ISP_RST, RST_and_LAP)
evt_bind(ISP_LAP, RST_and_LAP)
20070508 16:24:19,SAtaN,BL1,SAtaN666,XRR,338,3:35.380,2:43.840,3:12.120
20070511 10:56:39,demon,BL1,,FXR,4,1:31.340,0:33.520,1:02.520
20070511 11:11:36,demon,BL1,,FXR,5,11:05.160,0:33.130,1:02.960
20070511 11:13:00,demon,BL1,,FXR,6,1:23.600,0:29.140,0:58.430
20070511 19:58:15,UnDeAD,BL1,835,RB4,1,2:08.780,1:01.040,1:36.670
20070512 14:44:49,MDK,BL1,373,FXR,28,1:33.110,0:35.860,1:06.050
function ca(imsg)
luaLFS:tiny(1, TINY_NPL)
end
evt_bind(EVT_CONNECTED, ca)
function put_massive(imsg)
local t = luaLFS:npl(imsg)
s = { [t.plid] = { user = "", track = "", plate = t.plate, car = t.cname, sp1 = 0, sp2 = 0, sp3 = 0} }
print("Car: "..s[t.plid].car)
print("Plate: "..s[t.plid].plate)
end
evt_bind(ISP_NPL, put_massive)
function l_split(imsg)
local t = luaLFS:spx(imsg)
if (t.split == 1) then
s[t.plid].sp1 = t.stime
print ("SP1="..s[t.plid].sp1)
end
if (t.split == 2) then
s[t.plid].sp2 = t.stime
print ("SP1="..s[t.plid].sp1)
print ("SP2="..s[t.plid].sp2)
end
if (t.split == 3) then
s[t.plid].sp3 = t.stime
print ("SP1="..s[t.plid].sp1)
print ("SP2="..s[t.plid].sp2)
print ("SP3="..s[t.plid].sp3)
end
end
evt_bind(ISP_SPX, l_split)
function l_lap(imsg)
local t = luaLFS:lap(imsg)
local file_w = io.open("D:/Downloads/LFS/luaLFS-0.7/scripts/laps.log","a")
file_w:write(os.date('%x %X').." "..s[t.plid].plate.." "..s[t.plid].car.." "..t.ltime.." "..s[t.plid].sp1.." "..s[t.plid].sp2.."\n")
file_w:close()
end
evt_bind(ISP_LAP, l_lap)
s = { }
function pause(time)
local time0 = os.time()
while (os.difftime(os.time(), time0) < time) do
end
end
function luaLFS:mci(imsg)
-- print("Parsing MCI")
-- local n, psize, pty, reqi, numc, compcar = bunpack(imsg, "bbbb A?")
local n, psize, pty, reqi, numc = bunpack(imsg, "bbbb")
imsg = string.sub(imsg, 5)
-- ALWAYS string.len(imsg)/28 == numC ??????
---------------------------------------------
local i
local compcar = {}
for i = 1, string.len(imsg)/28 do
local n, node, lap, plid, position, info, sp3, x, y, z, speed, direction, heading, angvel = bunpack(imsg, "HHbbbblllHHHh")
compcar[plid] = { node = node, lap = lap, position = position, info = info, x = x, y = y, z = z, speed = speed, direction = direction, heading = heading, angvel = angvel }
imsg = string.sub(imsg, 29)
end
-- print("MCI parsed")
return { compcar = compcar }
end
local mci = luaLFS:mci(imsg)
...
[I]plid[/I] = ...
print(mci.compcar[[i]plid[/i]].node)
function luaLFS:mci(imsg)
local n, psize, pty, reqi, numc = bunpack(imsg, "bbbb")
local q, compcararr = bunpack(imsg, "A"..28*numc, n)
local compcar = { }
local i, s
s = 0
for i = 1, numc do
local node, lap, plid, position, info, sp3, x, y, z, speed, direction, heading, angvel
s, node, lap, plid, position, info, sp3, x, y, z, speed, direction, heading, angvel = bunpack(imsg, "HHbbbblllHHHh", s)
compcar[plid] = { node = node, lap = lap, position = position, info = info, x = x, y = y, z = z, speed = speed, direction = direction, heading = heading, angvel = angvel }
end
return { numc = numc, compcar = compcar }
end
function luaLFS:mci(imsg)
local n, psize, pty, reqi, numc = bunpack(imsg, "bbbb")
local q, compcararr = bunpack(imsg, "A"..28*numc, n)
local compcar = { }
local i, s
s = 1
for i = 1, numc do
local node, lap, plid, position, info, sp3, x, y, z, speed, direction, heading, angvel
s, node, lap, plid, position, info, sp3, x, y, z, speed, direction, heading, angvel = bunpack(compcararr, "HHbbbblllHHHh", s)
compcar[plid] = { node = node, lap = lap, position = position, info = info, x = x, y = y, z = z, speed = speed, direction = direction, heading = heading, angvel = angvel }
end
return { numc = numc, compcar = compcar }
end
function luaLFS:nlp(imsg)
local n, psize, pty, reqi, nump = bunpack(imsg, "bbbb")
local q, nodelaparr = bunpack(imsg, "A"..6*nump, n)
local nodelap = { }
local i, s
s = 1
for i = 1, nump do
local node, lap, plid, position
s, node, lap, plid, position = bunpack(nodelaparr, "HHbb", s)
nodelap[plid] = { node = node, lap = lap, position = position }
end
return { nump = nump, nodelap = nodelap }
end
function luaLFS:reo(...)
if (arg[n] == 1) then
-- Receiving IS_REO
local n, psize, pty, reqi, nump, plid = bunpack(arg[1], "bbbbb32")
return { nump = nump, plid = plid }
elseif (arg[n] == 3) then
-- Sending IS_REO
-- To use: luaLFS:reo(reqi, nump, tableofplid)
local plids, i
i = 1
for i, arg[2] do
plids = plids..bpack("b", arg[2][i])
end
local omsg = bpack("bbbbA32", 36, ISP_REO, arg[1], arg[2], plids)
luaLFS.sendmsg(omsg, string.len(omsg))
else
error("Invalid arguments")
end
end