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

Help (Redstone effects)

Started by Doomcraftian, 05 November 2012 - 05:55 AM
Doomcraftian #1
Posted 05 November 2012 - 06:55 AM
I want to make my Melee turtles attack when they detect redstone- please help, I need a step by step guide no 'Start writing a program' stuff because I dont know how to do that, Just tell me what I have to type EXACTLY please help, Thanks.
kazagistar #2
Posted 05 November 2012 - 07:41 AM
SIDE = "back" -- options: front, back, left, right, top, bottom
while true do
	os.pullEvent("redstone")
	if redstone.getInput(SIDE) then
		print("Die scoundrel")
		turtle.attack()
	end
end

I haven't exactly tested it, but it should work. :D/>/>
Doomcraftian #3
Posted 05 November 2012 - 07:57 AM
comes Up with lua:1: attempt to index ? (a nil value)
kazagistar #4
Posted 05 November 2012 - 08:07 AM
You probably put in the side without quotes?
Doomcraftian #5
Posted 05 November 2012 - 08:11 AM
Nope did that too still came up
Doyle3694 #6
Posted 05 November 2012 - 08:39 AM
direction.getInput()? That isn't a command is it?
jag #7
Posted 05 November 2012 - 09:03 AM
direction.getInput()? That isn't a command is it?
Nope it isn't, it's:

redstone.getInput("direction")
-- or in this case
redstone.getInput(SIDE)

-- you could even use the short version of the api
rs.getInput("direction")
rs.getInput(SIDE)
kazagistar #8
Posted 05 November 2012 - 09:49 AM
My bad, haha, I wrote that in my head, but something else came out of the fingers… I edited my original post.