Jump to content




Get item ID inside blood magic altar.


  • You cannot reply to this topic
28 replies to this topic

#1 fanzypantzy

  • Members
  • 14 posts

Posted 16 January 2016 - 01:05 AM

Is it possible to easily just get the ID of anything currently inside a blood magic altar?

Edited by fanzypantzy, 17 January 2016 - 12:09 AM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 16 January 2016 - 01:20 AM

Not through vanilla ComputerCraft. OpenPeripheral may allow it. Stick a computer next to an altar, run eg this script on it, see what that tells you.

#3 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 16 January 2016 - 01:21 AM

I doubt computercraft alone could do this. However, if OpenPeripherals is available, depending on the version of OpenP and Blood Magic, maybe.

This will give you either a list of methods for the alter (if it's a peripheral), or tell you it's not one (if it's not a peripheral).

local side = "top" --#this should be whatever side the alter is on
if peripheral.isPresent( side ) then
  for k, v in pairs( peripheral.getMethods( side ) do
    print( k )
  end
else
  print( "Not a Peripheral!" )
end

EditNinja'd

Edited by KingofGamesYami, 16 January 2016 - 01:21 AM.


#4 fanzypantzy

  • Members
  • 14 posts

Posted 16 January 2016 - 11:43 PM

Alright I thought it first was a little over my head and did it another way. But if I can understand this I can redo some of my script to make the automation much faster :)

Here are the method I think I will have the most use of:
Posted Image

My questions are:

How do I get the different parts of getInfo() under the blood altar. It returns more than one thing and I would like to be able to call both the capacity and contents separately.
I'm really really new to this and have never coded anything else than a simple sheep farm. How can I get the capacity and do a simple "while capacity > 8000 do" or something similar. And how can I get the contents so I can wait until the right slate is finished. Again as simple as "contents = Bloodmagic:Blankslate" or something like that.

Here is the script I am working in atm, it does all the filtering manually with BC emzuli pipes and gates.

Spoiler

Edited by fanzypantzy, 16 January 2016 - 11:45 PM.


#5 Ajt86

  • Members
  • 42 posts

Posted 16 January 2016 - 11:47 PM

It returns a table, so just get the index in the table.

local atable = {
  ["key"] = "Value"
}
print(atable.key)    -- Prints "Value"
print(atable["key"])    -- Prints "Value"

The latter is more useful when Lua could misinterpret the dot notation (spaces or special characters in key). It is also more useful when you're dynamically indexing the table.

#6 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 16 January 2016 - 11:52 PM

It actually returns a NESTED table, which is a table in a table.

local tbl = drive.getInfo()
tbl.contents.amount
will be the numerical value of it's current amount

#7 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 12:08 AM

Thank you Dragon that solves one part of the question :)

Could this give me the information about the block inside the blood altar?
Posted Image

The big question is: teach me like I am 5, what is this proxy table thingy?

#8 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 12:19 AM

What does the rest of the statement regarding it say?

#9 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 12:23 AM

Are you thinking of this?

Posted Image

I mean it's not giving me much to go on to figure out what is in the table or how to get to it:

Posted Image

#10 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 12:28 AM

From what I can see, it's returning something that can't be easily serialized. or it might...

Try running this to see what's in it
textutils.serialize(drive.getAllStacks())
If you get an error, that means that it's probably got a function in it somewhere.
If it does error, we'll work on that next.

I think proxy is negligible right now, since you're referencing the altar you care about anyways, no need for a proxy I assume.

#11 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 12:30 AM

Does this classify as an error in your books? :)

Posted Image

#12 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 12:37 AM

Figures... I'm assuming you know how to edit and run files, so make a file and run this:

local side = "left"
local drive = peripheral.wrap(side)
local file = fs.open("tableFile","w")
local function readTable(tbl,previous)
  previous = previous or ""
  for a,v in pairs(tbl) do
	if type(v) == table then
	  readTable(tbl,previous..a..":")
	else
	  file.writeLine(previous..a.." = " .. type(v))
	end
  end
end
readTable(drive.getAllStacks(),"")
file.close()

And then open the tableFile file

Edited by Dragon53535, 17 January 2016 - 12:39 AM.


#13 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 12:42 AM

Alright the tablefile contains:

1 = table


#14 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 12:45 AM

That's my fault.

local side = "left"
local drive = peripheral.wrap(side)
local file = fs.open("tableFile","w")
local function readTable(tbl,previous)
  previous = previous or ""
  for a,v in pairs(tbl) do
		if type(v) == "table" then --# I forgot the quotes here
		  readTable(tbl,previous..a..":")
		else
		  file.writeLine(previous..a.." = " .. type(v))
		end
  end
end
readTable(drive.getAllStacks(),"")
file.close()

Edited by Dragon53535, 17 January 2016 - 12:46 AM.


#15 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 12:49 AM

When I ran it this happened. Though I changed the side to front since it is facing forward atm.

Posted Image

But when I put the side back to left it returned 216 which is a blood interface block though. I assume you wanted the side to be the blood altar side.

#16 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 12:51 AM

Another one of my faults

local side = "left"
local drive = peripheral.wrap(side)
local file = fs.open("tableFile","w")
local function readTable(tbl,previous)
  previous = previous or ""
  for a,v in pairs(tbl) do
				if type(v) == "table" then --# I forgot the quotes here
				  readTable(v,previous..a..":") --#I was passing tbl here, which basically did this over and over again, without changing it's result
				else
				  file.writeLine(previous..a.." = " .. type(v))
				end
  end
end
readTable(drive.getAllStacks(),"")
file.close()

Yay for typos and mistakes...

Edited by Dragon53535, 17 January 2016 - 12:52 AM.


#17 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 12:52 AM

Hehe np. Here is the tablefile:

1:listSources = function
1:getAdvancedMethodsData = function
1:all = function
1:listMethods = function
1:doc = function
1:keys = function
1:basic = function
1:select = function
1:single = function


#18 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 12:54 AM

This looks like it's returning a table that has a peripheral in it. Given this thought, I'd go with:

drive.getAllStacks()[1].listMethods()
I probably should say, I mean plug that back into the lua prompt after wrapping the altar again.

Edited by Dragon53535, 17 January 2016 - 12:57 AM.


#19 fanzypantzy

  • Members
  • 14 posts

Posted 17 January 2016 - 12:59 AM

Here we go, everything you are doing is slightly over my head, but I trust you :):

Posted Image

#20 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 17 January 2016 - 01:03 AM

I'll just go with probably not this function then.
Just to test though, what do these get you?
drive.getAllStacks()[1].keys()
drive.getAllStacks()[1].listSources()


I'd also check what other methods you can use for the altar.
drive.listMethods()






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users