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

Act Script: Etho's Rail

Started by McLeopold, 13 August 2013 - 07:30 PM
McLeopold #1
Posted 13 August 2013 - 09:30 PM
Act scripting language version 2 is in beta. Here is some of the progress I've made. The turtles auto install, fuel up, position themselves, request supplies and build Etho's nether rail line communicating via modems.

[media]http://youtu.be/D0rtaDP3CvA[/media]

Take a peek at https://github.com/Forte40/act or install it

pastebin get 5CuUMxqr act-get
act-get

Installation

Like the video, place a disk drive on the left and a chest of fuel on the right. The center will be where the turtles go and where the track will be built. Make sure you have a 5x5 tunnel opening for the turtles to position themselves. If not, they will wait until the place is clear before coming online. Make sure each turtle is positioned and online before initializing the next.

To get the floppy ready put it in the disk drive and place the first turtle. Then run


pastebin get 5CuUMxqr act-get
act-get
act-get startup
act-get ethos_rail
copy ethos_rail.act disk

The floppy will now contain the startup script and ethos_rail.act. Now reboot the turtle and it will be the first on to initialize.

Here is the script that controls everything:

Spoiler

-- the tunnel cross section will look like this
-- _ is stone slab on bottom half
-- ^ is stone slab on top half
-- = is stone brick
-- I is iron bars
-- H is minecart track
-- * is glowstone
--
--	  normal	  every 8
--  4   _ _ _		_ * _  
--  3 = ^   ^ =	= ^   ^ =
--  2 I	   I	=	   =
--  1 I	   I	=	   =
--  0 = _ H _ =	= _ H _ =
-- -1	 ^			^

-- set start positions (x,y,z) and facing direction
%startup
  ,forman,	   0,1,0 ,south
  ,Left,		 2,3,1 ,south
  ,LeftCenter,   1,4,1 ,south
  ,Center,	   0,4,1 ,south
  ,RightCenter, -1,4,1 ,south
  ,Right,	   -2,3,1 ,south
%
-- routine to request resources
-- more than what is requested can be added
-- turtle only confirms amount, not type
--   slot, description, amount
(
  (Left:		%request, 1, brick, 18,
						  2, bars,  14%)
  (LeftCenter:  %request, 1, slab, 24%)
  (Center:	  %request, 1, brick, 15,
						  2, track, 8,
						  3, glowstone, 1%)
  (RightCenter: %request, 1, slab, 24%)
  (Right:	   %request, 1, brick, 18,
						  2, bars,  14%)
)=%stock%

-- routine to dig 1 space forward
-- turtles should be facing forward at top of tunnel
(
  (Left:		 Mf Md3)
  (LeftCenter:   Mf Md3 Dd)
  (Center:	   Mf Md4 Dd)
  (RightCenter:  Mf Md3 Dd)
  (Right:		Mf Md3)
)=%dig%

-- routine to place normal section
-- turtles should be at bottom of tunnel
(
  (Left:		rr s1 Bf u s2 Bf u Bf u s1 Bf ll)
  (LeftCenter:  rr f s1 Bd u3 Bd b Bf ll)
  (Center:	  rr f s1 Bd u s2 Bd u2 s1 Bu b u rr)
  (RightCenter: ll f s1 Bd u3 Bd b Bf rr)
  (Right:	   ll s1 Bf u s2 Bf u Bf u s1 Bf rr)
)=%normal%

-- routine to place pillar and light section
-- turtles should be at bottom of tunnel
(
  (Left:		rr s1 Bf u Bf u Bf u Bf ll)
  (LeftCenter:  rr f s1 Bd u3 Bd b Bf ll)
  (Center:	  rr f s1 Bd u s2 Bd u2 s3 Bu b u rr)
  (RightCenter: ll f s1 Bd u3 Bd b Bf rr)
  (Right:	   ll s1 Bf u Bf u Bf u Bf rr)
)=%pillar%

-- dig and build loop
(
%stock%
(%dig% %normal%) 7
%dig% %pillar%
f8
)8

Notes:

This is still in beta. Report bugs on the github repo. This particular script does not do session persistance well because the startup scripts are fighting each other. I'm working on it, soon.

If you need to reset the system, delete all the ".act.*" files and the startup file, then go through the initialization process again.
Nerox #2
Posted 23 August 2013 - 11:21 AM
I can't get this to work. I've placed the disk drive, a blank floppy disk in it, the chest with fuel, and the turtle in the middle.
But when I download and execute act-get, it updates act-get and then is.. done. Nothing happens after that.
McLeopold #3
Posted 23 August 2013 - 03:57 PM
Yeah, the installer doesn't put the startup file anywhere, or even download it. The floppy needs to have startup and ethos_rail.act on it. I did it by manipulating my local files.

I'll update the act-get installer so you can get the startup floppy working.
McLeopold #4
Posted 23 August 2013 - 05:03 PM
I can't get this to work. I've placed the disk drive, a blank floppy disk in it, the chest with fuel, and the turtle in the middle.
But when I download and execute act-get, it updates act-get and then is.. done. Nothing happens after that.

Okay, it's fixed and running again. Use the new installation procedure above.
Nerox #5
Posted 24 August 2013 - 11:50 AM
Nice! I've tried it again, now the turtles indeed install everything correctly.
However, it gets stuck after initializing ethos_rail.act. Any turtle, no matter if blank (program wise), keep spinning around clockwise, right after "worker 'Center' offline"… Looks quite funny though. :P/>
McLeopold #6
Posted 24 August 2013 - 01:55 PM
Did you put down the fuel chest and put fuel in it?
Nerox #7
Posted 26 August 2013 - 04:19 PM
Yeah I have, it's still getting stuck after "worker 'Center' offline"
McLeopold #8
Posted 26 August 2013 - 05:47 PM
The looping is stuck at line 63-80 of startup.lua. The turtle is turning around in circles waiting for a chest to appear. I'm using perifpheral.getType("front") to look for a peripheral with the string "chest" in the name.

Try making the turtle face your chest and type the following:


> lua
lua> print(peripheral.getType("front"))

Let me know what prints out. It should be "chest" for a regular single wooden chest. An ender chest would be "ender_chest" and an iron chest would be "iron_chest" and so on. Barrels won't work because they return "furnace_heater".
em3ricasforsale #9
Posted 28 August 2013 - 08:41 PM
Are you taking request? If so, could you add to it a turtle that picks the supplies up from a chest and reloads the turtles when it runs out of supplies?
McLeopold #10
Posted 30 August 2013 - 12:59 AM
Are you taking request? If so, could you add to it a turtle that picks the supplies up from a chest and reloads the turtles when it runs out of supplies?

I am taking requests, thanks for asking! I'll put that on the todo list.

Before I even get to a reload function on the turtles, they would need a chest to dump everything they excavated. (Unless building above ground, then maybe only the occasional tree or extreme hill.) And powered rails would be nice too.

It some point I will improve it, but the act scripting language itself still needs a lot of love. The main issue is persistence isn't working for multi-turtle scripts yet.

BTW, are you using the script and did it work for you? I'd love to see screen shots of a tunnel in your world.
Lyqyd #11
Posted 30 August 2013 - 01:07 AM
You should state somewhere that this requires OpenPeripherals.
McLeopold #12
Posted 30 August 2013 - 06:38 PM
You should state somewhere that this requires OpenPeripherals.
Is that why the turtle can't find the chest? I guess I thought it was build-in.
Lyqyd #13
Posted 31 August 2013 - 03:14 AM
Chests aren't peripherals in ComputerCraft. OpenPeripheral adds the peripheral interface for them and many other vanilla blocks.
BangPoulsen #14
Posted 23 November 2013 - 08:08 PM
When i start my first turtle, it starts the script, gets some fuel, turn to face in the right direction and then it takes one step forward and then one step back to its original position, where it then stops. The script still seems to be running but nothing happens and i cant place another turtle because the first still stands between chest and disk… what am i doing wrong?