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

Blood Magc LP in Altar HELP

Started by TormDemoniax, 27 April 2015 - 10:00 PM
TormDemoniax #1
Posted 28 April 2015 - 12:00 AM
Hello, I have recently been getting into programming. Im decently new to all programming language such as lua, but I do have a base knowledge of it. So here is my situation : I have an MFR spawner that spawns villager so I can kill them. But I want to regulate there numbers by reading the amount of LP in the Altar. Basically the only thing I need to know is, how can I read the amount of LP in an Altar? I am not asking for a full program I just want to know that.

Thanks!
TormDemoniax
Cranium #2
Posted 28 April 2015 - 12:51 AM
Moved to Ask A Pro
HPWebcamAble #3
Posted 28 April 2015 - 01:04 AM
If the altar is a peripheral, you can wrap it like a monitor or printer

You can check with this program I wrote:
http://pastebin.com/sKLqTGrM

Stick a computer next to the altar, then download and run the program

To download as 'gm'

pastebin get sKLqTGrM gm

Then run it, with the altar's side as an argument:

gm <side>
TormDemoniax #4
Posted 28 April 2015 - 11:17 PM
Thank you so much for the fast answer. I will sure be looking to that soon :D/>
MagicPwnies #5
Posted 28 April 2015 - 11:32 PM
I'm pretty sure with openPeripherals you can wrap the altar and use .getTankInfo to get the amount of LP currently in it. so something like this:

local altar = peripheral.wrap('top') –or whatever side it is on
local tankData = altar.getTankInfo()

I believe that a blood altar has two tanks so to see that main tank amount it will be in tankData[1].amount
Again i'm not 100% sure about this but I know with openPeripherals it can be wrapped and you can read the amount of LP in it.
TormDemoniax #6
Posted 29 April 2015 - 01:30 AM
Well, I tried it but when I do getTankInfo in a program it returns me a function for example my ansmer for my program is function: 66857750
Here is my program :
Altar = peripheral.wrap("back")
Stored = altar.getTankInfo
Print (stored)
TormDemoniax #7
Posted 29 April 2015 - 01:32 AM
Derpie me, I forgot to add the () after the tankinfo

But now, it returns me a table!
Inumel #8
Posted 29 April 2015 - 06:25 AM
Derpie me, I forgot to add the () after the tankinfo

But now, it returns me a table!

Try this.

for k,v in pairs(altar.getTankInfo()) do
   print(k,v)
end
TormDemoniax #9
Posted 29 April 2015 - 09:57 PM
Now im getting as a answer : 1table: 567ad2b0

But the numbers and letters always change
TormDemoniax #10
Posted 29 April 2015 - 10:33 PM
Finally found the solution :D/>
Here is my program

http://pastebin.com/QSDqG1SX
Thank you to everyone who helped me!