Add Lua 5.3 support

This commit is contained in:
gamax92 2016-01-16 12:03:25 -07:00
parent 0173be5116
commit 4e870aec70
6 changed files with 26 additions and 11 deletions

View File

@ -4,7 +4,7 @@ OCEmu - OpenComputers Emulator
Installation
------------
Needs lua-5.2, luafilesystem, utf8, luaffi, and SDL2.
Needs lua-5.2, luafilesystem, luautf8, luaffi, and SDL2.
luasocket is optional but is required for the Internet Component and higher precision timing.
@ -38,7 +38,7 @@ Follow the luarocks steps below.
**Lua Libraries**
```
luarocks-5.2 install luafilesystem
luarocks-5.2 install utf8
luarocks-5.2 install luautf8
luarocks-5.2 install luasocket
luarocks-5.2 install luasec
luarocks-5.2 install --server=http://luarocks.org/dev luaffi

View File

@ -1,6 +1,6 @@
local env = ...
local utf8 = require("utf8")
local utf8 = require("lua-utf8")
local function cln(str)
return str:gsub("%z.*","") .. ""

View File

@ -3,7 +3,7 @@ compCheckArg(1,maxwidth,"number")
compCheckArg(2,maxheight,"number")
compCheckArg(3,maxtier,"number")
local lua_utf8 = require("utf8")
local utf8 = require("lua-utf8")
local bindaddress
local depthTbl = {1,4,8}
@ -102,7 +102,7 @@ function obj.fill(x, y, width, height, char) -- Fills a portion of the screen at
if bindaddress == nil then
return nil, "no screen"
end
if lua_utf8.len(char) ~= 1 then
if utf8.len(char) ~= 1 then
return nil, "invalid fill value"
end
return component.cecinvoke(bindaddress, "fill", x, y, width, height, char)

View File

@ -1,7 +1,7 @@
local address = ...
local ffi = require("ffi")
local lua_utf8 = require("utf8")
local utf8 = require("lua-utf8")
local SDL = elsa.SDL
-- Conversion table for SDL2 keys to LWJGL key codes
@ -18,7 +18,7 @@ function elsa.textinput(event)
local textevent = ffi.cast("SDL_TextInputEvent*", event)
local text = ffi.string(textevent.text)
cprint("textinput",text)
setLatest(lua_utf8.byte(text))
setLatest(utf8.byte(text))
end
function elsa.keydown(event)

View File

@ -4,7 +4,7 @@ compCheckArg(2,maxheight,"number")
compCheckArg(3,maxtier,"number")
local ffi = require("ffi")
local utf8 = require("utf8")
local utf8 = require("lua-utf8")
local bit = require("bit32")
local SDL = elsa.SDL

View File

@ -124,7 +124,6 @@ local env = {
upvalueid = debug.upvalueid,
upvaluejoin = debug.upvaluejoin,
},
dofile = dofile,
error = error,
getmetatable = getmetatable,
io = {
@ -145,7 +144,6 @@ local env = {
},
ipairs = ipairs,
load = load,
loadfile = loadfile,
math = {
abs = math.abs,
acos = math.acos,
@ -166,7 +164,7 @@ local env = {
max = math.max,
min = math.min,
modf = math.modf,
pi = 3.1415926535898,
pi = math.pi,
pow = math.pow,
rad = math.rad,
random = math.random,
@ -230,6 +228,23 @@ local env = {
type = type,
xpcall = xpcall,
}
if _VERSION == "Lua 5.3" then
env._VERSION = "Lua 5.3"
env.coroutine.isyieldable = coroutine.isyieldable
env.math.maxinteger = math.maxinteger
env.math.mininteger = math.mininteger
env.math.tointeger = math.tointeger
env.math.type = math.type
env.math.ult = math.ult
env.string.pack = string.pack
env.string.packsize = string.packsize
env.string.unpack = string.unpack
env.table.move = table.move
env.utf8 = {}
for k,v in pairs(utf8) do
env.utf8[k] = v
end
end
setmetatable(env,{
__index = function(_,k)
cprint("Missing environment access", "env." .. k)