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

Simple destruction

Started by kazagistar, 29 November 2012 - 06:32 AM
kazagistar #1
Posted 29 November 2012 - 07:32 AM
I wrote a simple carpet bombing program, and I took some pictures. If you need something large thoroughly destroyed, and have a stupid amount of explosives lying about, this is the program for you! It has simple command line parameters, and can scale up pretty effectively to whatever explosives you need.

pastebin get 6WsAnk8X carpetbomb
Spoiler


--[[
simple TNT carpet-bombing program (carpetbomb)
by Kazagistar
Do whatever you want with it, no rights reserved, as per WTFPL
(http://sam.zoy.org/wtfpl/COPYING)
]]--


local x, y, density, rounds = ...
assert(x and y and density and rounds, "carpetbomb <xSize> <ySize> [density=4] [rounds=1]")
density=tonumber(density or 4)
rounds=tonumber(rounds or 1)
x=math.floor(tonumber(x)/density)
y=math.floor(tonumber(y)/density)

assert(turtle.getFuelLevel()=="unlimited" or turtle.getFuelLevel() >= (y+1)*x*density*rounds, "I need juice!")
local sum = 0
for i=1,16 do sum=sum+turtle.getItemCount(i) end
assert(sum >= x*y*rounds, "Gimme moar stuff to drop!")

print("Teeheeheehee >:D/>/>/>")

local current = 1
local function drop()
	if turtle.getItemCount(current) == 0 then
		current = current + 1
		assert(current <= 16, "Ran out of boom boom :(/>/>/>")
		return drop()
	end
	turtle.select(current)
	turtle.placeDown()
	rs.setOutput("bottom", true)
	sleep(0)
end
local function forward(distance)
	while distance > 0 do
		turtle.forward()
		distance = distance - 1
	end
end

local left = false
for k=1,rounds do
	for i=1,x do
		drop()
		for j=1,y do
			forward(density)
			drop()
		end
		if i==x then break end
		if left then
			turtle.turnLeft()
			forward(density)
			turtle.turnLeft()
			left = false
		else
			turtle.turnRight()
			forward(density)
			turtle.turnRight()
			left = true
		end
	end
	turtle.turnLeft()
	turtle.turnLeft()
end

Here is an album I made, demonstrating it's full destructive power.
Tiin57 #2
Posted 29 November 2012 - 10:41 AM
Why not try to do some calculations and make it more efficient?