Logging in asynchronously to Lua

In a related question, I asked how to get login through IUP . This works great, except that it goes through the system and depends on the speed, which is not optimal for the game. I would really like to be able to get the current state of any key at a given time. Is there a way to do this (via the IUP or otherwise)?

+1


a source to share


1 answer


You will probably need to wrap the calls to either the appropriate Win32 API, DirectX, or anything in the lua module. Detecting hatch events in the IUP requires that they be delivered to a window or controlled through the "normal" Windows messaging mechanism and is probably not the best approach in a gaming framework.

You can use the IUP timer object to perform scheduled repaints, but you still need a way to collect the keyboard state. If you want to use a gamepad, joystick, or any HID other than keyboard and mouse, then the IUP will not directly help in any way.

This is easy to do with a little C code compiled into a DLL.

This can be done quite easily using SWIG for some kinds of API. Others will require enough setup / tearing effort that it is easier to just wrap the packaging.



There is also an Alien Lua module that allows you to directly call arbitrary APIs from pure Lua. Alien is included as part of Lua for Windows , and also through the Luaforge project page. The alien himself is even somewhat transferred on different platforms, although nothing happened with him.

Something else to look at as you chase this path is one or more existing game engines. They usually hide the event loop inside the engine (like the IUP), but they are optimized for building games, not desktop applications.

There is a number that I heard rumors about the Lua mailing list. The one that comes to mind because it has been mentioned quite often is LÖVE .

+1


a source







All Articles