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

Help! Need/help for thsi program

Started by drunkjugernout, 17 May 2015 - 03:25 PM
drunkjugernout #1
Posted 17 May 2015 - 05:25 PM
Hello Guys!

this is my first ever post! i just need a program/help on a program that would allow me to send 5 redstone signal in a certain time in minecraft.
it would be helpful if you guys post a program that did this :D/>.
Lyqyd #2
Posted 17 May 2015 - 05:40 PM
Moved to Ask a Pro.

Check out the wiki page on the redstone API to see how you can set redstone outputs on and off. Also look into the sleep function to see how you can set how long the redstone will be on or off for.
Zenon #3
Posted 17 May 2015 - 08:58 PM
Well, That Depends, Which Ways Are You Trying To Output? And Does It NEED To Come From The Computer, Or Can It Go Into A Repeater?

Regardless, Here's An Example :


rs.setOutput("right", true) --Sets Output On The Right Side to True

OR, If You Wanted To Have Your Code Be More Interactive


term.write("Which Side?: ")  --Prints "Which Side?: " While Allowing You To Type On the Same Line
side = read()
tostring(side) Dont Think This Is Needed
term.write("On Or Off?: ")
on = read()
tostring(on) --Again, Dont Think This Is Needed, But Ive Drawn Errors Before By Not Using It
if on == "on" or on == "On" then --This Says That If The Users Types In "on" OR "On" Then Do The Following
  on = true --Sets On To True
elseif on == "off" or "Off" --Same Thing As The Above Code "If on == on" Code, Only This Time Uses Off
  on == false --Sets On To False
else
  print("I Don't Understand")
  shell.run(program) --This Will Run Your Program Again (Program Here Meaning Whatever You Typed In To Edit This Program(I.E.: edit startup))
end
rs.setOutput(side, on) --Runs Program

That Is Untested, But Should Work. Happy Coding :lol:/>
flaghacker #4
Posted 17 May 2015 - 09:33 PM
I'm sorry for the huge offtopic, but it's something I have been wondering for a little while…
Why do some people start every single word with a capital letter? Are there some languages in which you're supposed to do that? Or am I missing something super obvious here?
Edited on 17 May 2015 - 07:34 PM
KingofGamesYami #5
Posted 18 May 2015 - 12:18 AM
I'm sorry for the huge offtopic, but it's something I have been wondering for a little while…
Why do some people start every single word with a capital letter? Are there some languages in which you're supposed to do that? Or am I missing something super obvious here?

They speak a language where they capitalize differently, not starting every word with a capital, but they don't grasp the correct capitalization for English and capitalize everything. Just in case someone wants to learn, captialization rules.
drunkjugernout #6
Posted 18 May 2015 - 07:10 PM
I need a program that makes the computer automatic sends 5 pulses (on a sertian time of day 2 times) of redstone signal to pistons to open up/ close a gate
Edited on 18 May 2015 - 08:19 PM
Zenon #7
Posted 18 May 2015 - 11:00 PM
I'm sorry for the huge offtopic, but it's something I have been wondering for a little while…
Why do some people start every single word with a capital letter? Are there some languages in which you're supposed to do that? Or am I missing something super obvious here?

They speak a language where they capitalize differently, not starting every word with a capital, but they don't grasp the correct capitalization for English and capitalize everything. Just in case someone wants to learn, captialization rules.


I Fully Grasp The English Language, Its My First Language And I Speak It Fluently (Lol). I Just Capitalize Out Of Habit Because I Did When I Was Younger Haha
Zenon #8
Posted 18 May 2015 - 11:10 PM
I need a program that makes the computer automatic sends 5 pulses (on a sertian time of day 2 times) of redstone signal to pistons to open up/ close a gate

Which Directions? I Can Whip Up A Code If You Need, Otherwise Check Out This Redstone API Wiki Page
KingofGamesYami #9
Posted 18 May 2015 - 11:21 PM
I Fully Grasp The English Language, Its My First Language And I Speak It Fluently (Lol). I Just Capitalize Out Of Habit Because I Did When I Was Younger Haha

Hmm.. It's really irritating (no offence). I was simply stating what I know to be true (it might not apply to you, but other posters who do the same thing).
drunkjugernout #10
Posted 19 May 2015 - 01:50 AM
I need a program that makes the computer automatic sends 5 pulses (on a sertian time of day 2 times) of redstone signal to pistons to open up/ close a gate

Which Directions? I Can Whip Up A Code If You Need, Otherwise Check Out This Redstone API Wiki Page

yes please, i need to send he signals left and right at the same time for 5 times at morning and at dusk send 5 redstone signals behind in minecraft with a delay per signal and have a delay of 4 seconds per signal. btw i want this run automatically and daily (srry about this complex request im use to a different coding program and i have exams coming up)
Zenon #11
Posted 19 May 2015 - 11:01 PM
I need a program that makes the computer automatic sends 5 pulses (on a sertian time of day 2 times) of redstone signal to pistons to open up/ close a gate

Which Directions? I Can Whip Up A Code If You Need, Otherwise Check Out This Redstone API Wiki Page

yes please, i need to send he signals left and right at the same time for 5 times at morning and at dusk send 5 redstone signals behind in minecraft with a delay per signal and have a delay of 4 seconds per signal. btw i want this run automatically and daily (srry about this complex request im use to a different coding program and i have exams coming up)

No Problem At All : D Besides, Not That Complicated
Here's The Code, Need Anything Else Just Ask


function pulse()
for i = 1, 5 do
  rs.setOutput("right", true)
  rs.setOutput("left", true)
  sleep(4)
  rs.setOutput("right", false)
  rs.setOutput("left", false)
  sleep(4)
end
end
local alarm = os.setAlarm(0)
local alarm2 = os.setAlarm(12500)
   while true do
	   local evt, arg = os.pullEvent("alarm")
	   if arg == alarm or arg == alarm2 then
		 pulse()
	   end
   end
\

Again, Untested, But That Above Should Work. Happy Coding : D
Edited on 20 May 2015 - 08:48 PM
drunkjugernout #12
Posted 20 May 2015 - 12:33 AM
I need a program that makes the computer automatic sends 5 pulses (on a sertian time of day 2 times) of redstone signal to pistons to open up/ close a gate

Which Directions? I Can Whip Up A Code If You Need, Otherwise Check Out This Redstone API Wiki Page

yes please, i need to send he signals left and right at the same time for 5 times at morning and at dusk send 5 redstone signals behind in minecraft with a delay per signal and have a delay of 4 seconds per signal. btw i want this run automatically and daily (srry about this complex request im use to a different coding program and i have exams coming up)

No Problem At All : D Besides, Not That Complicated
Here's The Code, Need Anything Else Just Ask


function pulse()
for i = 1, 5 do
  rs.setOutput("right", true)
  rs.setOutput("left", true)
  sleep(4)
end
end
local alarm = os.setAlarm(0)
   while true do
	   local evt, arg = os.pullEvent("alarm")
	   if arg == alarm then
		 pulse()
	   end
   end
\

Again, Untested, But That Above Should Work. Happy Coding : D

can a prograom run a program?
HPWebcamAble #13
Posted 20 May 2015 - 03:46 AM
can a prograom run a program?

Yep, use the shell API


shell.run("filepath") --# Note that it should be a string

This would run the program 'filepath' as if you had typed the name into the computer's shell.

To add arguments:

shell.run("filepath","arg1","arg2")
flaghacker #14
Posted 20 May 2015 - 06:09 AM
That code won't work, add another sleep at the and of the for loop. Otherwise the redstone signal may never be off. (because the ccomputer is too fast)
Zenon #15
Posted 20 May 2015 - 10:47 PM
That code won't work, add another sleep at the and of the for loop. Otherwise the redstone signal may never be off. (because the ccomputer is too fast)

Aaah, Nice Catch. Thanks :P/>