Jump to content




Help! Need/help for thsi program



14 replies to this topic

#1 drunkjugernout

  • Members
  • 4 posts

Posted 17 May 2015 - 04: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.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 17 May 2015 - 04: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.

#3 Zenon

  • Members
  • 50 posts

Posted 17 May 2015 - 07: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:

#4 flaghacker

  • Members
  • 655 posts

Posted 17 May 2015 - 08: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 by flaghacker, 17 May 2015 - 08:34 PM.


#5 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 17 May 2015 - 11:18 PM

View Postflaghacker, on 17 May 2015 - 08:33 PM, said:

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.

#6 drunkjugernout

  • Members
  • 4 posts

Posted 18 May 2015 - 06: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 by drunkjugernout, 18 May 2015 - 09:19 PM.


#7 Zenon

  • Members
  • 50 posts

Posted 18 May 2015 - 10:00 PM

View PostKingofGamesYami, on 17 May 2015 - 11:18 PM, said:

View Postflaghacker, on 17 May 2015 - 08:33 PM, said:

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

#8 Zenon

  • Members
  • 50 posts

Posted 18 May 2015 - 10:10 PM

View Postdrunkjugernout, on 18 May 2015 - 06:10 PM, said:

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

#9 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 18 May 2015 - 10:21 PM

View PosttheMCcm, on 18 May 2015 - 10:00 PM, said:

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).

#10 drunkjugernout

  • Members
  • 4 posts

Posted 19 May 2015 - 12:50 AM

View PosttheMCcm, on 18 May 2015 - 10:10 PM, said:

View Postdrunkjugernout, on 18 May 2015 - 06:10 PM, said:

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)

#11 Zenon

  • Members
  • 50 posts

Posted 19 May 2015 - 10:01 PM

View Postdrunkjugernout, on 19 May 2015 - 12:50 AM, said:

View PosttheMCcm, on 18 May 2015 - 10:10 PM, said:

View Postdrunkjugernout, on 18 May 2015 - 06:10 PM, said:

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 by theMCcm, 20 May 2015 - 09:48 PM.


#12 drunkjugernout

  • Members
  • 4 posts

Posted 19 May 2015 - 11:33 PM

View PosttheMCcm, on 19 May 2015 - 10:01 PM, said:

View Postdrunkjugernout, on 19 May 2015 - 12:50 AM, said:

View PosttheMCcm, on 18 May 2015 - 10:10 PM, said:

View Postdrunkjugernout, on 18 May 2015 - 06:10 PM, said:

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?

#13 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 20 May 2015 - 02:46 AM

View Postdrunkjugernout, on 19 May 2015 - 11:33 PM, said:

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")


#14 flaghacker

  • Members
  • 655 posts

Posted 20 May 2015 - 05: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)

#15 Zenon

  • Members
  • 50 posts

Posted 20 May 2015 - 09:47 PM

View Postflaghacker, on 20 May 2015 - 05:09 AM, said:

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users