I made this, I posted this in the ComputerCraft topic. It's a t-flip-flop thing. Use with a button.
function clear()
term.clear()
term.setCursorPos(1, 1)
end
clear()
print "T-flip-flop mode. Use this with a button."
write "What side should receive power? "
inputside = read()
write "What side should send power? "
outputside = read()
clear()
print "T-flip-flop mode. Use this with a button."
print "Now ready! Press E to exit."
print("Input: "..inputside..", Output: "..outputside)
waiting = false
while true do
local event,attrib = os.pullEvent()
if event == "redstone" and not waiting and redstone.getInput(inputside) then
waiting = true
if redstone.getInput(outputside) then
redstone.setOutput(outputside, false)
print "The output is no longer powered!"
else
redstone.setOutput(outputside, true)
print "The output is now powered!"
end
sleep(0.9) --A button provides 0.9 seconds of power I think, not 1.
waiting = false
elseif event == "char" and attrib == "e" then
clear()
print "Exiting T-flip-flop mode."
print "Program by ihaveamac. :smile.gif:"
redstone.setOutput(outputside, false)
break
end
end
You can copy&paste into a file.
Basically when you power it, it will change the output to either on or off, depending on what it was before.
Name: Button
Function: Turns on a redstone current for the duration of a button
--Button
--Written by Onionnion
write("Which side? ")
op = read()
if op == "back" then
redstone.setOutput("back", true)
sleep(0.9)
redstone.setOutput("back", false)
elseif op == "front" then
redstone.setOutput("front", true)
sleep(0.9)
redstone.setOutput("front", false)
elseif op == "left" then
redstone.setOutput("left", true)
sleep(0.9)
redstone.setOutput("left", false)
elseif op == "right" then
redstone.setOutput("right", true)
sleep(0.9)
redstone.setOutput("right", false)
elseif op == "bottom" then
redstone.setOutput("bottom", true)
sleep(0.9)
redstone.setOutput("bottom", false)
elseif op == "top" then
redstone.setOutput("top", true)
sleep(0.9)
redstone.setOutput("top", false)
else
write("Incorrect input, try again.\n")
end
Description: Here's a basic button pressing program, just enter which side and press enter. A simple program that beginners can take as an example for basic redstone use in Lua.
i edited it so you can just type "button back"
or any other direction
local tArgs = {...}
if tArgs[1] == "back" then
redstone.setOutput("back", true)
sleep(0.9)
redstone.setOutput("back", false)
elseif tArgs[1] == "front" then
redstone.setOutput("front", true)
sleep(0.9)
redstone.setOutput("front", false)
elseif tArgs[1] == "left" then
redstone.setOutput("left", true)
sleep(0.9)
redstone.setOutput("left", false)
elseif tArgs[1] == "right" then
redstone.setOutput("right", true)
sleep(0.9)
redstone.setOutput("right", false)
elseif tArgs[1] == "bottom" then
redstone.setOutput("bottom", true)
sleep(0.9)
redstone.setOutput("bottom", false)
elseif tArgs[1] == "top" then
redstone.setOutput("top", true)
sleep(0.9)
redstone.setOutput("top", false)
else
write("Incorrect input, try again.\n")
end
I was messing around with this but the stuff entered doesn't change the file. So when I leave the map and come back to it the passwds were reset. Do you know a way to fix this? Other than that the code works perfectly.
Were you really downloading (or rather copy/pasting) my code to test it? Thanks a lot :biggrin.gif::D No, I sadly don't know how to fix that problem. I'm aware of it though, and it has saved me a few times when I forget the password x)
If anyone got a solution, feel free to post it.
Add them to the correct parts of the code and it should work. Also if you're planning to lock a safe/vault, try my program which also saves your data and has many features (2 posts above you!)
This is what I was trying to do but now I'm done now thanks for all your help. It makes it easier when it's a working example Download Safet Deposit Box program
Thanks a lot elrond1369 :smile.gif:
I'll try to add that code to my program.
Thank you your code was also a big help. It gave me something to work off of.
My program is a Safety Deposit Box program. which would be better used in MP. also mine has a banker's password so if someone forgets theirs the banker can use his
If you watch the video I posted above it will show you everthing including how to build a SDB Also the download link is with the video. BTW I didn't post the code for reading and writing to a file. that was 1lann. concerning your loop back problem your better off creating separate files and doing shell.run("filename") like so
file is startup
password = read()
if password == "Password"
then shell.run("menu")
else write("Incorrect Password!") sleep(1) shell.run("startup")
end
Thank you your code was also a big help. It gave me something to work off of.
My program is a Safety Deposit Box program. which would be better used in MP. also mine has a banker's password so if someone forgets theirs the banker can use his
If you watch the video I posted above it will show you everthing including how to build a SDB Also the download link is with the video. BTW I didn't post the code for reading and writing to a file. that was 1lann. concerning your loop back problem your better off creating separate files and doing shell.run("filename") like so
file is startup
password = read()
if password == "Password"
then shell.run("menu")
else write("Incorrect Password!") sleep(1) shell.run("startup")
end
Speaking of multiplayer; I just made a creative multiplayer server :smile.gif: (link) I think I'll begin to use the method of using one file per 'place' in the program. Seems to be less chaotic. Thank you for the tip :biggrin.gif:
Name of program: Fallout 3/NV style 'hackable' terminal Functions: opening doors, with a lot of work. Download link/Copy of code:http://kyoshiku.net/fo3_term.rar A description (Optional):
Terminal to open a single door, in Fallout 3 style.
Top output goes to the door to open it, bottom input for the reset(from a secure room would be good.)
Important! all files must be in the local computer running the program. You can't just dump this one into /roms/programs/. Put them all into the /saves/worldname/computer/#/ for the computer(s) you want it in.
Ehheh. I was just thinking about how one would go about making this, then you post. *looks over code* Huh. If you don't mind, I'm going to integrate this into my personal OS. Though, that'll be after I set up a front bumper of sorts to make this only accessible through a Hack command at my own password screen. Gotta make griefers work to troll me. Though, obviously there would be none on a single-player world. But still, fun.
Hello all.
I am programing a control system for a RP/BC/IC factory, but I`ve hit a "speedbump"..
I am not a experienced Lua coder..
My problem is that I can not seem to make a counter for each of the colors in a bundle with an easy way to check status of the count on each wire.
Can anyone of you good people give me a bump in the right direction?
Here is my pastebin where i will keep my codes My Pastebin
Here is the code. Door Lock
Credits to Hydrogen/TangentDelta and streetstar5 (without hydrogens's code and streetstar5's modifications my door lock program wouldn't have been possible.)
And also here is another code I made for things light the start of railways Terminal
Also if anyone knows how to make spoilers I would appreciate it
EDIT: Without some of these people posts my door lock code wouldn't be the same
Why noone use my function for lock mechanisms?
With read() function roommate can see password over your shoulder and steal your stuff. With my function they will see this instead (of course "Enter password" thing is not part of function, you can set up whatever prompt you want):
Not necessary, you just use read("*"), try it out yourself. That's what I do in my code.
Name of program: BootPassv1.1_02
Functions: Use a password to access your computer when it starts up
Download link/Copy of code: http://pastebin.com/4wqpEBGi
A description (Optional): You must name it "startup" for it to run when the computer first starts up. Save it under %appdata%/.minecraft/saves/WORLDNAME/Computer/COMPUTER ID NUMBER/startup Rename password to whatever you want it to be and have fun :biggrin.gif: Hope you like it
I'm making an os-ish thing (or custom program launcher at least). It'll be the engine for many of my future programs, and its first function was to blow up a mountain. It's therefore named DoomOS Engine.
Here's the code:
term.clear()
term.setCursorPos (1, 1)
print("")
print("--------------------------------------------------")
term.setCursorPos (16, 10)
print(" ---------------")
term.setCursorPos (16, 11)
print("| DoomOS Engine |")
term.setCursorPos (16, 12)
print(" ---------------")
term.setCursorPos (1,20)
print("--------------------------------------------------")
sleep(1)
term.setCursorPos (20, 14)
print("Loading...")
sleep (4)
term.clear()
pos = 1
menu = true
while menu do
term.setCursorPos (1, 5)
print(" -------------")
print("| Calculator |")
print("| Notepad |")
print("| Be awesome |")
print("| 2012 |")
print("| shutdown |")
print(" -------------")
if num == 200 then
pos = pos - 1
end
if num == 208 then
pos = pos + 1
end
if num == 28 then
menu = false
end
if pos > 5 then
pos = 5
elseif pos < 1 then
pos = 1
end
if pos == 1 then
term.setCursorPos (15, 6)
print("<--")
end
if pos == 2 then
term.setCursorPos (15, 7)
print("<--")
end
if pos == 3 then
term.setCursorPos (15, 8)
print("<--")
end
if pos == 4 then
term.setCursorPos (15, 9)
print("<--")
if num == 28 then
sleep(2)
redstone.setOutput("back", true)
sleep (2)
redstone.setOutput("back", false)
end
end
if pos == 5 then
term.setCursorPos (15, 10)
print("<--")
if num == 28 then
os.shutdown()
end
end
type, num = os.pullEvent()
term.clear()
end
I've not programmed in any features yet (except for shut down), only the framework is completed (or at least functional).
Lets include the form too, shall we? Name of program: DoomOS Engine Functions: Custom launcher. Download link/Copy of code: look in the spoiler above A description (Optional): Not completed yet; only the framework is done. No programs programmed in so far.
I'm making an os-ish thing (or custom program launcher at least). It'll be the engine for many of my future programs, and its first function was to blow up a mountain. It's therefore named DoomOS Engine.
Here's the code:
term.clear()
term.setCursorPos (1, 1)
print("")
print("--------------------------------------------------")
term.setCursorPos (16, 10)
print(" ---------------")
term.setCursorPos (16, 11)
print("| DoomOS Engine |")
term.setCursorPos (16, 12)
print(" ---------------")
term.setCursorPos (1,20)
print("--------------------------------------------------")
sleep(1)
term.setCursorPos (20, 14)
print("Loading...")
sleep (4)
term.clear()
pos = 1
menu = true
while menu do
term.setCursorPos (1, 5)
print(" -------------")
print("| Calculator |")
print("| Notepad |")
print("| Be awesome |")
print("| 2012 |")
print("| shutdown |")
print(" -------------")
if num == 200 then
pos = pos - 1
end
if num == 208 then
pos = pos + 1
end
if num == 28 then
menu = false
end
if pos > 5 then
pos = 5
elseif pos < 1 then
pos = 1
end
if pos == 1 then
term.setCursorPos (15, 6)
print("<--")
end
if pos == 2 then
term.setCursorPos (15, 7)
print("<--")
end
if pos == 3 then
term.setCursorPos (15, 8)
print("<--")
end
if pos == 4 then
term.setCursorPos (15, 9)
print("<--")
if num == 28 then
sleep(2)
redstone.setOutput("back", true)
sleep (2)
redstone.setOutput("back", false)
end
end
if pos == 5 then
term.setCursorPos (15, 10)
print("<--")
if num == 28 then
os.shutdown()
end
end
type, num = os.pullEvent()
term.clear()
end
I've not programmed in any features yet (except for shut down), only the framework is completed (or at least functional).
Lets include the form too, shall we? Name of program: DoomOS Engine Functions: Custom launcher. Download link/Copy of code: look in the spoiler above A description (Optional): Not completed yet; only the framework is done. No programs programmed in so far.
Assassin55 is right. As I wrote in the description (I think), It was originally written to set off an explosion :biggrin.gif:
That's why it's named DoomOS too
Assassin55 is right. As I wrote in the description (I think), It was originally written to set off an explosion :biggrin.gif:
That's why it's named DoomOS too
Ok so... If redstone.setBundledOutput("side", "1", true) command turns on the white cable connected to my bundled cable, then what are the other color numbers? There was a post on the second or third page dealing with colors. But from what I see, that changes the numbers. Someone have a list of the default color numbers if there is one?
Nm. Found it. If anyone else needs it here ya go.
White : 1
Orange : 2
magenta : 4
light blue : 8
yellow : 16
lime : 32
pink : 64
grey : 128
light grey : 256
cyan : 512
purple : 1024
blue : 2048
brown : 4096
green : 8192
red : 16384
black : 32768
Basically when you power it, it will change the output to either on or off, depending on what it was before.
i edited it so you can just type "button back"
or any other direction
local tArgs = {...}
if tArgs[1] == "back" then
redstone.setOutput("back", true)
sleep(0.9)
redstone.setOutput("back", false)
elseif tArgs[1] == "front" then
redstone.setOutput("front", true)
sleep(0.9)
redstone.setOutput("front", false)
elseif tArgs[1] == "left" then
redstone.setOutput("left", true)
sleep(0.9)
redstone.setOutput("left", false)
elseif tArgs[1] == "right" then
redstone.setOutput("right", true)
sleep(0.9)
redstone.setOutput("right", false)
elseif tArgs[1] == "bottom" then
redstone.setOutput("bottom", true)
sleep(0.9)
redstone.setOutput("bottom", false)
elseif tArgs[1] == "top" then
redstone.setOutput("top", true)
sleep(0.9)
redstone.setOutput("top", false)
else
write("Incorrect input, try again.\n")
end
Were you really downloading (or rather copy/pasting) my code to test it? Thanks a lot :biggrin.gif::D
No, I sadly don't know how to fix that problem. I'm aware of it though, and it has saved me a few times when I forget the password x)
If anyone got a solution, feel free to post it.
This is what I was trying to do but now I'm done now thanks for all your help. It makes it easier when it's a working example
Download Safet Deposit Box program
Thanks a lot elrond1369 :smile.gif:
I'll try to add that code to my program.
Thank you your code was also a big help. It gave me something to work off of.
My program is a Safety Deposit Box program. which would be better used in MP. also mine has a banker's password so if someone forgets theirs the banker can use his
If you watch the video I posted above it will show you everthing including how to build a SDB Also the download link is with the video. BTW I didn't post the code for reading and writing to a file. that was 1lann. concerning your loop back problem your better off creating separate files and doing shell.run("filename") like so
file is startup
Speaking of multiplayer; I just made a creative multiplayer server :smile.gif: (link)
I think I'll begin to use the method of using one file per 'place' in the program. Seems to be less chaotic. Thank you for the tip :biggrin.gif:
Ehheh. I was just thinking about how one would go about making this, then you post. *looks over code* Huh. If you don't mind, I'm going to integrate this into my personal OS. Though, that'll be after I set up a front bumper of sorts to make this only accessible through a Hack command at my own password screen. Gotta make griefers work to troll me. Though, obviously there would be none on a single-player world. But still, fun.
I am programing a control system for a RP/BC/IC factory, but I`ve hit a "speedbump"..
I am not a experienced Lua coder..
My problem is that I can not seem to make a counter for each of the colors in a bundle with an easy way to check status of the count on each wire.
Can anyone of you good people give me a bump in the right direction?
Pyro
My Pastebin
Here is the code.
Door Lock
Credits to Hydrogen/TangentDelta and streetstar5 (without hydrogens's code and streetstar5's modifications my door lock program wouldn't have been possible.)
And also here is another code I made for things light the start of railways
Terminal
Also if anyone knows how to make spoilers I would appreciate it
EDIT: Without some of these people posts my door lock code wouldn't be the same
Not necessary, you just use read("*"), try it out yourself. That's what I do in my code.
:3
Functions: Use a password to access your computer when it starts up
Download link/Copy of code: http://pastebin.com/4wqpEBGi
A description (Optional): You must name it "startup" for it to run when the computer first starts up. Save it under %appdata%/.minecraft/saves/WORLDNAME/Computer/COMPUTER ID NUMBER/startup Rename password to whatever you want it to be and have fun :biggrin.gif: Hope you like it
Here's the code:
Lets include the form too, shall we?
Name of program: DoomOS Engine
Functions: Custom launcher.
Download link/Copy of code: look in the spoiler above
A description (Optional): Not completed yet; only the framework is done. No programs programmed in so far.
oooo that looks nice. And what does 2012 do? :3
:3
Don't you think that 2012 means a big giant BOOM!!!!!!!!
Assassin55 is right. As I wrote in the description (I think), It was originally written to set off an explosion :biggrin.gif:
That's why it's named DoomOS too
Ahh ok whoops, didn't see that. Cool!
:3
Nm. Found it. If anyone else needs it here ya go.
White : 1
Orange : 2
magenta : 4
light blue : 8
yellow : 16
lime : 32
pink : 64
grey : 128
light grey : 256
cyan : 512
purple : 1024
blue : 2048
brown : 4096
green : 8192
red : 16384
black : 32768