Skip to content

Commit

Permalink
Lua 5.3+ fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed May 30, 2023
1 parent 1c163dd commit c71c147
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ dependencies {
compile 'com.google.code.findbugs:jsr305:1.3.9' // Annotations used by google libs.

embedded name: 'OC-LuaJ', version: '20220907.1', ext: 'jar'
embedded name: 'OC-JNLua', version: '20220928.1', ext: 'jar'
embedded name: 'OC-JNLua', version: '20230530.0', ext: 'jar'
embedded name: 'OC-JNLua-Natives', version: '20220928.1', ext: 'jar'

testCompile "org.mockito:mockito-all:1.10.19"
Expand Down
6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## New Features/Support
## Fixes/improvements

* Reverted Internet Card code to OC 1.7.7, fixing the many related regressions.
* Fixed "number expected, got number" being displayed instead of "number has no integer representation" on Lua 5.3+.
* Fixed math.randomseed() not working with non-integer values.

## OpenOS fixes/improvements

Expand Down
17 changes: 10 additions & 7 deletions src/main/resources/assets/opencomputers/lua/machine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -893,17 +893,19 @@ sandbox = {
acos = math.acos,
asin = math.asin,
atan = math.atan,
atan2 = math.atan2,
atan2 = math.atan2 or math.atan, -- Deprecated in Lua 5.3
ceil = math.ceil,
cos = math.cos,
cosh = math.cosh,
cosh = math.cosh, -- Deprecated in Lua 5.3
deg = math.deg,
exp = math.exp,
floor = math.floor,
fmod = math.fmod,
frexp = math.frexp,
frexp = math.frexp, -- Deprecated in Lua 5.3
huge = math.huge,
ldexp = math.ldexp,
ldexp = math.ldexp or function(a, e) -- Deprecated in Lua 5.3
return a*(2.0^e)
end,
log = math.log,
max = math.max,
min = math.min,
Expand All @@ -917,13 +919,14 @@ sandbox = {
return spcall(math.random, ...)
end,
randomseed = function(seed)
spcall(math.randomseed, seed)
-- math.floor(seed) emulates pre-OC 1.8.0 behaviour
spcall(math.randomseed, math.floor(seed))
end,
sin = math.sin,
sinh = math.sinh,
sinh = math.sinh, -- Deprecated in Lua 5.3
sqrt = math.sqrt,
tan = math.tan,
tanh = math.tanh,
tanh = math.tanh, -- Deprecated in Lua 5.3
-- Lua 5.3.
maxinteger = math.maxinteger,
mininteger = math.mininteger,
Expand Down

0 comments on commit c71c147

Please sign in to comment.