- ComputerCraft | Programmable Computers for Minecraft
- → Avarion's Content
Avarion's Content
There have been 15 items by Avarion (Search limited from 10-February 22)
#247316 Comprehensive Strip Miner
Posted by
Avarion
on 05 March 2016 - 11:59 AM
in
Turtle Programs
#223811 Combine turtle.inspect() with while?
Posted by
Avarion
on 29 June 2015 - 06:22 PM
in
Ask a Pro
I try to make a turtle digging while there is gravel in front of it.
My first test was
if turtle.forward() == false then
if turtle.inspect() == true, "minecraft:gravel" then
while turtle.inspect() == true, "minecraft:gravel" do
turtle.dig()
sleep(1)
end
else
break
end
end
Unfortunately it seems the while command is not able to handle both values at once. Is there a way to make it work or do I have to fill the inspect information to variables first and compare then?
#220252 Storing multiple peripherals in a table
Posted by
Avarion
on 07 June 2015 - 01:27 PM
in
Ask a Pro
function getMaxEnergy(cell)
local count = 0
local i = 0
for i in pairs(cell) do
count = count + cell[i].getMaxEnergy()
end
print(i)
return(count)
end
cell = {peripheral.find("tile_thermalexpansion_cell_resonant_name")}
print(getMaxEnergy(cell))
#220248 Storing multiple peripherals in a table
Posted by
Avarion
on 07 June 2015 - 01:01 PM
in
Ask a Pro
Bomb Bloke, on 07 June 2015 - 12:57 PM, said:
Thanks. That was the solution. I thought find (and my variant) look up a part of the string and wrap when the part is found in the peripherals name.
#220245 Storing multiple peripherals in a table
Posted by
Avarion
on 07 June 2015 - 12:52 PM
in
Ask a Pro
x = peripheral.wrap("tile_thermalexpansion_cell_resonant_name_3")
print("Energy: "..x.getEnergyStored("unknown"))
print("Max Energy: "..x.getMaxEnergyStored("unknown"))
This prints:
Energy: 78236235 Max Energy: 80000000
And this prints nothing:
cell = {peripheral.find("tile_thermalexpansion_cell")}
for i = 1, #cell do
print(cell[i].getEnergyStored())
end
Even when I add the "unknown" to the method.
#220242 Storing multiple peripherals in a table
Posted by
Avarion
on 07 June 2015 - 11:53 AM
in
Ask a Pro
function prepare()
cell = {}
local peripheralList = peripheral.getNames()
counter = 0
for Index = 1, #peripheralList do
if string.find(peripheralList[Index], "tile_thermalexpansion_cell") then
counter = counter + 1
cell[counter]=peripheral.wrap(peripheralList[Index])
end
end
return(cell)
end
cell = prepare()
print(cell[1][1])
cell = {peripheral.find("tile_thermalexpansion_cell")}
print(cell[1][1])
The table seems always to be empty.
If I wrap a single energy cell I get data.
Edit: Oh, if I use just cell[1] I just get the table ID, thus I've used [1][1]. There might be the problem if I haven't understood how table work.
#220213 Storing multiple peripherals in a table
Posted by
Avarion
on 07 June 2015 - 07:48 AM
in
Ask a Pro
I'm trying to read the energy status of multiple energy cells. I'm trying to make it adaptive so I just have to add more cells and add them to the network and the program recognizes them. Therefore I thought I use function which uses a loop to check for all the cells and add them to a table. Then returns the table. Unfortunately it seems the table is empty when I try to access it from the main program.
function prepare()
cell = {}
local peripheralList = peripheral.getNames()
counter = 0
for Index = 1, #peripheralList do
counter = counter + 1
if string.find(peripheralList[Index], "tile_thermalexpansion_cell") then
cell[counter]=peripheral.wrap(peripheralList[Index])
end
end
return(cell)
end
function getEnergy()
end
cell = prepare()
print(cell[1].getType())
#213720 Is there a way for turtles to go through doors?
Posted by
Avarion
on 12 April 2015 - 05:59 PM
in
Ask a Pro
I don't like the idea of having open wall or ceiling elements in my base for the turtles to use.
#212025 Is there a way to place microblocks or facades on carpenter blocks?
Posted by
Avarion
on 02 April 2015 - 12:46 PM
in
Peripheral Help and Discussion
#210972 Is there a way to place microblocks or facades on carpenter blocks?
Posted by
Avarion
on 25 March 2015 - 08:31 PM
in
Peripheral Help and Discussion
- ComputerCraft | Programmable Computers for Minecraft
- → Avarion's Content


