mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
CCAPI update as "bit" is now an alias of "bit32"
Former-commit-id: 68c272908747e3ab451799b4cddd211fbee09489 Former-commit-id: aeaa3e995030501175d3692248a1a3cc2d9bfcfa
This commit is contained in:
@@ -26,19 +26,13 @@ local function intLog2(i)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-------------
|
-----------------------
|
||||||
-- BIT API --
|
-- BIT API Extension --
|
||||||
-------------
|
-----------------------
|
||||||
|
|
||||||
_G.bit = {} -- CC's weird BIT API
|
bit.blshift = bit32.lshift(n, bits)
|
||||||
|
bit.brshift = bit32.arshift(n, bits)
|
||||||
bit.blshift = function(n, bits) bit32.lshift(n, bits) end
|
bit.blogic_rshift = bit32.rshift(n, bits)
|
||||||
bit.brshift = function(n, bits) bit32.arshift(n, bits) end
|
|
||||||
bit.blogic_rshift = function(n, bits) bit32.rshift(n, bits) end
|
|
||||||
bit.bxor = function(m, n) bit32.bxor(m, n) end
|
|
||||||
bit.bor = function(m, n) bit32.bor(m, n) end
|
|
||||||
bit.band = function(m, n) bit32.band(m, n) end
|
|
||||||
bit.bnot = function(n) bit32.bnot(n) end
|
|
||||||
|
|
||||||
|
|
||||||
----------------
|
----------------
|
||||||
@@ -134,28 +128,28 @@ term.blit = function(text, foreCol, backCol)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
term.getCursorPos = function() return term.getCursor() end
|
term.getCursorPos = term.getCursor
|
||||||
term.setCursorPos = function(x, y) term.moveCursor(x, y) end
|
term.setCursorPos = term.moveCursor
|
||||||
term.setCursorBlink = function(b) term.blink(b) end
|
term.setCursorBlink = term.blink
|
||||||
term.isColor = function() return term.isCol() end
|
term.isColor = term.isCol
|
||||||
term.getSize = function() return term.size() end
|
term.getSize = term.size
|
||||||
term.setTextColor = function(cccol) term.setForeCol(ccToGameCol[normaliseCCcol(cccol)]) end
|
term.setTextColor = function(cccol) term.setForeCol(ccToGameCol[normaliseCCcol(cccol)]) end
|
||||||
term.getTextColor = function() return term.getForeCol() end
|
term.getTextColor = term.getForeCol
|
||||||
term.setBackgroundColor = function(cccol) term.setBackCol(ccToGameCol[normaliseCCcol(cccol)]) end
|
term.setBackgroundColor = function(cccol) term.setBackCol(ccToGameCol[normaliseCCcol(cccol)]) end
|
||||||
term.getBackgroundColor = function() return term.getBackCol() end
|
term.getBackgroundColor = term.getBackCol
|
||||||
|
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
-- FILESYSTEM API --
|
-- FILESYSTEM API --
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
fs.makeDir = function(p) fs.mkdir(p) end
|
fs.makeDir = fs.mkdir
|
||||||
fs.move = function(a, b) fs.mv(a, b) end
|
fs.move = fs.mv
|
||||||
fs.copy = function(a, b) fs.cp(a, b) end
|
fs.copy = fs.cp
|
||||||
fs.delete = function(p) fs.rm(p) end
|
fs.delete = fs.rm
|
||||||
fs.combine = function(a, b) return fs.concat(a, b) end
|
fs.combine = fs.concat
|
||||||
fs.getDir = function(p) return fs.parent(p) end
|
fs.getDir = fs.parent
|
||||||
fs.run = function(p) fs.dofile(p) end
|
fs.run = fs.dofile
|
||||||
|
|
||||||
|
|
||||||
------------------
|
------------------
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ class Input(globals: Globals, computer: BaseTerrarumComputer) {
|
|||||||
val keys_caps = intArrayOf(Key.CAPS_LOCK, Key.BACKSPACE, Key.L_CONTROL)
|
val keys_caps = intArrayOf(Key.CAPS_LOCK, Key.BACKSPACE, Key.L_CONTROL)
|
||||||
}
|
}
|
||||||
|
|
||||||
class IsKeyDown(val computer: BaseTerrarumComputer) : OneArgFunction() {
|
class IsKeyDown(val host: BaseTerrarumComputer) : OneArgFunction() {
|
||||||
override fun call(keyCode: LuaValue): LuaValue {
|
override fun call(keyCode: LuaValue): LuaValue {
|
||||||
val key = keyCode.checkint()
|
val key = keyCode.checkint()
|
||||||
|
|
||||||
// L_Alt and L_COMMAND are homogeneous
|
// L_Alt and L_COMMAND are homogeneous
|
||||||
if (keys_alt.contains(key)) {
|
if (keys_alt.contains(key)) {
|
||||||
for (k in keys_alt) {
|
for (k in keys_alt) {
|
||||||
val down = computer.input.isKeyDown(k)
|
val down = host.input.isKeyDown(k)
|
||||||
if (down) return LuaValue.valueOf(true)
|
if (down) return LuaValue.valueOf(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,12 +37,12 @@ class Input(globals: Globals, computer: BaseTerrarumComputer) {
|
|||||||
// Caps, Backspace, L_Control, for Colemak and HHKB
|
// Caps, Backspace, L_Control, for Colemak and HHKB
|
||||||
if (keys_caps.contains(key)) {
|
if (keys_caps.contains(key)) {
|
||||||
for (k in keys_caps) {
|
for (k in keys_caps) {
|
||||||
val down = computer.input.isKeyDown(k)
|
val down = host.input.isKeyDown(k)
|
||||||
if (down) return LuaValue.valueOf(true)
|
if (down) return LuaValue.valueOf(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return LuaValue.valueOf(computer.input.isKeyDown(keyCode.checkint()))
|
return LuaValue.valueOf(host.input.isKeyDown(keyCode.checkint()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user