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

Need some help with a radio-detonated bomb

Started by Dunel, 15 April 2012 - 04:36 PM
Dunel #1
Posted 15 April 2012 - 06:36 PM
Hi.
I am new to this forum.
I need help with a radio-detonated bomb. Theorethically, I know what to do, but:
1.I don't know how to send a message(fell free to call me a noob :)/>/> ).
2.I don't know if the receiving program works. Here it is.
Spoilerlocal id, cmd = rednet.receive(10)
if cmd == nil then
print
elseif cmd == "boom" then
shell.run("boom")
end

Boom is
redstone.setOutput("bottom", "true")
end

Thanks for any help!
cant_delete_account #2
Posted 15 April 2012 - 07:31 PM
Code (for WIRELESS turtle, put a turtle or mining turtle with a wireless modem in crafting table, name this file 'startup'):

rednet.open("right")
local event, p1, p2, p3, p4, p5 = os.pullEvent()
if event == "rednet_message" and p2 == "boom" then
print("We've received a message from ID #"..p1.."!")
print("The message is:")
print(p2)
print("Message was received from "..p3.." blocks away!")
shell.run("boom")
end

Code (computer with modem on RIGHT side, attach it by holding shift and right clicking on the right side of the computer):
rednet.open("right")
print("Sending message...")
rednet.broadcast("boom")
sleep(0.6)
print("Done!")

Code (for WIRELESS turtle, the same one with the rednet receiver program, put TNT in first slot of turtle):

local times = 4
print("Bombing...")
for ijkl=1,times do
turtle.forward()
end
turtle.select(1)
turtle.placeDown()
rs.setOutput("bottom",true)
sleep(0.1)
rs.setOutput("bottom",false)
for ijkl=1,times do
turtle.back()
end
Kolpa #3
Posted 15 April 2012 - 07:35 PM
Hi.
I am new to this forum.
I need help with a radio-detonated bomb. Theorethically, I know what to do, but:
1.I don't know how to send a message(fell free to call me a noob :)/>/> ).
2.I don't know if the receiving program works. Here it is.
Spoilerlocal id, cmd = rednet.receive(10)
if cmd == nil then
print
elseif cmd == "boom" then
shell.run("boom")
end

Boom is
redstone.setOutput("bottom", "true")
end

Thanks for any help!

for send do:
rednet.open("side of modem")
print("press any key to detonate")
os.pullEvent("key")
rednet.broadcast("boom")

for recieve do:
rednet.open("side of modem")
while true do
id, msg = rednet.receive()
if msg == "boom" then
redstone.setOutput("back", true)
end
end
Kolpa #4
Posted 15 April 2012 - 07:36 PM
Code (for WIRELESS turtle, put a turtle or mining turtle with a wireless modem in crafting table, name this file 'startup'):

rednet.open("right")
local event, p1, p2, p3, p4, p5 = os.pullEvent()
if event == "rednet_message" and p2 == "boom" then
print("We've received a message from ID #"..p1.."!")
print("The message is:")
print(p2)
print("Message was received from "..p3.." blocks away!")
shell.run("boom")
end

Code (computer with modem on RIGHT side, attach it by holding shift and right clicking on the right side of the computer):
rednet.open("right")
print("Sending message...")
rednet.broadcast("boom")
sleep(0.6)
print("Done!")

Code (for WIRELESS turtle, the same one with the rednet receiver program, put TNT in first slot of turtle):

local times = 4
print("Bombing...")
for ijkl=1,times do
turtle.forward()
end
turtle.select(1)
turtle.placeDown()
rs.setOutput("bottom",true)
sleep(0.1)
rs.setOutput("bottom",false)
for ijkl=1,times do
turtle.back()
end

Friggin Ninjas
Dunel #5
Posted 15 April 2012 - 08:59 PM
Thanks, these codes are great :)/>/>!
Edit: Used Kolpa's code, it's great! Thanks, man!
Kolpa #6
Posted 16 April 2012 - 03:25 PM
no problem mate :)/>/>
u can also pm me for further questions :)/>/>