foreign keyboards
This commit is contained in:
@@ -5,7 +5,7 @@ LUA MODULE
|
||||
compress.deflatelua - deflate (and gunzip/zlib) implemented in Lua.
|
||||
|
||||
SYNOPSIS
|
||||
|
||||
|
||||
local DEFLATE = require 'compress.deflatelua'
|
||||
-- uncompress gzip file
|
||||
local fh = assert(io.open'foo.txt.gz', 'rb')
|
||||
@@ -13,12 +13,12 @@ SYNOPSIS
|
||||
DEFLATE.gunzip {input=fh, output=ofh}
|
||||
fh:close(); ofh:close()
|
||||
-- can also uncompress from string including zlib and raw DEFLATE formats.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
|
||||
This is a pure Lua implementation of decompressing the DEFLATE format,
|
||||
including the related zlib and gzip formats.
|
||||
|
||||
|
||||
Note: This library only supports decompression.
|
||||
Compression is not currently implemented.
|
||||
|
||||
@@ -34,9 +34,9 @@ API
|
||||
Decompresses input stream `fh` in the DEFLATE format
|
||||
while writing to output stream `ofh`.
|
||||
DEFLATE is detailed in http://tools.ietf.org/html/rfc1951 .
|
||||
|
||||
|
||||
DEFLATE.gunzip {input=fh, output=ofh, disable_crc=disable_crc}
|
||||
|
||||
|
||||
Decompresses input stream `fh` with the gzip format
|
||||
while writing to output stream `ofh`.
|
||||
`disable_crc` (defaults to `false`) will disable CRC-32 checking
|
||||
@@ -44,15 +44,15 @@ API
|
||||
gzip is detailed in http://tools.ietf.org/html/rfc1952 .
|
||||
|
||||
DEFLATE.inflate_zlib {input=fh, output=ofh, disable_crc=disable_crc}
|
||||
|
||||
|
||||
Decompresses input stream `fh` with the zlib format
|
||||
while writing to output stream `ofh`.
|
||||
`disable_crc` (defaults to `false`) will disable CRC-32 checking
|
||||
to increase speed.
|
||||
zlib is detailed in http://tools.ietf.org/html/rfc1950 .
|
||||
zlib is detailed in http://tools.ietf.org/html/rfc1950 .
|
||||
|
||||
DEFLATE.adler32(byte, crc) --> rcrc
|
||||
|
||||
|
||||
Returns adler32 checksum of byte `byte` (number 0..255) appended
|
||||
to string with adler32 checksum `crc`. This is internally used by
|
||||
`inflate_zlib`.
|
||||
@@ -63,9 +63,9 @@ COMMAND LINE UTILITY
|
||||
A `gunziplua` command line utility (in folder `bin`) is also provided.
|
||||
This mimicks the *nix `gunzip` utility but is a pure Lua implementation
|
||||
that invokes this library. For help do
|
||||
|
||||
|
||||
gunziplua -h
|
||||
|
||||
|
||||
DEPENDENCIES
|
||||
|
||||
Requires 'digest.crc32lua' (used for optional CRC-32 checksum checks).
|
||||
@@ -75,13 +75,13 @@ DEPENDENCIES
|
||||
is not that critical for this library but is required by digest.crc32lua.
|
||||
|
||||
'pythonic.optparse' is only required by the optional `gunziplua`
|
||||
command-line utilty for command line parsing.
|
||||
command-line utilty for command line parsing.
|
||||
https://github.com/davidm/lua-pythonic-optparse
|
||||
|
||||
INSTALLATION
|
||||
|
||||
Copy the `compress` directory into your LUA_PATH.
|
||||
|
||||
|
||||
REFERENCES
|
||||
|
||||
[1] DEFLATE Compressed Data Format Specification version 1.3
|
||||
@@ -811,7 +811,7 @@ function M.gunzip(t)
|
||||
if not disable_crc and data_crc32 then
|
||||
if data_crc32 ~= expected_crc32 then
|
||||
runtime_error('invalid compressed data--crc error')
|
||||
end
|
||||
end
|
||||
end
|
||||
if bs:read() then
|
||||
warn 'trailing garbage ignored'
|
||||
@@ -833,11 +833,11 @@ function M.inflate_zlib(t)
|
||||
local outbs = get_obytestream(t.output)
|
||||
local disable_crc = t.disable_crc
|
||||
if disable_crc == nil then disable_crc = false end
|
||||
|
||||
|
||||
local window_size_ = parse_zlib_header(bs)
|
||||
|
||||
|
||||
local data_adler32 = 1
|
||||
|
||||
|
||||
inflate{input=bs, output=
|
||||
disable_crc and outbs or
|
||||
function(byte)
|
||||
@@ -847,7 +847,7 @@ function M.inflate_zlib(t)
|
||||
}
|
||||
|
||||
bs:read(bs:nbits_left_in_byte())
|
||||
|
||||
|
||||
local b3 = bs:read(8)
|
||||
local b2 = bs:read(8)
|
||||
local b1 = bs:read(8)
|
||||
@@ -859,7 +859,7 @@ function M.inflate_zlib(t)
|
||||
if not disable_crc then
|
||||
if data_adler32 ~= expected_adler32 then
|
||||
runtime_error('invalid compressed data--crc error')
|
||||
end
|
||||
end
|
||||
end
|
||||
if bs:read() then
|
||||
warn 'trailing garbage ignored'
|
||||
|
||||
@@ -1172,9 +1172,8 @@ function input:translate(event, code, p1, p2)
|
||||
end
|
||||
|
||||
elseif event == 'char' then
|
||||
if not self.pressed[keys.leftAlt] and
|
||||
not self.pressed[keys.rightAlt] then
|
||||
self.fired = true
|
||||
if not self.fired then
|
||||
self.fired = true
|
||||
return code -- input:toCode(code)
|
||||
end
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ local GPS = require('gps')
|
||||
local itemDB = require('core.itemDB')
|
||||
local Point = require('point')
|
||||
local Socket = require('socket')
|
||||
local Sound = require('sound')
|
||||
local Util = require('util')
|
||||
local UI = require('ui')
|
||||
|
||||
@@ -21,11 +22,37 @@ local scanner = device['plethora:scanner'] or
|
||||
-- hud
|
||||
local canvas = glasses and glasses.canvas()
|
||||
if canvas then
|
||||
local lh
|
||||
|
||||
local function addText(x, y, text, color)
|
||||
local th = canvas.group.addText({ x, y }, text, color or 0xa0a0a0FF)
|
||||
lh = lh or th.getLineHeight()
|
||||
th.setShadow(true)
|
||||
th.setScale(.75)
|
||||
return th
|
||||
end
|
||||
|
||||
canvas.group = canvas.addGroup({ 4, 90 })
|
||||
canvas.bg = canvas.group.addRectangle(0, 0, 60, 24, 0x00000033)
|
||||
canvas.text = canvas.group.addText({ 4, 5 }, '') -- , 0x202020FF)
|
||||
canvas.text.setShadow(true)
|
||||
canvas.text.setScale(.75)
|
||||
canvas.group.bg = canvas.group.addRectangle(0, 0, 80, 10, 0x40404080)
|
||||
canvas.group.addLines(
|
||||
{ 0, 0 },
|
||||
{ 80, 0 },
|
||||
{ 80, 10 },
|
||||
{ 0, 10 },
|
||||
{ 0, 0 },
|
||||
0x202020FF,
|
||||
2)
|
||||
addText(20, 2, 'Swarm Miner', 0xc0c0c0FF)
|
||||
|
||||
local y = 15
|
||||
addText(3, y, 'Turtles')
|
||||
canvas.turtles = addText(60, y, '')
|
||||
canvas.group.addLine({ 0, y + lh - 2 }, { 80, y + lh - 2 }, 0x404040FF, 4)
|
||||
|
||||
y = y + lh + 5
|
||||
addText(3, y, 'Queue')
|
||||
canvas.queue = addText(60, y, '')
|
||||
canvas.group.addLine({ 0, y + lh - 2 }, { 80, y + lh - 2 }, 0x404040FF, 4)
|
||||
end
|
||||
|
||||
-- container
|
||||
@@ -512,9 +539,14 @@ function page:eventHandler(event)
|
||||
UI.Page.eventHandler(self, event)
|
||||
end
|
||||
|
||||
Event.onInterval(3, function()
|
||||
Event.onInterval(1, function()
|
||||
if not abort and not paused then
|
||||
page:scan()
|
||||
|
||||
local meta = scanner.getMetaOwner()
|
||||
if meta.isSneaking then
|
||||
page:scan()
|
||||
Sound.play('entity.bobber.throw', .6)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -541,9 +573,8 @@ Event.onInterval(1, function()
|
||||
page.info:sync()
|
||||
|
||||
if canvas then
|
||||
local text = string.format('Turtles: %s\nQueue: %s',
|
||||
Util.size(turtles), Util.size(queue))
|
||||
canvas.text.setText(text)
|
||||
canvas.turtles.setText(tostring(Util.size(turtles)))
|
||||
canvas.queue.setText(tostring(Util.size(queue)))
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
77
ignore/mobPickup.lua
Normal file
77
ignore/mobPickup.lua
Normal file
@@ -0,0 +1,77 @@
|
||||
local Point = require('point')
|
||||
local Util = require('util')
|
||||
|
||||
local device = _G.device
|
||||
local os = _G.os
|
||||
|
||||
local scanner = device['plethora:scanner']
|
||||
local sensor = device['plethora:sensor']
|
||||
|
||||
local id = sensor.getID()
|
||||
|
||||
local function dropOff()
|
||||
local blocks = scanner.scan()
|
||||
local b = Util.find(blocks, 'name', 'minecraft:hopper')
|
||||
print(not not b)
|
||||
if b then
|
||||
print('walking ', b.x, b.y + 1, b.z)
|
||||
os.sleep(1)
|
||||
sensor.walk(b.x, b.y + 1, b.z)
|
||||
os.sleep(2)
|
||||
repeat until not sensor.isWalking()
|
||||
print('done walking')
|
||||
|
||||
blocks = scanner.scan()
|
||||
b = Util.find(blocks, 'name', 'minecraft:hopper')
|
||||
if b then
|
||||
print(b.x, b.z)
|
||||
end
|
||||
if b and math.abs(b.x) < 1 and math.abs(b.z) < 1 then
|
||||
print('dropped')
|
||||
sensor.getEquipment().drop(1)
|
||||
os.sleep(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
while true do
|
||||
local sensed = Util.reduce(sensor.sense(), function(acc, s)
|
||||
s.y = Util.round(s.y)
|
||||
|
||||
if s.y == 0 and s.id ~= id then
|
||||
--s.x = Util.round(s.x)
|
||||
--s.z = Util.round(s.z)
|
||||
acc[s.id] = s
|
||||
end
|
||||
return acc
|
||||
end, { })
|
||||
|
||||
local pt = { x = 0, y = 0, z = 0 }
|
||||
while true do
|
||||
local b = Point.closest(pt, sensed)
|
||||
if not b then
|
||||
break
|
||||
end
|
||||
sensed[b.id] = nil
|
||||
b = sensor.getMetaByID(b.id)
|
||||
if b then
|
||||
print('picking up ', b.x, b.y, b.z)
|
||||
sensor.walk(b.x, b.y, b.z)
|
||||
os.sleep(2)
|
||||
repeat until not sensor.isWalking()
|
||||
print('done goto')
|
||||
os.sleep(.5)
|
||||
pt = b
|
||||
local amount = sensor.getEquipment().suck(1)
|
||||
print('sucked: ' .. amount)
|
||||
if amount == 0 then
|
||||
print('dropping')
|
||||
dropOff()
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
os.sleep(5)
|
||||
end
|
||||
|
||||
@@ -11,10 +11,11 @@ local parallel = _G.parallel
|
||||
local STARTUP_FILE = 'usr/autorun/fly.lua'
|
||||
|
||||
if not modules.launch or not modules.getMetaOwner then
|
||||
error([[Required:
|
||||
print([[Required:
|
||||
* Kinetic augment
|
||||
* Entity sensor
|
||||
* Introspection module]])
|
||||
error('missing required item')
|
||||
end
|
||||
|
||||
if not fs.exists(STARTUP_FILE) then
|
||||
|
||||
@@ -41,17 +41,17 @@ local function getPoint()
|
||||
end
|
||||
|
||||
local targets = {
|
||||
["minecraft:emerald_ore"] = 0x46FF26AA,
|
||||
["minecraft:diamond_ore"] = 0x50F8FFAA,
|
||||
["minecraft:gold_ore"] = 0xFFDF50AA,
|
||||
["minecraft:redstone_ore"] = 0xCC121566,
|
||||
["minecraft:lit_redstone_ore"] = 0xCC121566,
|
||||
["minecraft:iron_ore"] = 0xFFAC8766,
|
||||
["minecraft:lapis_ore"] = 0x0A107F66,
|
||||
["minecraft:coal_ore"] = 0x20202066,
|
||||
["quark:biotite_ore"] = 0x02051C66,
|
||||
["minecraft:quartz_ore"] = 0xCCCCCC66,
|
||||
["minecraft:glowstone"] = 0xFFDFA166
|
||||
["minecraft:emerald_ore"] = { "minecraft:emerald", 0 },
|
||||
["minecraft:diamond_ore"] = { "minecraft:diamond", 0 },
|
||||
["minecraft:gold_ore"] = { "minecraft:gold_ingot", 0 },
|
||||
["minecraft:redstone_ore"] = { "minecraft:redstone", 0 },
|
||||
["minecraft:lit_redstone_ore"] = { "minecraft:redstone", 0 },
|
||||
["minecraft:iron_ore"] = { "minecraft:iron_ingot", 0 },
|
||||
["minecraft:lapis_ore"] = { "minecraft:dye", 4 },
|
||||
["minecraft:coal_ore"] = { "minecraft:coal", 0 },
|
||||
--["quark:biotite_ore"] = 0x02051C66,
|
||||
["minecraft:quartz_ore"] = { "minecraft:quartz", 0 },
|
||||
["minecraft:glowstone"] = { "minecraft:glowstone_dust", 0 },
|
||||
}
|
||||
local projecting = { }
|
||||
local offset = getPoint() or showRequirements('GPS')
|
||||
@@ -90,21 +90,21 @@ local function update()
|
||||
for _, b in pairs(blocks) do
|
||||
if not projecting[b.id] then
|
||||
projecting[b.id] = b
|
||||
--[[
|
||||
b.box = canvas.addFrame({
|
||||
pos.x - offset.x + b.x + -(pos.x % 1) + .5,
|
||||
pos.y - offset.y + b.y + -(pos.y % 1) + .5,
|
||||
pos.z - offset.z + b.z + -(pos.z % 1) + .5,
|
||||
pos.x - offset.x + b.x + -(pos.x % 1),
|
||||
pos.y - offset.y + b.y + -(pos.y % 1),
|
||||
pos.z - offset.z + b.z + -(pos.z % 1),
|
||||
})
|
||||
b.box.setDepthTested(false)
|
||||
b.box.addItem({ 0, 0 }, b.name, b.damage, 2)
|
||||
--]]
|
||||
|
||||
local target = targets[b.name]
|
||||
b.box.addItem({ .25, .25 }, target[1], target[2], 2)
|
||||
--[[
|
||||
b.box = canvas.addItem({
|
||||
pos.x - offset.x + b.x + -(pos.x % 1) + .5,
|
||||
pos.y - offset.y + b.y + -(pos.y % 1) + .5,
|
||||
pos.z - offset.z + b.z + -(pos.z % 1) + .5,
|
||||
}, b.name, b.damage, .5)
|
||||
--]]
|
||||
b.box.setDepthTested(false)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user