This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Silverhustle's profile picture

Computercraft Dailer System for Draconic Evolution Portals?

Started by Silverhustle, 02 April 2016 - 01:23 AM
Silverhustle #1
Posted 02 April 2016 - 03:23 AM
I'm wondering if it's possible to have a dailer system for draconic evolution portals using a dislocator receptacle with charm of dislocation while running CompuerCraft? That would allow you to select a destination using a single portal with chest with multiple charm of dislocations in the chest.

Much like the Nexus Mystcraft multi-destination and this really sick Nexus setup that someone posted a while ago. Is it possible that a lua file can be altered and using draconic evolution blocks instead? I know that you can rename charm of dislocation using an anvil, just like linking books.

I have tested that Mystcraft dailer system on the creative world and it works perfectly. But the server I'm playing on disabled the Mystcraft creation so I would like to use Draconic Evolution portals instead. I tried placing "linking book" to "charm of dislocation" in the lua files, seems it doesn't work that way or is there something that I'm missing?

I'm playing on Infinity Evolved modpack if that matters.
Silverhustle #2
Posted 03 April 2016 - 03:25 AM

function debug(...)
  if not debugging then return end
  print('[Debug] ', unpack(arg) )
end
function debugTable(tbl)
  if not debugging then return end
  for key, value in pairs(tbl) do
    print(key, ': ', value)
  end
end
function discoverPeripherals()
  pMonitor = waitForPeripheral('monitor')
  pChest   = waitForPeripheral('chest')
  pMusic   = waitForPeripheral('note_block')
  debug('Discovered perhiperals')
end
function waitForPeripheral(type)
  unit = nil
  repeat
    unit = peripheral.find(type)
    if (unit == nil) then
	  if (pMusic ~= nil) then
	    pMusic.playSound('mob.bat.hurt', 1, 1)
	  end
	  print('Waiting for peripheral: ', type)
	  sleep(2.5)
    end
  until unit ~= nil
  return unit
end
function prepareUI()
  pMonitor.setTextScale(state.scale)
  state.width,
  state.height = pMonitor.getSize()
  debug('UI prepared')
end
function clearUI()
  pMonitor.setBackgroundColor(colors.black)
  pMonitor.clear()
  debug('UI cleared')
end
function adjustScale(delta)
  state.scale = state.scale + delta
  if	 state.scale > 5.0 then state.scale = 5
  elseif state.scale < 0.5 then state.scale = 0.5
  end
  prepareUI()
  print('Adjusted scale to ', state.scale)
end
function adjustColWidth(delta)
  state.entryW = state.entryW + delta
  if	 state.entryW > 50 then state.entryW = 50
  elseif state.entryW < 1  then state.entryW = 1
  end
  print('Adjusted col. width to ', state.entryW)
end
function setPortal(book, slot)
  -- Structure of a book or orb:
  -- book.display_name
  -- book.myst_book.destination
  pChest.pullItem('UP', 1)
  state.selected = nil
  if (book == nil and slot == nil) then
    debug('Portal reset')
  else
    pMusic.playSound('portal.travel', 1, 1)
    pChest.pushItem('UP', slot)
    state.selected = book
    debug('Portal set to: ', book.display_name)
  end
end
function updateButtons()
  state.entryX,
  state.entryY  = 2, 5
  state.buttons = {}
 
  -- Have to sort book items using indicies than
  -- by table keys
  stacks = pChest.getAllStacks()
  books  = {}
  for slot, stack in pairs(stacks) do
    -- OpenPeripheralCore 1.0 returns a "query"
    -- object rather than the itemstack itself.
    -- .all() from that object fetches all the
    -- properties as before.
    if (stack.all ~= nil) then
	  stack = stack.all()
    end
    if (stack.name == "charmofdislocation") then
	  stack.name = getBookName(stack)
	  stack.slot = slot
	  table.insert(books, stack)
    end
  end
  table.sort(books, sortBook)
  for _, book in ipairs(books) do
    addButton(book)
  end
  debug('Updated buttons')
end
function getBookName(book)
  if (book.display_name == "Charm of Dislocation") then
    return book.myst_book.destination
  else
    return book.display_name
  end
end
function sortBook(a, B)/>
  return a.name:lower()
	   < b.name:lower()
end
function addButton(book)
  button   = {}
  button.x    = state.entryX
  button.y    = state.entryY
  button.name = book.name
  button.lbl  = ' '..book.name:sub(0, 20)..' '
  button.xEnd = state.entryX + state.entryW
  button.book = book
  button.slot = book.slot
  table.insert(state.buttons, button)
  nextEntryPos()
end
function blinkButton(button)
  for i = 0,3 do
    pMonitor.setCursorPos(button.x, button.y)
    if (i % 2 == 0) then
	  pMonitor.setBackgroundColor(colors.gray)
    else
	  pMonitor.setBackgroundColor(colors.blue)
    end
    pMonitor.write(button.lbl)
    sleep(0.1)
  end
end
function nextEntryPos()
  state.entryY = state.entryY + 2
  if (state.entryY >= state.height) then
    state.entryX = state.entryX + state.entryW
    state.entryY = 5
  end
end
function drawBanner(text)
  pMonitor.setCursorPos(1, 1)
  pMonitor.setBackgroundColor(colors.blue)
  pMonitor.setTextColor(colors.white)
  drawFilledBox(pMonitor, 1, 1, state.width, 3)
  pMonitor.setCursorPos(2, 2)
  if (text ~= nil) then
    pMonitor.write(text)
  elseif (state.selected ~= nil) then
    pMonitor.write('Destination: '
	  .. state.selected.name)
  else
    pMonitor.write('Please select a destination')
  end
end
function drawButtons()
  for _, button in ipairs(state.buttons) do
    pMonitor.setBackgroundColor(colors.gray)
    -- Special cases
    if	 (button.name == 'The End') then
	  pMonitor.setTextColor(colors.lightBlue)
    elseif (button.name == 'The Nether') then
	  pMonitor.setTextColor(colors.red)
    elseif (button.name == 'The Deep Dark') then
	  pMonitor.setTextColor(colors.black)
    elseif (button.name == 'The Last Millenium') then
	  pMonitor.setTextColor(colors.lightGray)
    else
	  pMonitor.setTextColor(colors.white)
    end
    pMonitor.setCursorPos(button.x, button.y)
    pMonitor.write(button.lbl)
  end 
end

It should work like that if linking books and charm of dislocations are very similar, did I do something wrong?
Communeguy #3
Posted 03 April 2016 - 03:52 AM
My first thought - and granted I don't use Draconic Evolution - would be that the NBT structures for the books and the charms are dissimilar. I mean, a more precise explanation of how your modified code fails would be helpful.

More relevantly, though, the code is still behaving as though it is talking to mystcraft books. You've changed some display features to the string Charm of Dislocation but you've done nothing to address actual functions such as "book.mystbook.destination"

Either way, beyond these vague ideas of where the fault might be, this kind of program is outside my usual area of expertise (checking hidden values on blocks to control other functions as in my ReactorCraft controller) and you'd be better served with someone else's help.
Silverhustle #4
Posted 03 April 2016 - 04:17 AM
Yeah, me and my friend worked on this and solved the problem. We were able to use charm of dislocation using the dislocator successfully using a similar code. Thanks anyways! :)/>
123blastoff #5
Posted 03 April 2016 - 07:17 PM
Is there a way I could convince you to post that code? I want to use it also. Thanks :)/>
Silverhustle #6
Posted 03 April 2016 - 10:57 PM
Is there a way I could convince you to post that code? I want to use it also. Thanks :)/>

Yeah, no problem. Here's the code.


function debug(...)
  if not debugging then return end
  print('[Debug] ', unpack(arg) )
end
function debugTable(tbl)
  if not debugging then return end
  for key, value in pairs(tbl) do
    print(key, ': ', value)
  end
end
function discoverPeripherals()
  pMonitor = waitForPeripheral('monitor')
  pChest   = waitForPeripheral('chest')
  pMusic   = waitForPeripheral('note_block')
  debug('Discovered perhiperals')
end
function waitForPeripheral(type)
  unit = nil
  repeat
    unit = peripheral.find(type)
    if (unit == nil) then
	  if (pMusic ~= nil) then
	    pMusic.playSound('mob.bat.hurt', 1, 1)
	  end
	  print('Waiting for peripheral: ', type)
	  sleep(2.5)
    end
  until unit ~= nil
  return unit
end
function prepareUI()
  pMonitor.setTextScale(state.scale)
  state.width,
  state.height = pMonitor.getSize()
  debug('UI prepared')
end
function clearUI()
  pMonitor.setBackgroundColor(colors.black)
  pMonitor.clear()
  debug('UI cleared')
end
function adjustScale(delta)
  state.scale = state.scale + delta
  if	 state.scale > 5.0 then state.scale = 5
  elseif state.scale < 0.5 then state.scale = 0.5
  end
  prepareUI()
  print('Adjusted scale to ', state.scale)
end
function adjustColWidth(delta)
  state.entryW = state.entryW + delta
  if	 state.entryW > 50 then state.entryW = 50
  elseif state.entryW < 1  then state.entryW = 1
  end
  print('Adjusted col. width to ', state.entryW)
end
function setPortal(book, slot)
  -- Structure of a link book:
  -- book.display_name
  -- book.myst_book.destination
  pChest.pullItem('EAST', 1)
  state.selected = nil
  if (book == nil and slot == nil) then
    debug('Portal reset')
  else
    pMusic.playSound('portal.travel', 1, 1)
    pChest.pushItem('EAST', slot)
    state.selected = book
    debug('Portal set to: ', book.display_name)
  end
end
function updateButtons()
  state.entryX,
  state.entryY  = 2, 5
  state.buttons = {}
 
  -- Have to sort book items using indicies than
  -- by table keys
  stacks = pChest.getAllStacks()
  books  = {}
  for slot, stack in pairs(stacks) do
    -- OpenPeripheralCore 1.0 returns a "query"
    -- object rather than the itemstack itself.
    -- .all() from that object fetches all the
    -- properties as before.
    if (stack.all ~= nil) then
	  stack = stack.all()
    end
    if (stack.name == "teleporterMKI") then
	  stack.name = getBookName(stack)
  --    for key, value in pairs(stack) do print(tostring(key) .. ": " .. tostring(value)) end
--exit();
	  stack.slot = slot
	  table.insert(books, stack)
    end
  end
  table.sort(books, sortBook)
  for _, book in ipairs(books) do
    addButton(book)
  end
  debug('Updated buttons')
end
function getBookName(book)
  if(book.display_name==nil) then
    return book.name;
  end
    return book.display_name;
end
function sortBook(a, B)/>
  return a.name:lower()
	   < b.name:lower()
end
function addButton(book)
  button   = {}
  button.x    = state.entryX
  button.y    = state.entryY
  button.name = book.name
  button.lbl  = ' '..book.name:sub(0, 20)..' '
  button.xEnd = state.entryX + state.entryW
  button.book = book
  button.slot = book.slot
  table.insert(state.buttons, button)
  nextEntryPos()
end
function blinkButton(button)
  for i = 0,3 do
    pMonitor.setCursorPos(button.x, button.y)
    if (i % 2 == 0) then
	  pMonitor.setBackgroundColor(colors.gray)
    else
	  pMonitor.setBackgroundColor(colors.blue)
    end
    pMonitor.write(button.lbl)
    sleep(0.1)
  end
end
function nextEntryPos()
  state.entryY = state.entryY + 2
  if (state.entryY >= state.height) then
    state.entryX = state.entryX + state.entryW
    state.entryY = 6
  end
end
function drawBanner(text)
  pMonitor.setCursorPos(1, 1)
  pMonitor.setBackgroundColor(colors.blue)
  pMonitor.setTextColor(colors.white)
  drawFilledBox(pMonitor, 1, 1, state.width, 3)
  pMonitor.setCursorPos(2, 2)
  if (text ~= nil) then
    pMonitor.write(text)
  elseif (state.selected ~= nil) then
    pMonitor.write('Destination: '
	  .. state.selected.name)
  else
    pMonitor.write('Please select a destination')
  end
end
function drawButtons()
  for _, button in ipairs(state.buttons) do
    pMonitor.setBackgroundColor(colors.gray)
    -- Special cases
    if	 (button.name == 'The End') then
	  pMonitor.setTextColor(colors.lightBlue)
    elseif (button.name == 'The Nether') then
	  pMonitor.setTextColor(colors.red)
    elseif (button.name == 'The Deep Dark') then
	  pMonitor.setTextColor(colors.black)
    elseif (button.name == 'The Last Millenium') then
	  pMonitor.setTextColor(colors.lightGray)
    else
	  pMonitor.setTextColor(colors.white)
    end
    pMonitor.setCursorPos(button.x, button.y)
    pMonitor.write(button.lbl)
  end 
end

Other three files remains the same.