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

bios:338: [string "cell"]:5: '<eof>' expected.

Started by NdMSnIpEz, 11 May 2013 - 02:12 PM
NdMSnIpEz #1
Posted 11 May 2013 - 04:12 PM
Hi, I'm trying to make a program that will place a redstone energy cell, wait for it to be charged, then break it using the crescent hammer addon and drop it into a tesseract. It says eof expected. Here's the code:


turtle.place()
if turtle.detect()==true then
print("Redstone Energy Cell is Charging.")
end
else
  print("Redstone Energy Cell Not Recieved Yet. Waiting...")
  sleep(10)
end

while true do
m = peripheral.wrap("front")
data = m.get
do print(i..":"..tostring("data"))
if ("FullEnergy")==true then
turtle.dig()
turtle.dropDown(1)
else
sleep(2)
end

Could someone please help me? (BTW I'm new to programming in lua and may have typo'ed something. Any help would be appreciated.
Lyqyd #2
Posted 11 May 2013 - 04:46 PM
Split into new topic.
NdMSnIpEz #3
Posted 11 May 2013 - 04:55 PM
Managed to fix a part of it by myself. Now something strange happens. The turtle says: Redstone Energy Cell is Charging. That shows that the first part works. But the second one doesn't. It causes the turtle to reboot and nothing else. No error message.
Here's the code:


turtle.place()
if turtle.detect()==true then
print("Redstone Energy Cell is Charging.")
else
  print("Redstone Energy Cell Not Recieved Yet. Waiting...")
  sleep(10)
end

while true do
end
m = peripheral.wrap("front")
data = m.get
print(tostring("data"))
if ("FullEnergy")==true then
turtle.dig()
turtle.select(1)
turtle.dropDown()
else
sleep(2)
end
Also made a short video on what happens.
Here.

EDIT: Made a couple of advancements in my code. Now I get this error:
cell:12: attempt to index ? (a nil value)
Here's the code I made:


turtle.select(1)
turtle.place()
if turtle.detect()==true then 
print("Redstone Energy Cell is Charging.")
else
  print("Redstone Energy Cell Not Recieved Yet. Waiting...")
  sleep(10)
end

while true do
   m = peripheral.wrap("front")
   data = m.get
   print(tostring("data"))
   if ("FullEnergy")==true then
   turtle.dig()
   turtle.select(1)
   turtle.dropDown()
   else
   sleep(2)
   end
end
Engineer #4
Posted 11 May 2013 - 04:55 PM
I have re indented the code for you. You should do that too, its a good habit to do and you spot quick fixes :P/>
The code under this should be self-explainatory (Or something like that xD )


turtle.place()
if turtle.detect()==true then
	print("Redstone Energy Cell is Charging.")
end --# The statement is if-else-end
else
	print("Redstone Energy Cell Not Recieved Yet. Waiting...")
	sleep(10)
end

while true do
	m = peripheral.wrap("front")
	data = m.get() --# parenthesis are important when you call a function! 
	do print(i..":"..tostring("data"))
	if ("FullEnergy")==true then --# I think this line should be: data[someIndex] then (You can leave the == true)
		turtle.dig()
		turtle.dropDown(1)
	else
		sleep(2)
	end
--# Also you are missing an end here to close the loop

Edit: Ninja's, ninja's everywhere :P/>
NdMSnIpEz #5
Posted 11 May 2013 - 05:47 PM
Edit: Ninja's, ninja's everywhere :P/>
hehehe. Didn't wanna double post. Anyway, made a huge advancement into my code. I seem to be getting alot better at coding. Still stumped by one thing, though. I have this beast.


turtle.select(1)
turtle.place()
if turtle.detect()==true then
print("Redstone Energy Cell is Charging.")
else
  print("Redstone Energy Cell Not Recieved Yet. Waiting...")
  sleep(10)
end

m = peripheral.wrap("right")
data = m.get()
for field, value in pairs(data) do
   print(field..":"..tostring(value))  
   end
if ("Full Energy")==true then		
turtle.dig()
turtle.select(1)
turtle.dropDown()
else
sleep(2)
end
It runs fine. Apart from the fact that it doesn't pick up the cell when it's charged. Any help on this one? (By the way I removed the 'while true do'. Although I will try the data[someindex].
EDIT: Tried the index string thing. Comes up with an error saying a ] is missing on line 15, when it clearly isn't. Stumped, yet again.
Cmon CC, gimme a break! D:
KaoS #6
Posted 11 May 2013 - 05:56 PM
uhm… if ("full energy")==true ??? what redstone cell are you using from what mod and how is it being charged because "full energy" is a string and will never be equal to a positive boolean
NdMSnIpEz #7
Posted 11 May 2013 - 06:07 PM
uhm… if ("full energy")==true ??? what redstone cell are you using from what mod and how is it being charged because "full energy" is a string and will never be equal to a positive boolean
If you didn't read below, I changed it to data[Full Energy]. I'm using the Redstone Energy cell from thermal expansion and im powering it using 8 industrial steam engines that fun at 8mj/t, making a total of 64mj/t.
Engineer #8
Posted 11 May 2013 - 06:16 PM
You should use data[''Full Energy"]
That should work
NdMSnIpEz #9
Posted 11 May 2013 - 06:26 PM
Worked perfectly! Thanks :)/> Gonna upload the final code to the program database.