7 posts
Posted 15 May 2016 - 08:00 PM
Hello
I am in a militaristic server, and I built a gate on a road. I wanted to use the FiMa Coder's Security system as a way to open the gate from the outside. To open the gate from the inside, I wanted there to be pressure plates on the road that detected the car and opened the gate. Basically, I tried to do this first testing it at the bottom of the main code of the security system, and then at the top:
while true do
while redstone.getInput("bottom") do
shell.run("pass")
end
end
The "pass" program was:
redstone.setOutput("left", false)
sleep(13)
redstone.setOutput("left", true)
shell.run("lock")
"lock" is the main code for the security system. Here is the pastebin for the security system: pastebin run QK7CpYFT
The original code made it so that when you input the right code, it would output a redstone signal, but I edited "lock" so that it would output a redstone signal, then when the right code was entered, it would disable the signal, opening the gate. Ty for reading and for maybe helping me solve this!
3057 posts
Location
United States of America
Posted 15 May 2016 - 09:54 PM
Could you describe what issues you are having with it, and which edits you tried to make it work?
7 posts
Posted 15 May 2016 - 09:58 PM
Well, in "lock", wherever it said "rs.setOutput("redstoneSide", false) I put true and where the function for the correct code was I switched rs.setOutput("redstoneSide", true) to false and did:
rs.setOutput("redstoneSide", false)
sleep(13)
rs.setOutput("redstoneSide", true)
end
And then for the shell.run thing I tried was explained above and when I did it it crashed the pc. It wasn't responding to terminate and when I forced shutdown and re-clicked on it it wouldn't start.
7083 posts
Location
Tasmania (AU)
Posted 16 May 2016 - 01:47 AM
When you tell one script to run another, the former isn't unloaded from memory - it stays there, waiting for the latter to finish, and then it continues from where it left off.
If you construct a "loop" out of two scripts forever running each other, eventually you've got so many copies of these scripts running that the computer will crash. So don't do that!
local myTimer
while true do
local event, parameter = os.pullEvent()
if event == "redstone" then
if rs.getInput("bottom") then
rs.setOutput("left", false)
else
myTimer = os.startTimer(13)
end
elseif event == "timer" and parameter == myTimer and not rs.getInput("bottom") then
rs.setOutput("left", true)
end
end
See
os.pullEvent() and
os.startTimer() for more info.
7 posts
Posted 16 May 2016 - 02:07 AM
Bomb Bloke, thank you for the edited code! Where do I put it? Do I put it in "lock" or in it's own separate program? I'll try putting it in lock and see what happens, but plz reply on where exactly to put it.
7083 posts
Location
Tasmania (AU)
Posted 16 May 2016 - 02:33 AM
I'd just stick it in the "startup" file of the system managing the pressure plate. Use a different computer to manage the "keypad".
7 posts
Posted 16 May 2016 - 01:08 PM
Bomb Bloke, the problem with 2 computers is 1 computer can't shut the gate if the other is telling the gate to stay closed. Remember how I said I changed the program so that it always had the redstone signal on true and when the code was input, then it would turn off, opening the gate? I can't open the gate with another computer if the first computer is telling it to stay closed. Any ideas?
7083 posts
Location
Tasmania (AU)
Posted 16 May 2016 - 03:44 PM
One option is to stick an AND gate inbetween the two computers and the gate. Another is to rig the keypad system to output a pulse to the same wire the pressure plate's connected to whenever it wants the door open.
7 posts
Posted 16 May 2016 - 04:06 PM
Lemme try the second one, that I think I can get to work. I'll get back to you here.
Actually the second one won't work because of the first computer always outputting a redstone signal, but I think I just brainstormed the fix in my head. If I remove all redstone.setOutputs from the lock computer and put redstone.setOutput on the second computer that the redstone from the pressure plate is going in, what if I made it so that if the redstone came from the front (The pressure plates) or the top (the lock system) then it would open? I'll try and code it and get back here with any problems or the solution
7 posts
Posted 16 May 2016 - 05:59 PM
Ok, so it works, but the problem is: sometimes the redstone outputs don't output. So I have gates not opening, gates not closing once opened, and only half of the gate opening. For the gate I am using Tinkers' Mechworks' Drawbridges, the first tier out of 3. I'll test the other 2 in creative mode to see if they have any redstone options, but how do I fix the outputs not working?
7 posts
Posted 16 May 2016 - 10:06 PM
Ok idk how I fixed it but I ended up fixing it. It outputs everytime and as for the only opening the bottom part of the gate it only does it occassionally. TY all for your help :)/>