local ts = ts or { call = function() end, eval = function() end, } ts.eval [[ function commandShiftBrick(%x, %y, %z) { commandToServer('shiftBrick', %x, %y, %z); } function commandPlantBrick() { commandToServer('plantBrick'); } ]] local function plantBrickAt(brickpos, pos) local dx, dy, dz = pos[1]-brickpos[1], pos[2]-brickpos[2], pos[3]-brickpos[3] ts.call("commandShiftBrick", dy, -dx, dz) ts.call("commandPlantBrick") brickpos[1], brickpos[2], brickpos[3] = pos[1], pos[2], pos[3] end local function buildMemory(mem, romsize, offset, len) if type(romsize)~="table" or #romsize<3 then error("You must specify a ROM size.") end offset = offset or 0 local rombytes = romsize[1]*romsize[2]*romsize[3]/8 if len and len>rombytes then error("rom not big enough to hold "..len.." bytes (holds "..rombytes..")") end if not len then for i = 0, 0xFFFF do if mem[i] and (i=offset+rombytes) then error("memory does not fit in rom at addr "..string.format("%04X", i)) end end end local brickpos = {0, 0, 0} for x = 0, romsize[1]-1 do for y = 0, romsize[2]-1 do for z = 0, romsize[3]-1 do local addr = offset + ((romsize[3]/8)*(x + y*romsize[1]) + math.floor(z/8)) local pow = math.pow(2, z%8) local data = (addr>=offset and ((not len) or addr