6 posts
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
3790 posts
Location
Lincoln, Nebraska
Posted 28 April 2015 - 12:51 AM
Moved to Ask A Pro
957 posts
Location
Web Development
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/sKLqTGrMStick 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>
6 posts
Posted 28 April 2015 - 11:17 PM
Thank you so much for the fast answer. I will sure be looking to that soon :D/>
1 posts
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.
6 posts
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)
6 posts
Posted 29 April 2015 - 01:32 AM
Derpie me, I forgot to add the () after the tankinfo
But now, it returns me a table!
115 posts
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
6 posts
Posted 29 April 2015 - 09:57 PM
Now im getting as a answer : 1table: 567ad2b0
But the numbers and letters always change
6 posts
Posted 29 April 2015 - 10:33 PM
Finally found the solution :D/>
Here is my program
http://pastebin.com/QSDqG1SXThank you to everyone who helped me!