The online racing simulator
anyone?? :|
I'm currently not working on luaLFS at all, but you should find in scripts/disabled server-api.lua which has an example of how to subscribe to the IS_MSO packet, and IS_III, both which should give you a good start on how to subscribe to events and how to use them.

There are a few problems with luaLFS that I've not come up with a good way to solve. A lot of which are related to newcomers to programming for InSim, and problems people have with lua, and understanding its nuances.
Greetings, to me were possible to be connected to IRC and even to receive all messages with ISP_MSO. But works not as it would be desirable. Subroutine start (coroutine) is carried out by means of ISP_MCI. And if sit in spectator their messages will not get in IRC.

proc1 = coroutine.create(function ()
socket = require("socket")
client = socket.tcp()
client:settimeout(0)
res,err = client:connect("192.168.6.14", 6667)
print("connect",res,err)

function send(txt)
...
end

function recv()
...
end

function future()
...
end

-- Identify yourself
send("NICK Luabot")
send("USER Luabot 0 * :I am from the moon")

timer = future()
timer.register(5,function() send("JOIN #bot-tests") end)

repeat

res, err, timeout = recv()

if not err and not timeout then

if string.sub(res,1,4) == "PING" then
-- ping request
send(string.gsub(res,"PING","PONG",1))
elseif string.sub(res,1,1) ~= ":" then
...
end
end
timer.check()

coroutine.yield()
until err

client:close()
end)

function send_to_irc(imsg)
local t = luaLFS:mso(imsg)
local p = luaLFS:stripctrlchars(t.msg)
timer.register(1,function() send("PRIVMSG #bot-tests :"..string.char(3).."2From LFS: "..string.char(3)..p) end)
end
evt_bind(ISP_MSO, send_to_irc)

function tr()
coroutine.resume(proc1)
end
evt_bind(ISP_MCI, tr)

if use instead function tr()
while 1 do
coroutine.resume(proc1)
end

events never start
Just a quick bump with a note that this should really be in the LFS Programming Libs and Tools forum. Again, very nice work TAA, the concept is just biblically awesome.
Yeah, but I ain't working on it or any LFS projects any more (if someone wants to take it up and develop it further I'd be perfectly happy with that), and quite frankly it'll fall into disrepair fairly quickly (evidence by the fact that I was asked to fix something with luaLFS fairly recently and I refused said person).

Plus lapper has become the defacto standard so I never bothered moving on with it. Consider it a learning tool for other programmers (of how not to do this - the API I came up with is terrible and needs fixing badly, plus theres whole piles of problems regarding multiple scripts since they all run in the same scope, plus the C is shit), not a lib and I'd be happier tbh.
Quote from the_angry_angel :plus theres whole piles of problems regarding multiple scripts since they all run in the same scope

I had a mess around getting similar idea working with Python as the scripting language (basically a hosting environment for pyinsim) and ran into ridiculously big concurrency problems. Lots of scripts, threads and sockets all trying to do things at the same time. I think the idea is awesome, but the effort to get it working is so large, and everyone would just use Lapper instead anyway.
While I have boundless respect for LFSLapper, but I really liked where this project was going and I still think the pyInSim project has so much promise. Anyway, the environment's them selfs will only get better if there is competition. LFSLapper needs you guys more then ever to continue to see how things can be better. It can only benefit the community as a whole. I truly believe that we can do better with the current systems we have (InSim), I believe that when we get direct control of the LFS engine we can do so much better. But working with the tools we have access to now we can still have no maxed out what is possible with it.
luaLFS 1.01 (repeat's Changes)

09-Mar-2010

[*] polling - in config `polling` time interval, in milliseconds.
[+] EVT_THREAD - Event starts at each packet received or a period equal to `polling` (see config).

[*] luaLFS.sleep(x) - This makes luaLFS sleep for X milliseconds.

[*] Powered By Lua 5.1.4




Example: something like thread process
----------------------- CUT -----------------------
proc1 = coroutine.create(function ()
while true do
print("execute proc1")
coroutine.yield()
end
end)

proc2 = coroutine.create(function ()
while true do
print("execute proc2")
coroutine.yield()
end
end)


function thread()
coroutine.resume(proc1)
coroutine.resume(proc2)
end
evt_bind(EVT_THREAD, thread)
----------------------- CUT -----------------------
Attached files
luaLFS-1.01.zip - 142.8 KB - 232 views
Ping? Pong!
I got this " ping? pong! " problem... what's wrong? :O

""""""""""""""""
LuaLFS v1.0
Powered By Lua 5.1
This product is developed as open source software.
Please review the bundled LICENSE, NOTICE and README files for further details.
Registered 'Keepalive' module
Registered 'Lua' module
Loading core
Loading Event IDs
Loading Events
Loading API v0.1
Loading scripts/api.lua
Loading API v0.1
Loading scripts/event.lua
Loading Events
Loading scripts/event_id.lua
Loading Event IDs
Loading scripts/startup.lua
Loading config
Connection established
Got VER
Ping? Pong!
Ping? Pong!
Ping? Pong!
It's the keep-alive, which is mentioned in the InSim documentation. luaLFS is a framework for establishing and maintaining an InSim connection, by itself it's not supposed to actually "do" more than maintain the connection:
Quote from http://www.lfsforum.net/showthread.php?t=19832 :luaLFS monitors the connection, keeping it alive, and watches for timeouts.

What exactly are you trying to create with it?
Me bored. )
Is someone use this tool? It really easy make testing ideas or do a little project.
Learn PHP and use PRISM, then you won't be bored!
Not with Lua or luaLFS (since 2007) I'm afraid. Aspects of Lua's language feel very odd to me in recent years, and it's turned me off the language a lot. Additionally luaLFS had a lot of issues with blocking code in scripts, if I recall correctly and I believe I felt it was a flawed implementation.

Porting luaLFS to luvit might be interesting though. luvit is a port of node.js to Lua, and it comes with most (perhaps all now) of the standard node library - that adds a lot of pre-baked in functionality. That said, I'm not going to be the one to do it. Between occasionally faffing with xi4n and a few other non-LFS projects, I don't think I'd want to take it on
Quote from the_angry_angel :Additionally luaLFS had a lot of issues with blocking code in scripts, if I recall correctly and I believe I felt it was a flawed implementation.

Do You mean that until script not end next packet not start parse?
In the PRISM not like this?
Yeah, never heard of Luvit, but hey, ASync IO for Lua that's always a good thing! Well then repeat83, apparently you should port LuaLFS to use Luvit and then you won't be bored.

Quote from repeat83 :In the PRISM not like this?

PRISM's network IO is non-blocking unlike LuaLFS ... We are working on making SQL IO nonblocking in the next major version of PRISM as well.

FGED GREDG RDFGDR GSFDG