Ranking
Original Post
Lua Script Programming Help
Hey making a script for the Minecraft Modpack ComputerCraft and I need help with one of my programs that are not working. Basically I need it to repeat the following code 576 times:
Pulse Script code:
rs.setOutput("back, true")

sleep(0.1)

rs.setoOutput("back, false")

One of my friends sent me a program but it didn't work:
Repeater Script code:
while true do print("Enter Password") password = "Fire" if read() == password then print("Access Granted") for x = 1,10 do rs.setOutput("back", true) sleep(.1) rs.setOutput("back", false) end else print("Access Denied") sleep(1) end

Any ideas on how to fix the program above or any suggestions on a new script I should use?
| Leader of FC | Loans | ABD Enthusiast |
I really cannot process that info :3 Just tell me how pls or fix my script or make a new one? :3
| Leader of FC | Loans | ABD Enthusiast |
i`m not a lua coder but for what i got from the documentation try this out:
code:
for i = 0, 576, 1 do
rs.setOutput("back, true")
sleep(0.1)
rs.setoOutput("back, false")
end
^Very good!


Using a different method, which is based on the same mechanism your friend's code was using:
LUA code:
   i = 0
while i <= 576 do
rs.setOutput("back, true")
sleep(0.1)
rs.setoOutput("back, false")
i = i + 1
end
Last edited by ynvaser; Sep 18, 2014 at 12:38 AM.
Thanks guys but which one should I use? Is the 2nd code just longer for no reason but made for the sole purpose of making a code with my friend's mechanism?
| Leader of FC | Loans | ABD Enthusiast |
Originally Posted by ZENBOY123 View Post
Thanks guys but which one should I use? Is the 2nd code just longer for no reason but made for the sole purpose of making a code with my friend's mechanism?

It's just illustrating another way to do it.
<Faint> the rules have been stated quite clearly 3 times now from high staff
Well i'll take the shorter code :3 (Iraven's Code) XD
-----
Thanks for the help guys! I'm glad I didn't have to write those 3 lines of code 576 times O_O
Last edited by Merc; Sep 18, 2014 at 11:00 AM. Reason: <24 hour edit/bump
| Leader of FC | Loans | ABD Enthusiast |
Um the shorter one didn't work for Computer Craft...I'll check the 2nd one but any idea why? Keep in mind i'm coding a script in a MC Modpack to make a redstone pulse.