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

Count and print bundled output colours?

Started by 4moneyplz, 09 July 2012 - 02:17 PM
4moneyplz #1
Posted 09 July 2012 - 04:17 PM
Hello,

I just started playing tekkit and searched up all kinds of tutorials on youtube for account/password locks and other stuff,
now I never programmed in my life before and I just copied the code of some kind of Brute force attack from a video,
It works to open easy comination locks, but as it is trying all the possibilities it:

- Doesn't stop when the doors open – hard to code this?
- Doesn't count the possibillities tried,
- Doens't print the possibillities tried..

I'd like to know how to let it at least print all colour combinations it tried so i can see the last ones, when i heared the doors open/close.
For now I'm using lamps with each colour and try to see the combination when the doors open…
I could ofcourse change the delay to have more time but that would make it go very slow for some combinations.

Here's the code I have so far:

========================================
function delay(s)
os.startTimer(s)
while true do
event, param1 = os.pullEvent()
if event == "timer" then break end
end
end

for i=1, 255, 1 do
redstone.setBundledOutput("back", i)
delay(0.5)

end
======================================




Again, I just copied this, I have almost no idea of what actually happens here….
Could someone help me and/or give me feedback on how I did my first post here?

Thnxies :)/>/>


P.S.
I'm not trying to break in somebody's house, I'm just trying to understand all this code, which is new for me and I found this fun to do B)/>/>
OmegaVest #2
Posted 09 July 2012 - 06:31 PM
First: Computers only take in redstone signals. Unless the last wire/dustline has a line coming back to the computer, you cannot make it stop once the door opens.

Further than that, the other two "possibilities" are simple pieces to code that you can actually do if you take a moment to look at the wiki, or the API in game. And, to work out what happens here, start taking lines out. You'll figure out what they do that way.
4moneyplz #3
Posted 10 July 2012 - 10:59 PM
Removed? XD how do I remove a post c_C
4moneyplz #4
Posted 10 July 2012 - 11:12 PM
First: Computers only take in redstone signals. Unless the last wire/dustline has a line coming back to the computer, you cannot make it stop once the door opens.

Further than that, the other two "possibilities" are simple pieces to code that you can actually do if you take a moment to look at the wiki, or the API in game. And, to work out what happens here, start taking lines out. You'll figure out what they do that way.

Okay, thanks!

I've tried removing lines line by line but I'm not totally understanding the logic… :S
And with looking on the wiki or "API"… I don't understand most of it, maybe becauseI'm just 15 and my english isn't that good
(I'm dutch) and I dont know any of these program terms yet
xuma202 #5
Posted 10 July 2012 - 11:13 PM
I've made some comments in the code.


function delay(s)  ---Head of a function
os.startTimer(s)  --Starting a timer that will pull an event after the the given time (s)
while true do	--keep in this loop
  event, param1 = os.pullEvent()
  if event == "timer" then break end  --until the last event that has been pulled was one from the timer started above (timer is finished)
end
end --The end of the function
for i=1, 255, 1 do  --Count the variable i from 1 to 255 in steps of 1
redstone.setBundledOutput("back", i) --Set the bundled redstone output on the back to the variable i. If i is for example 5 it's 101 in binary so the 1st and the 3rd bit is 1 that means the white (1) and the magenta (3) cables are active
delay(0.5) --call the function from the beginning with the parameter s = 0.5
end

EDIT: Why do you double post the same answer?