mirror of https://github.com/kepler155c/opus
builder using command computer
This commit is contained in:
parent
3a5da45877
commit
2b1d96ab37
2
startup
2
startup
|
@ -30,7 +30,7 @@ term.setCursorPos(1, 1)
|
||||||
print('Starting OS')
|
print('Starting OS')
|
||||||
print()
|
print()
|
||||||
print('Press any key for menu')
|
print('Press any key for menu')
|
||||||
local timerId = os.startTimer(.75)
|
local timerId = os.startTimer(1.5)
|
||||||
while true do
|
while true do
|
||||||
local e, id = os.pullEvent()
|
local e, id = os.pullEvent()
|
||||||
if e == 'timer' and id == timerId then
|
if e == 'timer' and id == timerId then
|
||||||
|
|
|
@ -5,6 +5,7 @@ local JSON = require('json')
|
||||||
-- see https://github.com/Khroki/MCEdit-Unified/blob/master/pymclevel/minecraft.yaml
|
-- see https://github.com/Khroki/MCEdit-Unified/blob/master/pymclevel/minecraft.yaml
|
||||||
-- see https://github.com/Khroki/MCEdit-Unified/blob/master/Items/minecraft/blocks.json
|
-- see https://github.com/Khroki/MCEdit-Unified/blob/master/Items/minecraft/blocks.json
|
||||||
|
|
||||||
|
--[[-- nameDB --]]--
|
||||||
local nameDB = TableDB({
|
local nameDB = TableDB({
|
||||||
fileName = 'blocknames.db'
|
fileName = 'blocknames.db'
|
||||||
})
|
})
|
||||||
|
@ -35,31 +36,10 @@ function nameDB:lookupName(id, dmg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local blockDB = TableDB({
|
--[[-- blockDB --]]--
|
||||||
fileName = 'block.db',
|
local blockDB = TableDB()
|
||||||
tabledef = {
|
|
||||||
autokeys = false,
|
|
||||||
columns = {
|
|
||||||
{ name = 'key', type = 'key', length = 8 },
|
|
||||||
{ name = 'id', type = 'number', length = 5 },
|
|
||||||
{ name = 'dmg', type = 'number', length = 2 },
|
|
||||||
{ name = 'name', type = 'string', length = 35 },
|
|
||||||
{ name = 'refname', type = 'string', length = 35 },
|
|
||||||
{ name = 'strId', type = 'string', length = 80 },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function blockDB:load(dir)
|
function blockDB:load()
|
||||||
self.fileName = fs.combine(dir, self.fileName)
|
|
||||||
if fs.exists(self.fileName) then
|
|
||||||
TableDB.load(self)
|
|
||||||
else
|
|
||||||
self:seedDB(dir)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function blockDB:seedDB(dir)
|
|
||||||
|
|
||||||
local blocks = JSON.decodeFromFile(fs.combine('sys/etc', 'blocks.json'))
|
local blocks = JSON.decodeFromFile(fs.combine('sys/etc', 'blocks.json'))
|
||||||
|
|
||||||
|
@ -70,50 +50,40 @@ function blockDB:seedDB(dir)
|
||||||
for strId, block in pairs(blocks) do
|
for strId, block in pairs(blocks) do
|
||||||
strId = 'minecraft:' .. strId
|
strId = 'minecraft:' .. strId
|
||||||
if type(block.name) == 'string' then
|
if type(block.name) == 'string' then
|
||||||
self:add(block.id, 0, block.name, strId)
|
self:add(block.id, 0, block.name, strId, block.place)
|
||||||
else
|
else
|
||||||
for nid,name in pairs(block.name) do
|
for nid,name in pairs(block.name) do
|
||||||
self:add(block.id, nid - 1, name, strId)
|
self:add(block.id, nid - 1, name, strId, block.place)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.dirty = true
|
|
||||||
-- self:flush()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function blockDB:lookup(id, dmg)
|
|
||||||
|
|
||||||
|
function blockDB:lookup(id, dmg)
|
||||||
if not id then
|
if not id then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not id or not dmg then error('blockDB:lookup: nil passed', 2) end
|
|
||||||
local key = id .. ':' .. dmg
|
|
||||||
|
|
||||||
return self.data[key]
|
return self.data[id .. ':' .. dmg]
|
||||||
end
|
end
|
||||||
|
|
||||||
function blockDB:add(id, dmg, name, strId)
|
function blockDB:add(id, dmg, name, strId, place)
|
||||||
local key = id .. ':' .. dmg
|
local key = id .. ':' .. dmg
|
||||||
|
|
||||||
TableDB.add(self, key, {
|
TableDB.add(self, key, {
|
||||||
id = id,
|
id = id,
|
||||||
dmg = dmg,
|
dmg = dmg,
|
||||||
key = key,
|
|
||||||
name = name,
|
name = name,
|
||||||
strId = strId,
|
strId = strId,
|
||||||
|
place = place,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-- placementDB --]]--
|
--[[-- placementDB --]]--
|
||||||
-- in memory table that expands the standardBlock and blockType tables for each item/dmg/placement combination
|
-- in memory table that expands the standardBlock and blockType tables for each item/dmg/placement combination
|
||||||
local placementDB = TableDB({
|
local placementDB = TableDB()
|
||||||
fileName = 'placement.db'
|
|
||||||
})
|
|
||||||
|
|
||||||
function placementDB:load(dir, sbDB, btDB)
|
function placementDB:load(sbDB, btDB)
|
||||||
|
|
||||||
self.fileName = fs.combine(dir, self.fileName)
|
|
||||||
|
|
||||||
for k,blockType in pairs(sbDB.data) do
|
for k,blockType in pairs(sbDB.data) do
|
||||||
local bt = btDB.data[blockType]
|
local bt = btDB.data[blockType]
|
||||||
|
@ -123,12 +93,26 @@ function placementDB:load(dir, sbDB, btDB)
|
||||||
local id, dmg = string.match(k, '(%d+):*(%d+)')
|
local id, dmg = string.match(k, '(%d+):*(%d+)')
|
||||||
self:addSubsForBlockType(tonumber(id), tonumber(dmg), bt)
|
self:addSubsForBlockType(tonumber(id), tonumber(dmg), bt)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- testing
|
|
||||||
self.dirty = true
|
|
||||||
--self:flush()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function placementDB:load2(sbDB, btDB)
|
||||||
|
|
||||||
|
for k,v in pairs(sbDB.data) do
|
||||||
|
if v.place then
|
||||||
|
local bt = btDB.data[v.place]
|
||||||
|
if not bt then
|
||||||
|
error('missing block type: ' .. v.place)
|
||||||
|
end
|
||||||
|
local id, dmg = string.match(k, '(%d+):*(%d+)')
|
||||||
|
self:addSubsForBlockType(tonumber(id), tonumber(dmg), bt)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- special case for quartz pillars
|
||||||
|
self:addSubsForBlockType(155, 2, btDB.data['quartz-pillar'])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function placementDB:addSubsForBlockType(id, dmg, bt)
|
function placementDB:addSubsForBlockType(id, dmg, bt)
|
||||||
for _,sub in pairs(bt) do
|
for _,sub in pairs(bt) do
|
||||||
local odmg = sub.odmg
|
local odmg = sub.odmg
|
||||||
|
@ -153,215 +137,26 @@ function placementDB:addSubsForBlockType(id, dmg, bt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function placementDB:add(id, dmg, sid, sdmg, direction, extra)
|
function placementDB:add(id, dmg, sid, sdmg, direction, extra)
|
||||||
if not id or not dmg then error('placementDB:add: nil passed', 2) end
|
|
||||||
|
|
||||||
local key = id .. ':' .. dmg
|
|
||||||
|
|
||||||
if direction and #direction == 0 then
|
if direction and #direction == 0 then
|
||||||
direction = nil
|
direction = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
self.data[key] = {
|
local entry = {
|
||||||
id = id, -- numeric ID
|
oid = id, -- numeric ID
|
||||||
dmg = dmg, -- dmg with placement info
|
odmg = dmg, -- dmg with placement info
|
||||||
key = key,
|
id = sid, -- string ID
|
||||||
sid = sid, -- string ID
|
dmg = sdmg, -- dmg without placement info
|
||||||
sdmg = sdmg, -- dmg without placement info
|
|
||||||
direction = direction,
|
direction = direction,
|
||||||
extra = extra,
|
|
||||||
}
|
}
|
||||||
end
|
if extra then
|
||||||
|
Util.merge(entry, extra)
|
||||||
--[[-- StandardBlockDB --]]--
|
|
||||||
local standardBlockDB = TableDB({
|
|
||||||
fileName = 'standard.db',
|
|
||||||
tabledef = {
|
|
||||||
autokeys = false,
|
|
||||||
type = 'simple',
|
|
||||||
columns = {
|
|
||||||
{ label = 'Key', type = 'key', length = 8 },
|
|
||||||
{ label = 'Block Type', type = 'string', length = 20 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function standardBlockDB:load(dir)
|
|
||||||
self.fileName = fs.combine(dir, self.fileName)
|
|
||||||
|
|
||||||
if fs.exists(self.fileName) then
|
|
||||||
TableDB.load(self)
|
|
||||||
else
|
|
||||||
self:seedDB()
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
self.data[id .. ':' .. dmg] = entry
|
||||||
function standardBlockDB:seedDB()
|
|
||||||
self.data = {
|
|
||||||
[ '6:0' ] = 'sapling',
|
|
||||||
[ '6:1' ] = 'sapling',
|
|
||||||
[ '6:2' ] = 'sapling',
|
|
||||||
[ '6:3' ] = 'sapling',
|
|
||||||
[ '6:4' ] = 'sapling',
|
|
||||||
[ '6:5' ] = 'sapling',
|
|
||||||
[ '8:0' ] = 'truncate',
|
|
||||||
[ '9:0' ] = 'truncate',
|
|
||||||
[ '17:0' ] = 'wood',
|
|
||||||
[ '17:1' ] = 'wood',
|
|
||||||
[ '17:2' ] = 'wood',
|
|
||||||
[ '17:3' ] = 'wood',
|
|
||||||
[ '18:0' ] = 'leaves',
|
|
||||||
[ '18:1' ] = 'leaves',
|
|
||||||
[ '18:2' ] = 'leaves',
|
|
||||||
[ '18:3' ] = 'leaves',
|
|
||||||
[ '23:0' ] = 'dispenser',
|
|
||||||
[ '26:0' ] = 'bed',
|
|
||||||
[ '27:0' ] = 'adp-rail',
|
|
||||||
[ '28:0' ] = 'adp-rail',
|
|
||||||
[ '29:0' ] = 'piston',
|
|
||||||
[ '33:0' ] = 'piston',
|
|
||||||
[ '34:0' ] = 'air',
|
|
||||||
[ '36:0' ] = 'air',
|
|
||||||
[ '44:0' ] = 'slab',
|
|
||||||
[ '44:1' ] = 'slab',
|
|
||||||
[ '44:2' ] = 'slab',
|
|
||||||
[ '44:3' ] = 'slab',
|
|
||||||
[ '44:4' ] = 'slab',
|
|
||||||
[ '44:5' ] = 'slab',
|
|
||||||
[ '44:6' ] = 'slab',
|
|
||||||
[ '44:7' ] = 'slab',
|
|
||||||
[ '50:0' ] = 'torch',
|
|
||||||
[ '51:0' ] = 'flatten',
|
|
||||||
[ '53:0' ] = 'stairs',
|
|
||||||
[ '54:0' ] = 'chest-furnace',
|
|
||||||
[ '55:0' ] = 'flatten',
|
|
||||||
[ '59:0' ] = 'flatten',
|
|
||||||
[ '60:0' ] = 'flatten',
|
|
||||||
[ '61:0' ] = 'chest-furnace',
|
|
||||||
[ '62:0' ] = 'chest-furnace',
|
|
||||||
[ '63:0' ] = 'signpost',
|
|
||||||
[ '64:0' ] = 'door',
|
|
||||||
[ '65:0' ] = 'wallsign-ladder',
|
|
||||||
[ '66:0' ] = 'rail',
|
|
||||||
[ '67:0' ] = 'stairs',
|
|
||||||
[ '68:0' ] = 'wallsign-ladder',
|
|
||||||
[ '69:0' ] = 'lever',
|
|
||||||
[ '71:0' ] = 'door',
|
|
||||||
[ '75:0' ] = 'torch',
|
|
||||||
[ '76:0' ] = 'torch',
|
|
||||||
[ '77:0' ] = 'button',
|
|
||||||
[ '78:0' ] = 'flatten',
|
|
||||||
[ '81:0' ] = 'flatten',
|
|
||||||
[ '83:0' ] = 'flatten',
|
|
||||||
[ '84:0' ] = 'flatten', -- jukebox
|
|
||||||
[ '86:0' ] = 'pumpkin',
|
|
||||||
[ '90:0' ] = 'air',
|
|
||||||
[ '91:0' ] = 'pumpkin',
|
|
||||||
[ '92:0' ] = 'flatten', -- cake
|
|
||||||
[ '93:0' ] = 'repeater',
|
|
||||||
[ '94:0' ] = 'repeater',
|
|
||||||
[ '96:0' ] = 'trapdoor',
|
|
||||||
[ '99:0' ] = 'flatten',
|
|
||||||
[ '100:0' ] = 'flatten',
|
|
||||||
[ '106:0' ] = 'vine',
|
|
||||||
[ '107:0' ] = 'gate',
|
|
||||||
[ '108:0' ] = 'stairs',
|
|
||||||
[ '109:0' ] = 'stairs',
|
|
||||||
[ '114:0' ] = 'stairs',
|
|
||||||
[ '115:0' ] = 'flatten',
|
|
||||||
[ '117:0' ] = 'flatten',
|
|
||||||
[ '118:0' ] = 'cauldron',
|
|
||||||
[ '120:0' ] = 'flatten', -- end portal
|
|
||||||
[ '126:0' ] = 'slab',
|
|
||||||
[ '126:1' ] = 'slab',
|
|
||||||
[ '126:2' ] = 'slab',
|
|
||||||
[ '126:3' ] = 'slab',
|
|
||||||
[ '126:4' ] = 'slab',
|
|
||||||
[ '126:5' ] = 'slab',
|
|
||||||
[ '127:0' ] = 'cocoa',
|
|
||||||
[ '128:0' ] = 'stairs',
|
|
||||||
[ '130:0' ] = 'chest-furnace',
|
|
||||||
[ '131:0' ] = 'tripwire',
|
|
||||||
[ '132:0' ] = 'flatten',
|
|
||||||
[ '134:0' ] = 'stairs',
|
|
||||||
[ '135:0' ] = 'stairs',
|
|
||||||
[ '136:0' ] = 'stairs',
|
|
||||||
[ '140:0' ] = 'flatten',
|
|
||||||
[ '141:0' ] = 'flatten',
|
|
||||||
[ '142:0' ] = 'flatten',
|
|
||||||
[ '143:0' ] = 'button',
|
|
||||||
[ '144:0' ] = 'mobhead',
|
|
||||||
[ '145:0' ] = 'anvil',
|
|
||||||
[ '146:0' ] = 'chest-furnace',
|
|
||||||
[ '149:0' ] = 'comparator',
|
|
||||||
[ '151:0' ] = 'flatten',
|
|
||||||
[ '154:0' ] = 'hopper',
|
|
||||||
[ '155:2' ] = 'quartz-pillar',
|
|
||||||
[ '156:0' ] = 'stairs',
|
|
||||||
[ '157:0' ] = 'adp-rail',
|
|
||||||
[ '158:0' ] = 'dispenser',
|
|
||||||
[ '161:0' ] = 'leaves',
|
|
||||||
[ '161:1' ] = 'leaves',
|
|
||||||
[ '162:0' ] = 'wood',
|
|
||||||
[ '162:1' ] = 'wood',
|
|
||||||
[ '163:0' ] = 'stairs',
|
|
||||||
[ '164:0' ] = 'stairs',
|
|
||||||
[ '167:0' ] = 'trapdoor',
|
|
||||||
[ '170:0' ] = 'hay-bale', -- hay bale
|
|
||||||
[ '175:0' ] = 'largeplant',
|
|
||||||
[ '175:1' ] = 'largeplant',
|
|
||||||
[ '175:2' ] = 'largeplant', -- double tallgrass - an alternative would be to use grass as the bottom part, bonemeal as top part
|
|
||||||
[ '175:3' ] = 'largeplant',
|
|
||||||
[ '175:4' ] = 'largeplant',
|
|
||||||
[ '175:5' ] = 'largeplant',
|
|
||||||
[ '176:0' ] = 'signpost',
|
|
||||||
[ '177:0' ] = 'wallsign-ladder',
|
|
||||||
[ '178:0' ] = 'truncate',
|
|
||||||
[ '180:0' ] = 'stairs',
|
|
||||||
[ '182:0' ] = 'slab',
|
|
||||||
[ '183:0' ] = 'gate',
|
|
||||||
[ '184:0' ] = 'gate',
|
|
||||||
[ '185:0' ] = 'gate',
|
|
||||||
[ '186:0' ] = 'gate',
|
|
||||||
[ '187:0' ] = 'gate',
|
|
||||||
[ '193:0' ] = 'door',
|
|
||||||
[ '194:0' ] = 'door',
|
|
||||||
[ '195:0' ] = 'door',
|
|
||||||
[ '196:0' ] = 'door',
|
|
||||||
[ '197:0' ] = 'door',
|
|
||||||
[ '198:0' ] = 'end_rod', -- end rod
|
|
||||||
[ '205:0' ] = 'slab',
|
|
||||||
[ '210:0' ] = 'flatten',
|
|
||||||
[ '355:0' ] = 'bed',
|
|
||||||
[ '356:0' ] = 'repeater',
|
|
||||||
[ '404:0' ] = 'comparator',
|
|
||||||
}
|
|
||||||
self.dirty = true
|
|
||||||
-- self:flush()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[-- BlockTypeDB --]]--
|
--[[-- BlockTypeDB --]]--
|
||||||
local blockTypeDB = TableDB({
|
local blockTypeDB = TableDB()
|
||||||
fileName = 'blocktype.db',
|
|
||||||
tabledef = {
|
|
||||||
autokeys = true,
|
|
||||||
columns = {
|
|
||||||
{ name = 'odmg', type = 'number', length = 2 },
|
|
||||||
{ name = 'sid', type = 'number', length = 5 },
|
|
||||||
{ name = 'sdmg', type = 'number', length = 2 },
|
|
||||||
{ name = 'dir', type = 'string', length = 20 },
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function blockTypeDB:load(dir)
|
|
||||||
self.fileName = fs.combine(dir, self.fileName)
|
|
||||||
|
|
||||||
if fs.exists(self.fileName) then
|
|
||||||
TableDB.load(self)
|
|
||||||
else
|
|
||||||
self:seedDB()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function blockTypeDB:addTemp(blockType, subs)
|
function blockTypeDB:addTemp(blockType, subs)
|
||||||
local bt = self.data[blockType]
|
local bt = self.data[blockType]
|
||||||
|
@ -381,7 +176,7 @@ function blockTypeDB:addTemp(blockType, subs)
|
||||||
self.dirty = true
|
self.dirty = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function blockTypeDB:seedDB()
|
function blockTypeDB:load()
|
||||||
|
|
||||||
blockTypeDB:addTemp('stairs', {
|
blockTypeDB:addTemp('stairs', {
|
||||||
{ 0, nil, 0, 'east-up' },
|
{ 0, nil, 0, 'east-up' },
|
||||||
|
@ -718,48 +513,12 @@ function blockTypeDB:seedDB()
|
||||||
{ '+8', nil, nil },
|
{ '+8', nil, nil },
|
||||||
{ '+12', nil, nil },
|
{ '+12', nil, nil },
|
||||||
})
|
})
|
||||||
blockTypeDB:addTemp('air', {
|
|
||||||
{ 0, 'minecraft:air', 0 },
|
|
||||||
{ 1, 'minecraft:air', 0 },
|
|
||||||
{ 2, 'minecraft:air', 0 },
|
|
||||||
{ 3, 'minecraft:air', 0 },
|
|
||||||
{ 4, 'minecraft:air', 0 },
|
|
||||||
{ 5, 'minecraft:air', 0 },
|
|
||||||
{ 6, 'minecraft:air', 0 },
|
|
||||||
{ 7, 'minecraft:air', 0 },
|
|
||||||
{ 8, 'minecraft:air', 0 },
|
|
||||||
{ 9, 'minecraft:air', 0 },
|
|
||||||
{ 10, 'minecraft:air', 0 },
|
|
||||||
{ 11, 'minecraft:air', 0 },
|
|
||||||
{ 12, 'minecraft:air', 0 },
|
|
||||||
{ 13, 'minecraft:air', 0 },
|
|
||||||
{ 14, 'minecraft:air', 0 },
|
|
||||||
{ 15, 'minecraft:air', 0 },
|
|
||||||
})
|
|
||||||
blockTypeDB:addTemp('truncate', {
|
|
||||||
{ 0, nil, 0 },
|
|
||||||
{ 1, 'minecraft:air', 0 },
|
|
||||||
{ 2, 'minecraft:air', 0 },
|
|
||||||
{ 3, 'minecraft:air', 0 },
|
|
||||||
{ 4, 'minecraft:air', 0 },
|
|
||||||
{ 5, 'minecraft:air', 0 },
|
|
||||||
{ 6, 'minecraft:air', 0 },
|
|
||||||
{ 7, 'minecraft:air', 0 },
|
|
||||||
{ 8, 'minecraft:air', 0 },
|
|
||||||
{ 9, 'minecraft:air', 0 },
|
|
||||||
{ 10, 'minecraft:air', 0 },
|
|
||||||
{ 11, 'minecraft:air', 0 },
|
|
||||||
{ 12, 'minecraft:air', 0 },
|
|
||||||
{ 13, 'minecraft:air', 0 },
|
|
||||||
{ 14, 'minecraft:air', 0 },
|
|
||||||
{ 15, 'minecraft:air', 0 },
|
|
||||||
})
|
|
||||||
blockTypeDB:addTemp('slab', {
|
blockTypeDB:addTemp('slab', {
|
||||||
{ '+0', nil, nil, 'bottom' },
|
{ '+0', nil, nil, 'bottom' },
|
||||||
{ '+8', nil, nil, 'top' },
|
{ '+8', nil, nil, 'top' },
|
||||||
})
|
})
|
||||||
blockTypeDB:addTemp('largeplant', {
|
blockTypeDB:addTemp('largeplant', {
|
||||||
{ '+0', nil, nil, 'east-door' }, -- should use a generic double tall keyword
|
{ '+0', nil, nil, 'east-door', { twoHigh = true } }, -- should use a generic double tall keyword
|
||||||
{ '+8', 'minecraft:air', 0 },
|
{ '+8', 'minecraft:air', 0 },
|
||||||
})
|
})
|
||||||
blockTypeDB:addTemp('wood', {
|
blockTypeDB:addTemp('wood', {
|
||||||
|
@ -769,14 +528,14 @@ function blockTypeDB:seedDB()
|
||||||
{ '+12', nil, nil },
|
{ '+12', nil, nil },
|
||||||
})
|
})
|
||||||
blockTypeDB:addTemp('door', {
|
blockTypeDB:addTemp('door', {
|
||||||
{ 0, nil, 0, 'east-door' },
|
{ 0, nil, 0, 'east-door', { twoHigh = true } },
|
||||||
{ 1, nil, 0, 'south-door' },
|
{ 1, nil, 0, 'south-door', { twoHigh = true } },
|
||||||
{ 2, nil, 0, 'west-door' },
|
{ 2, nil, 0, 'west-door', { twoHigh = true } },
|
||||||
{ 3, nil, 0, 'north-door' },
|
{ 3, nil, 0, 'north-door', { twoHigh = true } },
|
||||||
{ 4, nil, 0, 'east-door' },
|
{ 4, nil, 0, 'east-door', { twoHigh = true } },
|
||||||
{ 5, nil, 0, 'south-door' },
|
{ 5, nil, 0, 'south-door', { twoHigh = true } },
|
||||||
{ 6, nil, 0, 'west-door' },
|
{ 6, nil, 0, 'west-door', { twoHigh = true } },
|
||||||
{ 7, nil, 0, 'north-door' },
|
{ 7, nil, 0, 'north-door', { twoHigh = true } },
|
||||||
{ 8,'minecraft:air', 0 },
|
{ 8,'minecraft:air', 0 },
|
||||||
{ 9,'minecraft:air', 0 },
|
{ 9,'minecraft:air', 0 },
|
||||||
{ 10,'minecraft:air', 0 },
|
{ 10,'minecraft:air', 0 },
|
||||||
|
@ -800,8 +559,6 @@ function blockTypeDB:seedDB()
|
||||||
{ 10, nil, 0, 'north-block' },
|
{ 10, nil, 0, 'north-block' },
|
||||||
{ 11, nil, 0, 'east-block' },
|
{ 11, nil, 0, 'east-block' },
|
||||||
})
|
})
|
||||||
self.dirty = true
|
|
||||||
-- self:flush()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local Blocks = class()
|
local Blocks = class()
|
||||||
|
@ -811,11 +568,23 @@ function Blocks:init(args)
|
||||||
self.blockDB = blockDB
|
self.blockDB = blockDB
|
||||||
self.nameDB = nameDB
|
self.nameDB = nameDB
|
||||||
|
|
||||||
blockDB:load(self.dir)
|
blockDB:load()
|
||||||
standardBlockDB:load(self.dir)
|
-- standardBlockDB:load()
|
||||||
blockTypeDB:load(self.dir)
|
blockTypeDB:load()
|
||||||
nameDB:load(self.dir, blockDB)
|
nameDB:load(self.dir, blockDB)
|
||||||
placementDB:load(self.dir, standardBlockDB, blockTypeDB)
|
-- placementDB:load(standardBlockDB, blockTypeDB)
|
||||||
|
placementDB:load2(blockDB, blockTypeDB)
|
||||||
|
|
||||||
|
-- _G._b = blockDB
|
||||||
|
-- _G._s = standardBlockDB
|
||||||
|
-- _G._bt = blockTypeDB
|
||||||
|
-- _G._p = placementDB
|
||||||
|
|
||||||
|
-- Util.writeTable('pb1.lua', placementDB.data)
|
||||||
|
|
||||||
|
-- placementDB.data = { }
|
||||||
|
|
||||||
|
-- Util.writeTable('pb2.lua', placementDB.data)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- for an ID / dmg (with placement info) - return the correct block (without the placment info embedded in the dmg)
|
-- for an ID / dmg (with placement info) - return the correct block (without the placment info embedded in the dmg)
|
||||||
|
@ -823,15 +592,9 @@ function Blocks:getPlaceableBlock(id, dmg)
|
||||||
|
|
||||||
local p = placementDB:get({id, dmg})
|
local p = placementDB:get({id, dmg})
|
||||||
if p then
|
if p then
|
||||||
return {
|
return Util.shallowCopy(p)
|
||||||
id = p.sid,
|
|
||||||
dmg = p.sdmg,
|
|
||||||
direction = p.direction,
|
|
||||||
extra = p.extra,
|
|
||||||
odmg = dmg
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local b = blockDB:get({id, dmg})
|
local b = blockDB:get({id, dmg})
|
||||||
if b then
|
if b then
|
||||||
return { id = b.strId, dmg = b.dmg }
|
return { id = b.strId, dmg = b.dmg }
|
||||||
|
@ -841,7 +604,7 @@ function Blocks:getPlaceableBlock(id, dmg)
|
||||||
if b then
|
if b then
|
||||||
return { id = b.strId, dmg = b.dmg }
|
return { id = b.strId, dmg = b.dmg }
|
||||||
end
|
end
|
||||||
|
|
||||||
return { id = id, dmg = dmg }
|
return { id = id, dmg = dmg }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -715,7 +715,6 @@ function Schematic:determineBlockPlacement(y)
|
||||||
|
|
||||||
local hi = turtle.getHeadingInfo(doorDirections[d])
|
local hi = turtle.getHeadingInfo(doorDirections[d])
|
||||||
b.heading = hi.heading
|
b.heading = hi.heading
|
||||||
b.twoHigh = true
|
|
||||||
|
|
||||||
self:addPlacementChain(chains, {
|
self:addPlacementChain(chains, {
|
||||||
{ x = b.x, z = b.z, y = b.y },
|
{ x = b.x, z = b.z, y = b.y },
|
||||||
|
|
|
@ -8,7 +8,7 @@ function TableDB:init(args)
|
||||||
data = { },
|
data = { },
|
||||||
tabledef = { },
|
tabledef = { },
|
||||||
}
|
}
|
||||||
Util.merge(defaults, args) -- refactor
|
Util.merge(defaults, args)
|
||||||
Util.merge(self, defaults)
|
Util.merge(self, defaults)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ end
|
||||||
function TableDB:flush()
|
function TableDB:flush()
|
||||||
if self.dirty then
|
if self.dirty then
|
||||||
Util.writeTable(self.fileName, {
|
Util.writeTable(self.fileName, {
|
||||||
tabledef = self.tabledef,
|
-- tabledef = self.tabledef,
|
||||||
data = self.data,
|
data = self.data,
|
||||||
})
|
})
|
||||||
self.dirty = false
|
self.dirty = false
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
if not turtle and not commands then
|
if not turtle and not commands then
|
||||||
error('Must be run on a turtle')
|
error('Must be run on a turtle or a command computer')
|
||||||
end
|
end
|
||||||
|
|
||||||
require = requireInjector(getfenv(1))
|
require = requireInjector(getfenv(1))
|
||||||
local class = require('class')
|
local class = require('class')
|
||||||
local Event = require('event')
|
local Event = require('event')
|
||||||
local Message = require('message')
|
local Message = require('message')
|
||||||
local UI = require('ui')
|
local UI = require('ui')
|
||||||
local Schematic = require('schematic')
|
local Schematic = require('schematic')
|
||||||
local TableDB = require('tableDB')
|
local TableDB = require('tableDB')
|
||||||
local MEProvider = require('meProvider')
|
local MEProvider = require('meProvider')
|
||||||
local Blocks = require('blocks')
|
local Blocks = require('blocks')
|
||||||
local Point = require('point')
|
local Point = require('point')
|
||||||
|
|
||||||
local ChestProvider = require('chestProvider')
|
local ChestProvider = require('chestProvider')
|
||||||
if os.getVersion() == 1.8 then
|
if os.getVersion() == 1.8 then
|
||||||
|
@ -65,6 +65,8 @@ function subDB:seedDB()
|
||||||
[ "minecraft:unpowered_comparator:0" ] = "minecraft:comparator:0",
|
[ "minecraft:unpowered_comparator:0" ] = "minecraft:comparator:0",
|
||||||
[ "minecraft:powered_comparator:0" ] = "minecraft:comparator:0",
|
[ "minecraft:powered_comparator:0" ] = "minecraft:comparator:0",
|
||||||
[ "minecraft:piston_head:0" ] = "minecraft:air:0",
|
[ "minecraft:piston_head:0" ] = "minecraft:air:0",
|
||||||
|
[ "minecraft:piston_extension:0" ] = "minecraft:air:0",
|
||||||
|
[ "minecraft:minecraft:portal:0" ] = "minecraft:air:0",
|
||||||
[ "minecraft:double_wooden_slab:0" ] = "minecraft:planks:0",
|
[ "minecraft:double_wooden_slab:0" ] = "minecraft:planks:0",
|
||||||
[ "minecraft:double_wooden_slab:1" ] = "minecraft:planks:1",
|
[ "minecraft:double_wooden_slab:1" ] = "minecraft:planks:1",
|
||||||
[ "minecraft:double_wooden_slab:2" ] = "minecraft:planks:2",
|
[ "minecraft:double_wooden_slab:2" ] = "minecraft:planks:2",
|
||||||
|
@ -369,10 +371,8 @@ function Builder:substituteBlocks(throttle)
|
||||||
-- replace schematic block type with substitution
|
-- replace schematic block type with substitution
|
||||||
local pb = blocks:getPlaceableBlock(b.id, b.dmg)
|
local pb = blocks:getPlaceableBlock(b.id, b.dmg)
|
||||||
|
|
||||||
b.id = pb.id
|
Util.merge(b, pb)
|
||||||
b.dmg = pb.dmg
|
|
||||||
b.direction = pb.direction
|
|
||||||
b.extra = pb.extra
|
|
||||||
b.odmg = pb.odmg or pb.dmg
|
b.odmg = pb.odmg or pb.dmg
|
||||||
|
|
||||||
local sub = subDB:get({ b.id, b.dmg })
|
local sub = subDB:get({ b.id, b.dmg })
|
||||||
|
@ -1069,8 +1069,8 @@ function Builder:placeDirectionalBlock(b, slot, travelPlane)
|
||||||
b.placed = self:place(slot)
|
b.placed = self:place(slot)
|
||||||
end
|
end
|
||||||
|
|
||||||
if b.extra and b.extra.facing then
|
if b.facing then
|
||||||
self:rotateBlock('down', b.extra.facing)
|
self:rotateBlock('down', b.facing)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- debug
|
-- debug
|
||||||
|
@ -1163,7 +1163,7 @@ function Builder:build()
|
||||||
direction = -1
|
direction = -1
|
||||||
last = 1
|
last = 1
|
||||||
turtle.status = 'destroying'
|
turtle.status = 'destroying'
|
||||||
elseif self.isCommandComputer then
|
elseif not self.isCommandComputer then
|
||||||
travelPlane = self:findTravelPlane(self.index)
|
travelPlane = self:findTravelPlane(self.index)
|
||||||
turtle.status = 'building'
|
turtle.status = 'building'
|
||||||
if not self.confirmFacing then
|
if not self.confirmFacing then
|
||||||
|
@ -1220,7 +1220,9 @@ function Builder:build()
|
||||||
|
|
||||||
if b.twoHigh then
|
if b.twoHigh then
|
||||||
local _, topBlock = schematic:findIndexAt(b.x, b.z, b.y + 1, true)
|
local _, topBlock = schematic:findIndexAt(b.x, b.z, b.y + 1, true)
|
||||||
placeBlock(id, topBlock.odmg, b.x, b.y + 1, b.z)
|
if topBlock then
|
||||||
|
placeBlock(id, topBlock.odmg, b.x, b.y + 1, b.z)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif self.mode == 'destroy' then
|
elseif self.mode == 'destroy' then
|
||||||
|
@ -1287,7 +1289,7 @@ function Builder:build()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if self.mode == 'destroy' then
|
if self.mode == 'destroy' then
|
||||||
self:saveProgress(math.max(self.index - 1, 1))
|
self:saveProgress(math.max(self.index, 1))
|
||||||
else
|
else
|
||||||
self:saveProgress(self.index + 1)
|
self:saveProgress(self.index + 1)
|
||||||
end
|
end
|
||||||
|
|
3141
sys/etc/blocks.json
3141
sys/etc/blocks.json
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue