15 posts
Posted 08 February 2013 - 05:35 AM
I'm trying to make a vault - in tekkit, with a frame door. I have made two programs, one for a triple-password security check(Computer #1), and one for controlling the frame door.(Computer #2)
Comp. 1 will emit a redstone signal to comp. 2, when the passwords have been typed in correctly.
Comp. 2 will then emit bundled cable signal (Orange) twice to open the frame door.
When a redstone signal is apllied under comp. 2, comp. 2 will tell the frame door to close (Bundled white x2)
When i try to my program for comp. 2, i get this error:
door:3: Too long without yeild
Here is a link for the programs::
http://pastebin.com/VP07fH0AI hope someone out there knows a solution, a quick answer will be appreciated! :)/>
8543 posts
Posted 08 February 2013 - 06:45 AM
Split into new topic.
I noticed that you had replied to another post in the New Members Needing to Ask Questions topic. Don't do that.
15 posts
Posted 08 February 2013 - 06:48 AM
Won't do that again :)/>
46 posts
Posted 08 February 2013 - 06:49 AM
What does your third line say in your "door" program? I looked at the pastebin and at that line it says nothing.
8543 posts
Posted 08 February 2013 - 06:52 AM
Thanks. You might try adding a sleep(0) or an os.pullEvent("redstone") to the while loop at the beginning of the second program. The second one just yields for as short a time as possible before continuing, but the second waits for a change in redstone state before continuing. Which you need depends on how your system works. If you're not sure, try the os.pullEvent("redstone") first. If it breaks the program, try the sleep(0). It's better to make it wait as much as possible, as this will be less load on the server.
46 posts
Posted 08 February 2013 - 06:56 AM
As he said above, try making the wait time longer, maybe 3 seconds. So instead of:
function open()
rs.setBundledOutput("right", colors.orange)
sleep(.5)
c = colors.subtract(colors.orange)
rs.setBundledOutput("right", c)
sleep(.5)
end
Try:
function open()
rs.setBundledOutput("right", colors.orange)
sleep(3)
c = colors.subtract(colors.orange)
rs.setBundledOutput("right", c)
sleep(3)
end
Or am I wrong? I probably sound like a nub, I'm new to lua and computercraft :/
15 posts
Posted 08 February 2013 - 07:07 AM
As he said above, try making the wait time longer, maybe 3 seconds. So instead of:
function open()
rs.setBundledOutput("right", colors.orange)
sleep(.5)
c = colors.subtract(colors.orange)
rs.setBundledOutput("right", c)
sleep(.5)
end
Try:
function open()
rs.setBundledOutput("right", colors.orange)
sleep(3)
c = colors.subtract(colors.orange)
rs.setBundledOutput("right", c)
sleep(3)
end
Or am I wrong? I probably sound like a nub, I'm new to lua and computercraft :/
This will make the door use 12 seconds to open, thats a bit too slow XD
15 posts
Posted 08 February 2013 - 07:13 AM
Thanks. You might try adding a sleep(0) or an os.pullEvent("redstone") to the while loop at the beginning of the second program. The second one just yields for as short a time as possible before continuing, but the second waits for a change in redstone state before continuing. Which you need depends on how your system works. If you're not sure, try the os.pullEvent("redstone") first. If it breaks the program, try the sleep(0). It's better to make it wait as much as possible, as this will be less load on the server.
Thanks alot, os.pullEvent("redstone") worked :D/>
I changed the program so there is a little time between the open() and open(), or else it would only open half-way :P/>
Well, this was a positive first experience with this forum :D/>
46 posts
Posted 08 February 2013 - 07:14 AM
Oh wait, now I see what the problem was! I'm a nub for not answering that first… Sigh. Took me a while to find out what was wrong.
This will make the door use 12 seconds to open, thats a bit too slow XD
Well as they say: "Oh no, a creeper is coming! Open the door!"
7508 posts
Location
Australia
Posted 08 February 2013 - 07:15 AM
-snip-
-snip-
Well it was a learning experience for the both of you ;)/> :D/>
15 posts
Posted 08 February 2013 - 07:23 AM
Hmm.. it seems the bundle cable thing I'm doing in function open() and function close() is wrong :/
it's supposed to shut the signal on, then off again, so i can do it twice, but, oh well, I'm new to the colors API, so, anyone have a solution to this? (God thats alot of commas XD)
15 posts
Posted 08 February 2013 - 07:32 AM
Hmm, would using rs.setBundledOutput("right", colors.orange - colors.orange) technically turn the signal off?
46 posts
Posted 08 February 2013 - 07:34 AM
Does your new code look something like:
function open()
os.pullEvent("redstone")
rs.setBundledOutput("right", colors.orange)
sleep(.5)
c = colors.subtract(colors.orange)
rs.setBundledOutput("right", c)
sleep(.5)
end
758 posts
Location
Budapest, Hungary
Posted 08 February 2013 - 07:41 AM
colors.subtract(colors.orange)
I don't think that's a good idea. As far as I know, .subtract requires two or more arguments.
Hmm, would using rs.setBundledOutput("right", colors.orange - colors.orange) technically turn the signal off?
Of course, 0 turns off technically everything :D/>
15 posts
Posted 08 February 2013 - 07:46 AM
So using rs.setBundledOutput("right", 0) would also turn it off? Kinda makes it alot simpler :D/>
758 posts
Location
Budapest, Hungary
Posted 08 February 2013 - 07:47 AM
yup
btw You'll eventually get used to using 1, 2, 4, 8, … instead of colors.*… 1 is colors.white, 2 is colors.orange, and hey 1 + 2 = 3, and 3 is colors.white + colors.orange!
I mean
rs.setBundledOutput("left", 7)
will turn on the white, the magenta and the orange outputs on the left side of the computer.
7508 posts
Location
Australia
Posted 08 February 2013 - 07:53 AM
So using rs.setBundledOutput("right", 0) would also turn it off? Kinda makes it alot simpler :D/>
The only time you would want to do the method you originally had is if other colors would be going along the cable and you wouldn't want them affected. in that cause you would do this
function open()
os.pullEvent("redstone")
local newColor = colors.combine(rs.getBundledInput("right"), colors.orange)
rs.setBundledOutput("right", newColor)
sleep(.5)
newColor = colors.subtract(rs.getBundledInput("right"), colors.orange)
rs.setBundledOutput("right", newColor)
sleep(.5)
end
758 posts
Location
Budapest, Hungary
Posted 08 February 2013 - 07:56 AM
function open()
os.pullEvent("redstone")
local newColor = colors.combine(rs.getBundledInput("right"), colors.orange)
rs.setBundledOutput("right", newColor)
sleep(.5)
newColor = colors.subtract(rs.getBundledInput("right"), colors.orange)
rs.setBundledOutput("right", newColor)
sleep(.5)
end
Hey! That's what I'm using every day on my mutitask OS! (Pretty useful when coroutines think they can just turn off one another's signals…)
7508 posts
Location
Australia
Posted 08 February 2013 - 07:59 AM
Hey! That's what I'm using every day on my mutitask OS! (Pretty useful when coroutines think they can just turn off one another's signals…)
Wasn't it you that was asking how to do it a few days ago and I gave almost that exact solution? o.O
758 posts
Location
Budapest, Hungary
Posted 08 February 2013 - 08:01 AM
No way. I've asked only one question on this forom, and my question revealed a bug with the Command Blocks (Cloudy iterated the operation queue backwards…)
7508 posts
Location
Australia
Posted 08 February 2013 - 08:05 AM
No way. I've asked only one question on this forom, and my question revealed a bug with the Command Blocks (Cloudy iterated the operation queue backwards…)
Ahh ok, must have been someone else with a similar profile picture to you then ( help so many ppl it all becomes a blur now :P/> )