The online racing simulator
Searching in All forums
(132 results)
A.Fedorov
No longer welcome
Error if i not have internet connection (WR). I have use this addon for LAN. Fix it please.
A.Fedorov
No longer welcome
Quote :Connection to 'localhost' failed

try use 127.0.0.1
A.Fedorov
No longer welcome
old fix but in new api

function luaLFS:small(reqi, subt, uval)
local omsg = bpack("bbbbL", 8, IS[B]P[/B]_SMALL, reqi, subt, uval)
luaLFS.sendmsg(omsg, string.len(omsg))
end

--------------
function luaLFS:mod(sixteenbit, refresh, width, height)
local omsg = bpack("bbbbllll", 20, IS[B]P[/B]_MOD, 0, 0, sixteenbit, refresh, width, height)
luaLFS.sendmsg(omsg, string.len(omsg))
end

and all arg[n] or table.maxn(arg) need replace #arg

api: fix+add func
A.Fedorov
No longer welcome
for future
[!] api of BFN incomplete
A.Fedorov
No longer welcome
for future:
- turn off MCI if it not needed
- before get who wins need get MCI packet all drag racers
A.Fedorov
No longer welcome
with good description that must do script at items was much easier its write
A.Fedorov
No longer welcome
my first big script DRAG on BL1. For demo players useful for fun race.

for help type /i help

start line after S-turn where end right-curb (in this place, you see the texture change of track)

include: scripts + api
require: luaLFS-0.8
A.Fedorov
No longer welcome
I maked some script. Now i can drag on BL1 (and other track only need correct coordinate), i have traffic-light for start. Using it for fun race
A.Fedorov
No longer welcome
if point(xa,ya) in square area then true or else false


function vectors(x1,y1,x2,y2,x3,y3,x4,y4, xa,ya)

local s = math.abs(1/2*((x1-x3)*(y2-y3)-(x2-x3)*(y1-y3))) + math.abs(1/2*((x3-x1)*(y4-y1)-(x4-x1)*(y3-y1)))

local sa = math.abs(1/2*((x1-xa)*(y2-ya)-(x2-xa)*(y1-ya))) + math.abs(1/2*((x2-xa)*(y3-ya)-(x3-xa)*(y2-ya))) + math.abs(1/2*((x3-xa)*(y4-ya)-(x4-xa)*(y3-ya))) + math.abs(1/2*((x4-xa)*(y1-ya)-(x1-xa)*(y4-ya)))

if (s ~= sa) then
return false
elseif (s == sa) then
return true
end
end

A.Fedorov
No longer welcome
I think with X, Y need use Heading.

Description cars using 4 point (like rectangle) and check lie everything peak of rectangle first car into square second car and retrogradely.



- MCI get position of car relative to center (Xnc,Ync).
- you need have a peaks (Xn1,Yn1;Xn2,Yn2;Xn3,Yn3;Xn4,Yn4) relative to center.
- using trigonometry will help you get absolute coordinate of peaks.
- if one of top of one machine appertained in square another => collision
Last edited by A.Fedorov, .
A.Fedorov
No longer welcome
how use CPP? i try with function of api

-- CAMERA CONTROL
-- XXX: Needs to be finished
function luaLFS:cpp(...)
if (table.maxn(arg) == 1) then
local n, psize, pty, reqi, zero, x, y, z, h, p, r, viewplid, ingamecam, fov, time, flags = bunpack(arg[1], "bbbblllHHHbbfHH")
return { x = x, y = y, z = z, h = h, p = p, r = r, viewplid = viewplid, ingamecam = ingamecam, fov = fov, time = time, flags = flags }
end
end

use script


function l_init(imsg)
luaLFS:small(0, SMALL_NLI, 1000)
luaLFS:tiny(1, TINY_NPL)
end
evt_bind(EVT_CONNECTED, l_init)

function ttest(imsg)
print("ok")
local cpp = luaLFS:cpp(imsg)
luaLFS:btn(1, 255, 1, 0, 0, 0, 172, 15, 28, 10, "PLID="..cpp.viewplid)
luaLFS:btn(2, 255, 1, 0, 0, 0, 172, 25, 28, 10, "X="..cpp.x)
luaLFS:btn(3, 255, 1, 0, 0, 0, 172, 35, 28, 10, "Y="..cpp.y)
luaLFS:btn(4, 255, 1, 0, 0, 0, 172, 45, 28, 10, "Z="..cpp.z)

luaLFS:btn(5, 255, 1, 0, 0, 0, 172, 55, 28, 10, "H="..cpp.h)
luaLFS:btn(6, 255, 1, 0, 0, 0, 172, 65, 28, 10, "P="..cpp.p)
luaLFS:btn(7, 255, 1, 0, 0, 0, 172, 75, 28, 10, "R="..cpp.r)

luaLFS:btn(8, 255, 1, 0, 0, 0, 172, 85, 28, 10, "FOV="..cpp.fov)
luaLFS:btn(9, 255, 1, 0, 0, 0, 172, 95, 28, 10, "Time="..cpp.time)
end
evt_bind(ISP_CPP, ttest)

function tre(imsg)
luaLFS:tiny(1, TINY_SCP)
end
evt_bind(ISP_MCI, tre)

nothing
A.Fedorov
No longer welcome
You want get handicap of user who now on track?
It's possible.

If you want i make script for luaLFS which print all handicaps (mass and restrict) of racers using command /i handi
A.Fedorov
No longer welcome
its my issue or really bug?
A.Fedorov
No longer welcome
^8 - default color and Latin-1
^9 - only default color

tested on ISP_MTC
ISP_III (wrong message from user)
A.Fedorov
No longer welcome
I get message with cyrillic words - ^cwords not ^Cwords and if i use this for output with ISP_MTC i see :words

not tested with other language and ISP_MSO
A.Fedorov
No longer welcome
test this
Quote from the_angry_angel :function luaLFS:reo(...)
if (table.maxn(arg) == 1) then
-- Receiving IS_REO
local n, psize, pty, reqi, nump, plid = bunpack(arg[1], "bbbbb32")
return { nump = nump, plid = plid }
elseif (table.maxn(arg) == 3) then
-- Sending IS_REO
[/code]

A.Fedorov
No longer welcome
scroll line

function scroll_line(imsg)
luaLFS.sleep(3)
local i
local str = "^2TEST ^8Scroll Line For Info"

for i = 1, 200, 1 do
luaLFS:btn(1, 255, 1, 0, 32, 0, 0, 100, i, 10, str)
luaLFS.sleep(0.0001)
end
luaLFS.sleep(5)
for i = 200, 1, -1 do
luaLFS:btn(1, 255, 1, 0, 32, 0, 200-i, 100, i, 10, str)
luaLFS.sleep(0.0001)
end
luaLFS:bfn(0, 255, 1, 0)
end
evt_bind(EVT_CONNECTED, scroll_line)

A.Fedorov
No longer welcome
First script for drag on demo server StartLine. I use area (4 coordinates). If car into this area (s = sa[s, sa - square area] => car in area) all see text You crossed starting line.


+ svetofor script. type /i start
Last edited by A.Fedorov, .
A.Fedorov
No longer welcome
I don't know lua language. I only small learn it.
A.Fedorov
No longer welcome
Great!

byte Size; // 4 + NumP * 6 (PLUS 2 if needed to make it a multiple of 4)

its not important?

Think about this nodelap[plid], compcar[plid]. Need memory. How clear if car leave track? Remember that it internal function and it not use fix value (like plid in table). All data from compcarArr need treat with external script. Or not.
Last edited by A.Fedorov, .
A.Fedorov
No longer welcome
Thanks. Your function is compacted
fixed

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

Last edited by A.Fedorov, .
A.Fedorov
No longer welcome
need test with many cars on track
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

use in script something like this

local mci = luaLFS:mci(imsg)
...
[I]plid[/I] = ...
print(mci.compcar[[i]plid[/i]].node)

Last edited by A.Fedorov, .
A.Fedorov
No longer welcome
fix function luaLFSapi:small
local omsg = bpack("bbbbL", 8, ISP_SMALL, reqi, subt, uval)

fix function luaLFSapi:mod
local omsg = bpack("bbbbllll", 20, ISP_MOD, 0, 0, bits, rr, width, height)
A.Fedorov
No longer welcome
hey, i think need make force engine stall if we have now force cocpit view
A.Fedorov
No longer welcome
Tested. Work me too
FGED GREDG RDFGDR GSFDG