The online racing simulator
I've added it to my copy and I'll hopefully be finishing a few bits of code off tonight to bundle with an updated release.
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
Attached files
api.zip - 3.1 KB - 287 views
luaLFS:sta bug
in current api luaLFS:sta() does not return 'viewplid'
Hi all!
I have a problem when launching this InSim. See attached pic
Attached images
insim.jpg
icyocean,
Fixed in trunk. I'll be popping together an update tomorrow.

Also have fixed an issue with the IS_REO packet (thanks maczo).

Töki (HUN), you've either:
1. Not enabled InSim properly on your client (type /insim 29999 [or a port of your choice, it just has to match whats in config.lua) into a text / chat dialog)
2. Picked a different port that InSim in running on to that which is configured in the config.lua file
3. You have a firewall blocking it
Noobish post alert.

I downloaded luaLFS yesterday and after some reading I wanted to play with it a bit. Problem is, it keeps timing out (the in-game message is "InSim timeout : luaLFS v0.9"). I have no scripts running besides the default connected.lua, which seems to work fine (displays messages upon connection; I have no idea what to do to make it close by means of iii).

The timeout happens usually after about a minute or so, and all the time luaLFS uses around 80% of cpu time (single-core Intel-something 1.7GHz, possibly running at 700MHz to save energy though (notebook) ). I've had this with default config, trying a smaller value for polling doesn't seem to have an effect. I'm running WinXP BTW.

Have I missed something obvious in the doc regarding keeping the connection alive? I've assumed it's not my duty. Or is it?
No, it shouldnt be your duty at all. Nor should luaLFS be using that much of your processor, unless you're doing something really mad in a script.

You might want to try a higher select time out (the polling configuration - say 30). Does that help?

One thing I didn't note in DOCUMENTATION was that any Lua script blocks since the Lua scripts are currently run in the same process as the actual network code, which means if you use luaLFS.sleep(x) (where x is a number of seconds), it will cause a network timeout.
OK, I deleted the whole directory and unzipped the archive again to make sure it was not caused by me doing something silly. Unfortunately no changes. Remote assistance would be welcome, screenie below (if you see any spyware etc. processes, feel free to let me know ).

LuaLFS timed out just a few seconds after the screenshot was taken. :sadbanana
Attached images
luaLFS_problem.png
I'm gonna regret this, but can you run luaLFS with verbose mode? (set verbose = 1). It's gonna spam a lot of crap to the screen, but I need to know what it's doing

Edit:
I've had a better idea.
Could you put luaLFS into verbose mode by editing the config.lua file, then extract the attached debug.zip file to the same directory as luaLFS and run that instead. Once it closes then upload debug.txt which should be in the same directory.

Edit 2: Slight cock up in the batch file. This one will work.
Now LuaLFS took on average 98% of cpu time If I don't keep LFS minimized, the load spreads: 40% LFS, 60% LuaLFS.
Funny thing is, this time LuaLFS did not timeout, it just quit after some time (about a minute again). When I tried to reproduce it, it would timeout the next two attempts.

Edit: OK, I'll try that. debug.zip needed though :P

Edit2: This time it closed (according to in-game message)
LuaLFS v0.9
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/connected.lua

Loading config

Sending 1 (Sizes: Sent 44, Actual 44)
Sending 3 (Sizes: Sent 4, Actual 4)
Connected
Calling hook connected funcs
luaLFS v0.9 connected
Sending 13 (Sizes: Sent 68, Actual 68)
sent
Sending 3 (Sizes: Sent 4, Actual 4)
Connection lost
Calling hook disconnected funcs
Calling hook create funcs
Closing 'Keepalive'
Closing 'Lua'
Connection to 'localhost' failed
Connection to 'localhost' failed
insim_recv: Connection Timeout

Attached images
lua_close.png
Would you mind pasting your config.lua also?
Quote :Connection to 'localhost' failed

try use 127.0.0.1
Quote from A.Fedorov :try use 127.0.0.1

If localhost fails then there's probably something not right with the box..
config.lua (untouched out of the archive)
config =
{
--- Configuration for luaLFS
--- Must exist
luaLFS =
{
-- Auto reconnect
-- This is a VERY dangerous setting. It effectively puts luaLFS
-- into a recursive loop, trying to connect FOREVER.
-- If set it overrides connection_attempts
-- It is HIGHLY recommended that it remains set to 0, except for servers
-- Use at your own risk
auto_reconnect = 0,
-- Number of times luaLFS attempts to connect to LFS - overridden
-- if auto_reconnect is set
connection_attempts = 5,
-- ADVANCED
-- polling is the amount of time between select() timeouts
-- also used for the amount of time between connection attempts
polling = 5,
-- Minimum timeout in seconds before we assume LFS has been closed,
timeout = 70,
-- verbosity of luaLFS: consider as a debugging mode
verbose = 1,
},
--- Configuration for LFS
--- Must exist
LFS =
{
-- The address of computer running LFS
address = "localhost",
-- The port LFS is listening for InSim connections on
port = 29999,
-- The administrative password
password = "password",
-- Number of ms between NLP or MCI packets (0=none)
interval = 0,
-- Flags
-- Example; Requests both NLP and MCI packets;
-- flags = bit.bor(ISF_NLP, ISF_MCI),
-- Example; Allows for local buttons and gets NLP packets
-- flags = bit.bor(ISF_LOCAL, ISF_NLP),
flags = 0,
-- Character to prefix all messaged destined specifically for the host
prefix = "!",
},
}

Setting addr to 127.0.0.1 makes no difference, unfortunately. I have a bad feeling I somehow screwed something up badly and I'm gonna blush when we nail this down.
I don't see how you've screwed anything up atm. You're running a default config, with InSim enabled on LFS. I don't see why its currently eating CPU, and I don't see why its failing to connect atm - do you have any firewall software, or antivirus by any chance?
Quote from the_angry_angel :I don't see why its currently eating CPU, and I don't see why its failing to connect atm - do you have any firewall software, or antivirus by any chance?

Well - yes, and yes. Standard windows firewall is on and I'm using AVG antivirus. I just figured it can't be the source of problems, as the connection is being established, but times out. I'll try turning them off and see if that helps.

Edit: Turning off the firewall doesn't help.
Edit2: The same with antivirus
Looking at the output from luaLFS, you're not actually receiving any packets from LFS at all... which is very odd as you should get at least an ISP_VER.. How sure are you that your firewall is allowing the connection? Any half decent firewall would stop any connection, but right now that's the only thing I can think of that would make sense right now...

For the record, this is what I would expect as proper "verbose" output;
Sending 1 (Sizes: Sent 44, Actual 44)
Sending 3 (Sizes: Sent 4, Actual 4)
Connected
Calling hook connected funcs
luaLFS v0.9 connected
Sending 13 (Sizes: Sent 68, Actual 68)
sent
retval 20, total local buffer size: 20
Recv 'Keepalive'
Recv 'Lua'
Received 2, size 20
Buffer size: 0
retval 28, total local buffer size: 28
Recv 'Keepalive'
Recv 'Lua'
Received 5, size 28
Buffer size: 0

You see it sending the ISP_ISI and ISP_VER request, then receiving the IS_VER response, then an IS_STA..
Quote from the_angry_angel :Looking at the output from luaLFS, you're not actually receiving any packets from LFS at all... which is very odd as you should get at least an ISP_VER.. How sure are you that your firewall is allowing the connection? Any half decent firewall would stop any connection, but right now that's the only thing I can think of that would make sense right now...

How sure? Totally disabling the firewall didn't help, so I guess it's 'moderately sure'
With firewall turned on, I have exceptions for LFS, luaLFS and the port 29999 (TCP). Anything else to check?
I wouldn't have thought so, but it would depend on the firewall tbh... I'm just making a few, small changes, and adding something to help debugging, and hopefully make sure that the connection is true...
luaLFS 1.0 (no there is no significance of it being 1.0, it's just less confusing than 0.10, as technically I should've made all the previous releases 0.01, etc.).

Changes:
* libinsim: Added a new hook event (pre-recv)
* libinsim: Moved all the connection keepalive code into the Keepalive hook
* libinsim: Added IS_VER detection - if we don't get it, we inform the user and quit - the assumption is that a connection has not been established correctly
* libinsim / config.lua: introduction of connection_fast to avoid a sleep call
* Misc fixes in ./scripts/core/api.lua
* Bundled "debug" script to aide debugging
* Misc fixes and/ore updates to NOTICE, README and DOCUMENTATION

maczo;
Could you give this one a go, and see if it helps at all?
Attached files
luaLFS-1.0.zip - 139.9 KB - 474 views
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/connected.lua
Loading config

Sending 1 (Sizes: Sent 44, Actual 44)
Sending 3 (Sizes: Sent 4, Actual 4)
Connection established
Calling hook connected funcs
luaLFS v1.0 connected
Sending 13 (Sizes: Sent 68, Actual 68)
sent
Calling hook prerecv funcs
PreRecv 'Keepalive'
PreRecv 'Lua'
Calling hook prerecv funcs
PreRecv 'Keepalive'
PreRecv 'Lua'
Calling hook prerecv funcs
PreRecv 'Keepalive'
PreRecv 'Lua'
Calling hook prerecv funcs
PreRecv 'Keepalive'
PreRecv 'Lua'
Calling hook prerecv funcs
PreRecv 'Keepalive'
PreRecv 'Lua'

(goes on for 8kB)

Calling hook prerecv funcs
PreRecv 'Keepalive'
PreRecv 'Lua'
Calling hook prerecv funcs
PreRecv 'Keepalive'
PreRecv 'Lua'
Sending 3 (Sizes: Sent 4, Actual 4)
Disconnected
Calling hook disconnected funcs
Calling hook close funcs
Closing 'Keepalive'
Closing 'Lua'
Config: Warning, 'timeout' too low - reset from 40 to 70
hkeepalive_prerecv: Didn't receive ISP_VER response in a seemly amount of time.

So I guess I really have to see why there's no communication from LFS

Edit: I just tried Vain's LFS Pitboard and the firewall asked me whether to let it connect when I executed the program, which wasn't the case with luaLFS. I really have no clue why.
Quote from maczo :Edit: I just tried Vain's LFS Pitboard and the firewall asked me whether to let it connect when I executed the program, which wasn't the case with luaLFS. I really have no clue why.

Pass. I'm not doing anything unusual in creating the socket (other than using the berkeley functions).. Which firewall software do you use?
I'm using Windows' built-in firewall. I tried removing all exceptions regarding luaLFS, but it still didn't ask me whether to let it connect. I think I'll have to do some research on this on my own. I'll let you know if I find out anything.
I still have no idea why the connection fails. I tried it on my other computer (also WinXP and built-in firewall) with exactly same results. Could anyone with WinXP SP2 confirm that they managed to have luaLFS connect (and stay connected) and share their firewall settings if possible, please?
Have you tried connecting starting LFS up with the /insim command-line and trying to connect luaLFS to it and see if it works? Have you stopped the firewall and tried connecting?

Quote from maczo :I still have no idea why the connection fails. I tried it on my other computer (also WinXP and built-in firewall) with exactly same results. Could anyone with WinXP SP2 confirm that they managed to have luaLFS connect (and stay connected) and share their firewall settings if possible, please?


FGED GREDG RDFGDR GSFDG