This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
tonkku107's profile picture

Tonkku107's programs

Started by tonkku107, 16 May 2013 - 09:39 AM
tonkku107 #1
Posted 16 May 2013 - 11:39 AM
Tonkku107's programs


Hello, Here i'm going to put all my programs.

Table Of Contents:[anchor='Computer']
Computer Programs


You all know the main item of computercraft, the computer. Here's my programs to those

Programs:[Anchor='PassLock']
PassLock

SpoilerContents:[anchor='PLIntro']
Introduction

PassLock is a Lock that needs a password to let you go through a door. It was my first program.

[anchor='PLCode']

The Code

>lock
Spoiler

--[[ PassLock v.2.2 by tonkku107 ]]--

os.pullEvent = os.pullEventRaw

rednet.open("top")
local password = "Pass"
local opentime = 5
local myId = os.computerID()
local done = false
local serverId = 7
local ver = 2.2

function gui()
term.clear()
term.setCursorPos(1,1)
print("PassLock v."..ver)
term.setCursorPos(1,3)
end

while done == false do
gui()
write("Password: ")
local input = read("*")
if input == "AdminPass" then
  gui()
  textutils.slowPrint("Access Granted!")
  sleep(2)
  rednet.close("top")
  term.clear()
  term.setCursorPos(1,1)
  print("CraftOS 1.5")
  done = true
else
  rednet.send(serverId,input)
  senderId,message,distance = rednet.receive(5)
  if senderId == serverId then
   if message == "Valid" then
	gui()
		print("Password Correct!")
		rs.setOutput("back",true)
		sleep(5)
		rs.setOutput("back",false)
		os.shutdown()
   else
	gui()
		print("Password Incorrect!")
		sleep(2)
		os.shutdown()
   end
end
end
end

>Lock without rednet
Spoiler

os.pullEvent = os.pullEventRaw

local password = "Pass"
local opentime = 5
local done = false
local ver = 2.0

function gui()
term.clear()
term.setCursorPos(1,1)
print("PassLock v."..ver)
term.setCursorPos(1,3)
end

while done == false do
gui()
write("Password: ")
local input = read("*")
if input == password then
  term.clear()
  term.setCursorPos(1,1)
  print("PassLock v. 2,0")
  term.setCursorPos(1,3)
  print("Password Correct!")
  rs.setOutput("back",true)
  sleep(opentime)
  rs.setOutput("back",false)
  os.shutdown()
elseif input == "AdminPass" then
  gui()
  print("Access Granted!")
  sleep(2)
  term.clear()
  term.setCursorPos(1,1)
  done = true
else
  gui()
  print("Password Incorrect!")
  sleep(2)
  os.shutdown()
end
end

>Exit
Spoiler

os.pullEvent = os.pullEventRaw

local door = "exit"
local serverId = 7
local myId = os.computerID()
local ver = 2.2
local done = false

function gui()
term.clear()
term.setCursorPos(1,1)
print("PassLock v."..ver)
term.setCursorPos(1,3)
end

rednet.open("top")
while done == false do
gui()
write("Press enter to open the door...")
io.read()
rednet.send(serverId,door)
   senderId,message,distance = rednet.receive(5)
   if senderId == serverId then
	if message == "Valid" then
	 gui()
	 write("Door open!")
	 rs.setOutput("back",true)
	 sleep(5)
	 rs.setOutput("back",false)
	 os.shutdown()
	else
	os.shutdown()
	end
   end
end

>Exit without Rednet
Spoiler

os.pullEvent = os.pullEventRaw

local ver = 2.0
local done = false

function gui()
term.clear()
term.setCursorPos(1,1)
print("PassLock v."..ver)
term.setCursorPos(1,3)
end

while done == false do
gui()
write("Press enter to open the door...")
io.read()
	 gui()
	 write("Door open!")
	 rs.setOutput("back",true)
	 sleep(5)
	 rs.setOutput("back",false)
	 os.shutdown()
	else
	os.shutdown()
	end
   end
end

[Anchor='PLVideo']

Videos

No videos available

[Anchor='PLScreen']

Screenshots

Spoiler>Starting Screen


>No one will see your input


>Correct screen


>Local / Admin Password Correct


>Incorrect

[anchor='PLDL']
Download

Pastebin:
PassLock, PassLock without rednet, PassLock exit, PassLock exit without rednet
In Game:
PassLock:
pastebin get xqnd5Jg2 lock

PassLock without rednet:
pastebin get 4P78Gf8c lock

PassLock exit:
pastebin get VMR0bxk1 exit

PassLock exit without rednet:
pastebin get gsR45nzu exit


[anchor='PLCredits']





Credits

Me - for doing the code, all myself (and with alot of youtube tutorials of CCLua)


[Anchor='Turtle']






Turtle Programs




Here is the programs for these nice little moving turtles

Programs:[anchor='Cobble_Turtle']
Cobble Turtle

SpoilerContents:[anchor='CBIntro']
Introduction

This program makes a turtle mine cobblestone in front of a cobblestone generator.

You can decide how much it will mine.

-1 will mine forever, but it can be terminated!


[anchor='CBCode']
The Code

>cobble
Spoiler

--[[ Cobble Turtle by Tonkku107 ]]--

local mined = 0
local amount = false

function dropItems()
	turtle.turnRight()
	turtle.turnRight()
	print("Dropping Items...")
	for i = 1, 16 do
		turtle.select(i)
		turtle.drop()
	end
	turtle.select(1)
	print("Dropped!")
	turtle.turnRight()
	turtle.turnRight()
end

write("Amount of cobblestone: ")
repeat
		amount = tonumber(read())
		if not amount then
				write("I need a number: ")
		end
until amount

print("Amount set to " .. tostring(amount))

repeat
		if turtle.dig() then
		 print("Mined!")
				mined = mined + 1
		end
		sleep(0.2)
		local full = true
for i = 1, 16 do
	full = (turtle.getItemSpace(i) == 0) and full
end
if full then
	print("Inventory is full!")
	dropItems()
end
until amount == mined
print("Successfully mined "..mined.." cobblestone!")
	dropItems()

[anchor='CBVideos']
Videos

Coming Soon!

[anchor='CBScreen']
Screenshots

Spoiler>Starting


>It doing it's job


>After it's done


>Dropping items to the chest behind it

[anchor='CBDL']
Download

Pastebin:
Cobble Turtle
In Game:
Cobble Turtle:

Pastebin get gCmW5pS9 cobble

[anchor='CBCredits']





Credits

Me - The Code… Atleast a little bit, idea
LBPHacker - Helping alot!

[anchor='Ideas']





Ideas for Programs?

Have any ideas for programs i could make? Tell me! Post into this topic, or Contact me other ways, such as skype.
I'm such a noob in coding, but it would be great if new ideas make me learn :)/>/>
Edited on 05 January 2015 - 01:28 PM
Zudo #2
Posted 22 May 2013 - 01:56 AM
Looks OK, but PLEASE put the actual program section in spoilers to shrink down the post.
tonkku107 #3
Posted 23 May 2013 - 11:50 AM
Looks OK, but PLEASE put the actual program section in spoilers to shrink down the post.
Done! why is there a empty space? Fixed!
tonkku107 #4
Posted 23 May 2013 - 12:47 PM
Added the Cobble Turtle Program!
Link
superaxander #5
Posted 25 May 2013 - 01:28 AM
Nice programs but can please take another color. Cyan is not good readable
tonkku107 #6
Posted 25 May 2013 - 03:59 AM
Nice programs but can please take another color. Cyan is not good readable
what would be a better colour?
theoriginalbit #7
Posted 25 May 2013 - 04:06 AM
what would be a better colour?
Black.
tonkku107 #8
Posted 25 May 2013 - 07:17 AM
what would be a better colour?
Black.
Black Is Boring, but ok
superaxander #9
Posted 25 May 2013 - 07:20 AM
Ah now I can read what it says thanks
tonkku107 #10
Posted 25 May 2013 - 07:22 AM
Ah now I can read what it says thanks
:D/> lol is there any better colors than balck :P/>
superaxander #11
Posted 25 May 2013 - 07:24 AM
Purple?
theoriginalbit #12
Posted 25 May 2013 - 07:25 AM
:D/> lol is there any better colors than balck :P/>
Anything dark or darker shades really.
tonkku107 #13
Posted 25 May 2013 - 07:26 AM
:D/> lol is there any better colors than balck :P/>
Anything dark or darker shades really.
Like This?
Or This?
Purple?
eww… I hate purple :P/>
superaxander #14
Posted 25 May 2013 - 07:27 AM
I like blue more but red is good too
tonkku107 #15
Posted 25 May 2013 - 07:28 AM
I like blue more but red is good too
Blue is my favorite, i think i will use it
tonkku107 #16
Posted 29 May 2013 - 10:36 AM
added screenshots to Cobble Turtle. Link