Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Combined Teleport and Artillery Control System
- local modem = peripheral.find("modem") or error("No modem attached", 0)
- local CHANNEL = 15
- modem.open(CHANNEL)
- -- Function to wait for a modem message on a specific channel
- local function receiveMessage()
- local event, _, channel, _, message = os.pullEvent("modem_message")
- if channel == CHANNEL then
- return message
- else
- return receiveMessage()
- end
- end
- local function teleportPlayer(player, x, y, z, dimension)
- if dimension then
- commands.exec(("execute in %s run tp %s %d %d %d"):format(dimension, player, x, y, z))
- else
- commands.exec(("tp %s %d %d %d"):format(player, x, y, z))
- end
- end
- -- Function to summon particles at a given position
- local function summonParticles(x, y, z, dimension)
- for _ = 1, 10 do
- if dimension then
- commands.exec(("execute in %s run particle minecraft:portal %d %d %d 1 1 1 0.1 50"):format(dimension, x, y, z))
- else
- commands.exec(("particle minecraft:portal %d %d %d 1 1 1 0.1 50"):format(x, y, z))
- end
- sleep(0.1) -- Creates a brief delay between particle bursts
- end
- end
- -- Function to add slight randomness to coordinates
- local function addRandomness(coordinate)
- -- Generate random number between -2 and 2
- local randomOffset = math.random(-1, 1)
- -- 60% chance to apply randomness (accuracy simulation)
- if math.random(1, 10) <= 6 then
- return coordinate + randomOffset
- end
- return coordinate
- end
- -- Function to summon TNT in a grid with offset for alternating patterns
- local function summonGrid(size, spacing, targetX, targetY, targetZ, projectileType, iteration)
- local offset = math.floor(size / 2) * spacing
- local patternOffset = (iteration % 2) * (spacing / 2) -- Alternate pattern offset
- for dx = -offset, offset, spacing do
- for dz = -offset, offset, spacing do
- -- Apply alternating offset to create staggered pattern
- local x = targetX + dx + patternOffset
- local z = targetZ + dz + patternOffset
- -- Add randomness to each explosion
- local randomX = addRandomness(x)
- local randomY = addRandomness(targetY)
- local randomZ = addRandomness(z)
- commands.exec(("summon %s %d %d %d {Fuse:100}"):format(projectileType, randomX, randomY, randomZ))
- end
- end
- end
- -- Seed the random number generator
- math.randomseed(os.time())
- term.clear()
- term.setCursorPos(1, 1)
- print("Bastion Network Online!")
- print("Waiting for command...")
- -- Main program loop
- while true do
- local command = receiveMessage()
- if command == "Recall" then
- print("Recalling Player...")
- modem.transmit(43, CHANNEL, "Recalling Player...")
- print("Starting Teleporter")
- os.sleep(2)
- for i = 1, 100 do
- local chargePercent = i
- print("Charging " .. chargePercent .. "%")
- modem.transmit(43, CHANNEL, "Charging " .. chargePercent .. "%")
- sleep(0.05) -- 100 updates over 5 seconds
- end
- -- Teleport the player
- local targetX, targetY, targetZ = -1413, 249, 20, "minecraft:overworld"
- teleportPlayer("Alexr036", targetX, targetY, targetZ, dimension)
- -- Summon teleport particles
- summonParticles(targetX, targetY, targetZ, dimension)
- elseif command == "Teleport" then
- print("Programming Started")
- local positionX = receiveMessage()
- print("Position X: " .. positionX)
- local positionY = receiveMessage()
- print("Position Y: " .. positionY)
- local positionZ = receiveMessage()
- print("Position Z: " .. positionZ)
- local dimension = receiveMessage()
- print("Target Dimension: " .. dimension)
- print("Starting Teleporter")
- os.sleep(2)
- for i = 1, 100 do
- print("Charging " .. i .. "%")
- modem.transmit(43, CHANNEL, "Charging " .. i .. "%")
- sleep(0.05)
- end
- -- Teleport the player across dimensions
- teleportPlayer("Alexr036", positionX, positionY, positionZ, dimension)
- -- Summon teleport particles
- summonParticles(positionX, positionY, positionZ, dimension)
- elseif command == "TNT" or command == "Nuke" or command == "Arrows" then
- print("Artillery System Online")
- modem.transmit(43, CHANNEL, "Artillery System Online")
- local projectileType = command
- local projectilePattern = receiveMessage()
- local iterations = tonumber(receiveMessage())
- local targetX = receiveMessage()
- local targetY = receiveMessage() + 40
- local targetZ = receiveMessage()
- -- Map to Minecraft entities & define spread
- local spread
- if projectileType == "TNT" then
- projectileType = "minecraft:tnt"
- spread = 7
- elseif projectileType == "Nuke" then
- projectileType = "alexscaves:nuclear_bomb"
- spread = 80
- elseif projectileType == "Arrows" then
- projectileType = "minecraft:arrow"
- spread = 12.5
- end
- modem.transmit(43, CHANNEL, "Bombardment Started")
- for i = 1, iterations do
- print("Iteration "..i)
- modem.transmit(43, CHANNEL, "Iteration "..i)
- if projectilePattern == "Spray" then
- local spiralCount = 900 -- Number of spiral steps
- local spacing = 0.5 -- Distance between each arrow
- local dx, dz = 0, 0 -- Current position
- local dirX, dirZ = 1, 0
- local segmentLength = 1
- local stepsTaken = 0
- local segmentPassed = 0
- for i = 1, spiralCount do
- local summonX = targetX + dx * spacing
- local summonZ = targetZ + dz * spacing
- commands.exec(('summon %s %d %d %d {Motion:[0.0,-10.0,0.0],Potion:"minecraft:slowness",Effects:[{Id:2,Amplifier:3,Duration:200},{Id:19,Amplifier:1,Duration:100}]}'):format(projectileType, summonX, targetY, summonZ))
- dx = dx + dirX
- dz = dz + dirZ
- stepsTaken = stepsTaken + 1
- if stepsTaken == segmentLength then
- dirX, dirZ = -dirZ, dirX
- segmentPassed = segmentPassed + 1
- stepsTaken = 0
- if segmentPassed % 2 == 0 then
- segmentLength = segmentLength + 1
- end
- end
- end
- modem.transmit(43, CHANNEL, "Spray Complete")
- elseif projectilePattern == "StabCharge" then
- print("Executing Stab Charge with orbital laser visuals")
- modem.transmit(43, CHANNEL, "Orbital Laser: Stab Charge begun")
- local maxPerLevel = 6
- local beamHeight = 20 -- Height from which the laser descends
- local beamDuration = 15 -- How long the beam particle effect lasts
- local laserParticle = "minecraft:dust 1 0 0 1" -- Bright red beam
- for j = 1, 10 do
- local stabY = targetY - j
- local count = math.ceil((j / 10) * maxPerLevel)
- for k = 1, count do
- local xOff = addRandomness(targetX)
- local zOff = addRandomness(targetZ)
- commands.exec(("particle minecraft:flash %d %d %d 0 0 0 0 1 force"):format(xOff, stabY, zOff))
- commands.exec(("summon %s %d %d %d {Fuse:10,Motion:[0.0,-10.0,0.0]}"):format(
- projectileType, xOff, stabY, zOff))
- end
- sleep(0.1)
- end
- modem.transmit(43, CHANNEL, "Orbital Laser complete")
- else
- -- calculate height variation
- local variationY = (i % 3) * 2
- local iterationY = targetY + variationY
- if projectilePattern == "Single" then
- commands.exec(("summon %s %d %d %d {Fuse:100}"):format(projectileType, targetX, iterationY, targetZ))
- elseif projectilePattern == "2x2" then
- summonGrid(2, spread, targetX, iterationY, targetZ, projectileType, i)
- elseif projectilePattern == "3x3" then
- summonGrid(3, spread, targetX, iterationY, targetZ, projectileType, i)
- elseif projectilePattern == "4x4" then
- summonGrid(4, spread, targetX, iterationY, targetZ, projectileType, i)
- elseif projectilePattern == "5x5" then
- summonGrid(5, spread, targetX, iterationY, targetZ, projectileType, i)
- end
- modem.transmit(43, CHANNEL, "Bombardment Complete")
- end
- os.sleep(0.2)
- end
- elseif command == "Remote Connected" then
- print("Connected to System")
- modem.transmit(43, CHANNEL, "Connected to System")
- else
- print("Unknown command: " .. command)
- modem.transmit(43, CHANNEL, "Unknown command")
- end
- print("Waiting for next command...")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement