some basic error checking on keys.lua

This commit is contained in:
Lilian Jónsdóttir 2020-07-09 23:58:29 -07:00
parent 53eef6f083
commit 33208a900d

View file

@ -1,8 +1,7 @@
local keys = require("Keyboard Layout Changer.keys")
local supportedLayouts = ""
for name, _ in pairs(keys) do
supportedLayouts = supportedLayouts .. name .. " "
end
for name, _ in pairs(keys) do supportedLayouts = supportedLayouts .. name .. " " end
local this = {}
@ -15,9 +14,15 @@ this.modInfo = "Allows use of non-qwerty keyboard layouts.\n\nCurrently supporte
function this.log(str) mwse.log("[%s] %s", this.modName, str) end
function this.changeLayout(layout)
if keys[layout] and (#keys[layout].lowercase == 256 and #keys[layout].uppercase == 256) then
-- Thanks NullCascade
mwse.memory.writeBytes({address = 0x775148, bytes = keys[layout].lowercase})
mwse.memory.writeBytes({address = 0x775248, bytes = keys[layout].uppercase})
else
local message = "Bad keys.lua file, please re-install."
this.log(message)
tes3.messageBox(string.format("(%s) %s", this.modName, message))
end
end
return this