Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local fileHeader =
- [[
- -----------------------------------------
- -- Custom Key Layout --
- -----------------------------------------
- ----------------Remapper------------------
- local map = {}
- local function addRemap(expected, modifier)
- map[expected] = modifier
- end
- function os.pullEvent(filter)
- local evt = {os.pullEventRaw(filter or nil)}
- if(evt[1] == "char") then
- for k,v in pairs(map) do
- if(k[2] == evt[2]) then
- e = v(evt)
- return unpack(e)
- end
- end
- end
- return unpack(evt)
- end
- ------------------------------------------
- ]]
- local function split(str)
- local t = {}
- for m in str:gmatch(".") do table.insert(t,m) end
- return t
- end
- local data = {}
- local layout = {}
- local priority = "gfhdjskalrueiwoqpvbcnxmy"
- priority = priority..priority:upper()
- priority = priority.."1234567890"
- local handle,content = fs.open(args[1],"r"),false
- content = handle.readAll()
- handle.close()
- data = textutils.unserialize(content)
- local datakeys = {}
- for k,v in pairs(data) do
- table.insert(datakeys,k)
- end
- table.sort(datakeys,function(i,j) return i>j end)
- local processed = {}
- for _,i in pairs(datakeys) do
- if(#priority==0) then break end
- for k,v in pairs(data[i]) do
- if(#priority==0) then break end
- local c = priority:sub(1,1)
- priority = priority:sub(2)
- processed[c] = v
- end
- end
- local map = {}
- for k,v in pairs(processed) do
- local val = v
- if(v == "\"") then val = "\\\"" end
- if(v == "\n") then val = "\\n" end
- fileHeader = fileHeader.."addRemap({'char',\""..k.."\"},function(evt) return {'char',\""..val.."\"} end)".."\n"
- end
- local handle = fs.open("mapped","w")
- handle.write(fileHeader)
- handle.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement