Update main.lua

This commit is contained in:
tangent committed 2026-10-29 18:03:45 -06:00
1 parent 052a637f7c
commit 3cf682ba71
1 file changed
+30
+30
View File
@@ -1,7 +1,37 @@
local tilesheet = require "lib.tilesheet" local tilesheet = require "lib.tilesheet"
local utf8 = require "utf8"
local utility = require "lib.utility" local utility = require "lib.utility"
local window_width, window_height = love.graphics.getDimensions()
local tiles local tiles
local current_text = ""
function love.load()
love.keyboard.setKeyRepeat(true)
end
function love.draw()
love.graphics.printf("Prompt:", 0, 0, window_width)
love.graphics.printf(current_text, 0, 20, window_width) -- lazy magic numbers
end
function love.textinput(character)
current_text = current_text .. character
end
function love.keypressed(key)
if key == "escape" then
love.event.quit()
elseif key == "backspace" then
local byteoffset = utf8.offset(current_text, -1)
if byteoffset then
current_text = current_text:sub(1, byteoffset - 1)
end
elseif key == "enter" then
-- TODO end of a textinput; what to do depends on what was being asked
end
end
function love.filedropped(file_path) function love.filedropped(file_path)
if file_path:sub(-5) == ".json" then if file_path:sub(-5) == ".json" then