Keyboard input...?

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Keyboard input...?

Post by Gambit37 »

OK, this one is way beyond my current knowledge and capabilities:

Is it possible to have a full screen renderer that can accept user input via keyboard?

If so, is there anything in the base code that might suggest how to do it?
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Keyboard input...?

Post by Sophia »

I'm not sure if it's in the base code but you'll want to use dsb_poll_keyboard in your fullscreen renderer's main loop. It returns nil if the user hasn't pressed a key, or a table containing various information about the pressed key if the user has. The table contains various indices but the two that are most important to you are key which is the pressed key represented as a string, and keycode which is the pressed key represented as an integer.

So if you're using it to let the user type something in, you can store key in a table or concatenate it to a string or whatever you want to do with it.

Code: Select all

rtbl = dsb_poll_keyboard()
mystr = mystr .. rtbl.key
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Keyboard input...?

Post by Gambit37 »

Ah nice, OK, I think that should be enough to get me started. But expect lots of questions about this when I get stuck... :)
Post Reply