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

Portal Program

Started by sephermoor, 11 January 2014 - 09:33 PM
sephermoor #1
Posted 11 January 2014 - 10:33 PM
Hello
so i am trying to get a portal program to work in a custom mod pack 1.6.4.
I have pulled 3 programs off of pastebin to run with a advanced computer and advanced wireless turtle.
On the advanced computer i have:
http://pastebin.com/cK9wnj7X this is labeled as button
http://pastebin.com/Wvn6zT3i this is labeled as portal

In my turtle i have:
http://pastebin.com/BEhzLeLQ this is labeled as books

Now under the advanced computer is my wireless modem and to the right is advanced monitors. Under the turtle is an iron chest.
I also added a program on the turtle its labeled as startup it has
shell.run("books")

same with the computer but it is
shell.run("portal")

So i reboot the turtle and it runs books.
Then i reboot the computer and it runs portal but when i go back to the turtle it gives me an error
books:16: attempt to index ? (a nil value)
can anyone help me with this its driving me crazy i assume the 16 means the line that's having the error but i'm not positive.
Alice #2
Posted 12 January 2014 - 12:05 AM
Do you have mods installed?
You need OpenPeripherals
/*Nice direwolf20 vid watching :P/>*/
surferpup #3
Posted 12 January 2014 - 02:36 AM
Take a look at my portal program. It is working pretty well.

Portal Computer: http://pastebin.com/amCuLiLa

Portal Turltes: http://pastebin.com/aysQLJG7

It uses wireless turtles, N number of wired monitors (I think three is plenty), it operates as a touch screen, and it allows for easy creation of labels, etc. The turtles and the computer synchronize automatically based on turtle inventories. I just haven't got around to posting it on the forums yet. Feel free to steal code liberally.
Alice #4
Posted 12 January 2014 - 02:39 AM
The only problem with his is that he doesn't have OpenPeripherals installed, otherwise that method wouldn't error.
surferpup #5
Posted 12 January 2014 - 02:54 AM
So i reboot the turtle and it runs books.
Then i reboot the computer and it runs portal but when i go back to the turtle it gives me an error
books:16: attempt to index ? (a nil value)
can anyone help me with this its driving me crazy i assume the 16 means the line that's having the error but i'm not positive.

I had this problem on mine. First, I ended up using routers to deal with the turtle.suck() issue. It is much more effective. Second, you have to make sure that the book gets put back into the same slot.

I use a routine like this to ensure placement in the inventory:

function pullBook(book)
displayStatus("Pulling Book"..tostring(book),9,0)
	-- force router to eject
	redstone.setOutput("bottom", false)
	sleep (.2)
	-- check book placement, if placed in wrong slot move it
	if turtle.getItemCount(book)==0 then
		for slot=1,16 do
			if (turtle.getItemCount(slot)~=slots[slot]) then
				--print ("Bad Slot")
				turtle.select(slot)
				xferResult =true

				if (not turtle.transferTo(book,1)) then
					--print("could not moved book to "..tostring(slot))
					slots[slot]=turtle.getItemCount(slot)
				else
					--print("moved book to "..tostring(slot))
					break
				end
			end
		end
	end
redstone.setOutput("bottom", true) -- turns router back on
end

Also, I just updated my code on pastebin to the newest version I am running. The users on my server really like the portal functionality. I am thinking of rewriting it and taking advantage of the coroutine concepts. It should make turtle/computer communication much easier. As it is it works fairly well. It has been running 33 days without a hitch – complete with daily server reboots. I haven't messed with it a bit.