ive tried
Code: Select all
if blaa blaa and
love.keyboard.isDown("return") or
love.keyboard.isDown("kpenter") then
blaa blaa
end
i also want to do it so W and the up arrow do the same thing
any thoughts?
Code: Select all
if blaa blaa and
love.keyboard.isDown("return") or
love.keyboard.isDown("kpenter") then
blaa blaa
end
You should have done this :lolsasory wrote:is there a way to do something like love.keyboard.isDown("return") love.keyboard.isDown("kpenter") have the same command
ive triedbut that doesnt workCode: Select all
if blaa blaa and love.keyboard.isDown("return") or love.keyboard.isDown("kpenter") then blaa blaa end
Code: Select all
if abooleanvalue and (keyDown1 or keyDown2) then
makecake
end
Code: Select all
if abooleanvalue and (keyDown1 or keyDown2) then
makecake
end
Code: Select all
if blaa blaa and love.keyboard.isDown("return", "kpenter") then
blaa blaa
end
Code: Select all
if ky.isDown('lshift','rshift') and ky.isDown('z') then zoom = zoom + dt end
if ky.isDown( 'z' ) and not ky.isDown('lshift','rshift') then zoom = zoom > 0.1 and zoom - dt or dt end
You can convert the unicode into string, you can try a function, like this:Inny wrote:This is handy for english keyboard input. However, it doesn't work with anything above 126, as Lua lacks unicode support.
Code: Select all
function love.load()
tab = {}
txt = ""
font = love.graphics.newFont("consola.ttf", 20)
love.graphics.setFont(font)
end
function love.draw()
love.graphics.print(txt, 0, 0)
end
function love.keypressed(key, code)
table.insert(tab, code)
txt = conv2utf8(tab)
end
function conv2utf8(unicode_list)
local result = ""
local w,x,y,z = 0,0,0,0
for i,v in ipairs(unicode_list) do
if v ~= 0 and v ~= nil then
if v <= 0x7F then -- same as ASCII
result = result .. string.char(v)
elseif v >= 0x80 and v <= 0x7FF then -- 2 bytes
y = math.floor((v % 0x000800) / 64)
z = v % 0x000040
result = result .. string.char(0xC0 + y, 0x80 + z)
elseif (v >= 0x800 and v <= 0xD7FF) or (v >= 0xE000 and v <= 0xFFFF) then -- 3 bytes
x = math.floor((v % 0x010000) / 4096)
y = math.floor((v % 0x001000) / 64)
z = v % 0x000040
result = result .. string.char(0xE0 + x, 0x80 + y, 0x80 + z)
elseif (v >= 0x10000 and v <= 0x10FFFF) then -- 4 bytes
w = math.floor((v % 0x200000) / 262144)
x = math.floor((v % 0x040000) / 4096)
y = math.floor((v % 0x001000) / 64)
z = v % 0x000040
result = result .. string.char(0xF0 + w, 0x80 + x, 0x80 + y, 0x80 + z)
end
end
end
return result
end
That looks like an awesome candidate for https://love2d.org/wiki/Category:Snippets , Care to put it up there?Przemator wrote:You can convert the unicode into string, you can try a function, like this: ...
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests