MiM (Minecraft in Minecraft) (One day I'll continue working on this)
Link: MiM (Direct Fire if your having problems - http://www.mediafire...gbppjttghp1vlhr
About:
Minecraft in Minecraft!
Features:
Creates a new font inside your computer directory which you can then copy to your minecraft.jar!
OldVideo:
Spoiler
[media]http://www.youtube.com/watch?v=sYVmooRe4n0[/media]NBS Converter
Link: NBS Converter
About:
Converts .NBS (Note Block Studio) Files into a custom format designed by me.
Tutorial
Link: Tutorial
About:
An Interactive In-Game Tutorial for ComputerCraft
IN-GAME DEBUGGER (Outdated and kinda pointless as of 1.3)
Link: DEBUG
About:
Gives you some information about where and what caused your program to crash.
Usage = debug <programname> <tracebackcount> <args>
Notes/Bugs:
None ATM, need more test cases.
The program will give you detailed information (as much as I can) about your crash.
A FULL traceback is found in the "debugtraceback" file each time you run debug on your program.
PIC In Action!
Spoiler
Random Programs
I am just going to post all kinds of random programs here that I don't deem worthy to make it into my "you should really check out list"
These programs will be labeled, but their usage and such will prolly not be explained. They also might be buggy as I'm just going to go through and copy the
files that I find first.
Pong
Spoiler
-- Pong V1 for ComputerCraft
-- Coded By Casper
-- Have fun and well... idk I was bored.
controlU = 17
controlD = 31
function diffselect()
term.clear()
print "Select Difficulty:"
print "1. LOL"
print "2. Easy"
print "3. Normal"
print "4. Hard"
print "5. Seriously?"
print "6. Change Bindings off of W/Sn"
diff = io.read()
if diff == "5" then gDiff = 500 end
if diff == "4" then gDiff = 300 end
if diff == "3" then gDiff = 100 end
if diff == "2" then gDiff = 50 end
if diff == "1" then gDiff = 10 end
if diff == "6" then
sleep(.5)
print "Press the key you wish to move upwards with."
local event, earg = os.pullEvent()
controlU = earg
sleep(.5)
print "Press the key you wish to move downards with."
local event, earg = os.pullEvent()
controlD = earg
diffselect()
end
end
diffselect()
gRunning = true
playerY = 2
compY = 2
ballY = 10
ballX = 24
ballA = 0
ballS = 12
ballD = -1
gTimer = false
cTimer = 0
playerScore = 0
compScore = 0
function round(num)
under = math.floor(num)
upper = math.floor(num) + 1
underV = -(under - num)
upperV = upper - num
if (upperV > underV) then
return under
else
return upper
end
end
function score()
term.clear()
if ballX <= 1 then
compScore = compScore + 1
term.setCursorPos(16,9)
term.write("Computer SCOOOORES!")
end
if ballX >= 49 then
playerScore = playerScore + 1
term.setCursorPos(16,9)
term.write("Player SCOOOORES!")
end
sleep(2)
if compScore == 5 or playerScore == 5 then
gRunning = false
term.clear()
term.setCursorPos(16,9)
if ballX >= 49 then term.write("Player WIIIINS!") else term.write("Computer WIIIINS!") end
sleep(2)
end
ballY = 10
ballX = 24
ballA = 0
ballS = 12
gTimer = false
cTimer = 0
rnd = math.random(1, 2)
if rnd == 1 then ballD = -1 else ballD = 1 end
end
function moveplayer(earg)
if earg == controlU then playerY = playerY - 1 end
if earg == controlD then playerY = playerY + 1 end
if playerY < 2 then playerY = 2 end
if playerY > 15 then playerY = 15 end
end
function updateangle(ang)
if ang == 0 then
if ballA <= 0 then ballA = ballA - 2 else ballA = ballA + 1 end
end
if ang == 2 then
if ballA <= 0 then ballA = ballA + 2 else ballA = ballA - 1 end
end
term.clear()
print (ang)
print (ballA)
sleep(1)
end
function contact()
if (ballY == playerY and ballX == 3) or (ballY == compY and ballX == 47) then
if ballA <= 0 then ballA = ballA - 1 else ballA = ballA + .6 end
return (true)
end
if (ballY == playerY + 1 and ballX == 3) or (ballY == compY + 1 and ballX == 47) then
if ballA >= 1.25 then ballA = ballA - .45 end
if ballA <= -1.25 then ballA = ballA + .45 end
if ballA <= 0 then ballA = ballA - .35 else ballA = ballA + .35 end
return (true)
end
if (ballY == playerY + 2 and ballX == 3) or (ballY == compY + 2 and ballX == 47) then
if ballA <= 0 then ballA = ballA + 1 else ballA = ballA - .6 end
return (true)
end
return (false)
end
function movecomp()
if ballY > compY + 1 then compY = compY + 1 else compY = compY - 1 end
if compY < 2 then compY = 2 end
if compY > 15 then compY = 15 end
cTimer = false
end
function moveball()
ballX = ballX + ballD
if ballX == 3 and contact() == true then
ballD = 1
ballX = 4
ballS = ballS + (ballS / 3)
end
if ballX == 47 and contact() == true then
ballD = -1
ballX = 46
ballS = ballS + (ballS / 3)
end
if ballX == 1 then score() end
if ballX == 49 then score() end
if ballA >= 1.75 then ballA = ballA - .35 end
if ballA <= -1.75 then ballA = ballA + .35 end
oldbally = ballY
ballY = ballY + round(ballA)
if ballY <= 2 or ballY >= 17 then
ballY = oldbally
ballA = ballA * -1
end
if ballS > 30 then
rnd = math.random(1, 10)
ballS = ballS - rnd
end
gTimer = false
if ballS >= 150 and moved == false then
moved = true
moveball()
end
rnd = math.random(1, gDiff) * .1
cTimer = cTimer + rnd
if cTimer >= 1 then
movecomp()
cTimer = 0
end
moved = false
end
-- 18 x 49
while gRunning do
term.clear()
y = 1
x = 1
-- Print Game Area
while y < 19 do
term.setCursorPos(1,y)
term.write("|")
term.setCursorPos(49,y)
term.write("|")
y = y + 1
end
while x < 50 do
term.setCursorPos(x,1)
term.write("_")
term.setCursorPos(x,18)
term.write("~")
x = x + 1
end
-- Print Paddles
y = 0
while y < 3 do
term.setCursorPos(3,playerY + y)
term.write("]")
term.setCursorPos(47,compY + y)
term.write("[")
y = y + 1
end
-- Print Score
term.setCursorPos(22,9)
term.write(playerScore.." vs "..compScore)
-- Print Ball
term.setCursorPos(ballX,ballY)
term.write("O")
if gTimer == false then
os.startTimer(2 / ballS)
gTimer = true
end
local event, earg = os.pullEvent()
if event == "timer" then
moveball()
end
if event == "key" and earg == 1 then
term.clear()
break
end
if event == "key" then
moveplayer(earg)
end
end
term.clear()
term.setCursorPos(1,1)
Connect HTTP Parser(Original connect program that uses luajava, you could easily convert to HTTP or just rip the parser from it)
Spoiler
local tArgs = { ... }
term.clear()
print "Please use http://"
jURL = luajava.newInstance("java.net.URL", tArgs[1])
jBufferedReader = luajava.newInstance("java.io.BufferedReader",
luajava.newInstance("java.io.InputStreamReader",
jURL:openStream()
)
)
local str = jBufferedReader:readLine()
tLines = {}
a = 1
local file = io.open( "parse", "w" )
while( str ) do
file:write( str .. "n")
str = jBufferedReader:readLine()
end
file:close()
nl = "n"
filename = "parse"
function HTML_ToText (file)
local text
local f=io.open (file)
if f then
text = f:read ("*a")
f:close()
end
text = string.gsub (text,"(<([^>]-)>)",function (str) return str:lower() end)
local devkill=
{
["("..string.char(10)..")"] = " ",
["("..string.char(13)..")"] = " ",
["("..string.char(15)..")"] = "",
["(%s%s+)"]=" ",
}
for pat, res in pairs (devkill) do
text = string.gsub (text, pat, res)
end
text = string.gsub (text, "(<%s*head[^>]*>)", "<head>")
text = string.gsub (text, "(<%s*%/%s*head%s*>)", "</head>")
text = string.gsub (text, "(<head>,*<%/head>)", "")
text = string.gsub (text, "(<%s*script[^>]*>)", "<script>")
text = string.gsub (text, "(<%s*%/%s*script%s*>)", "</script>")
text = string.gsub (text, "(<script>,*<%/script>)", "")
text = string.gsub (text, "(<%s*style[^>]*>)", "<style>")
text = string.gsub (text, "(<%s*%/%s*style%s*>)", "</style>")
text = string.gsub (text, "(<style>.*<%/style>)", "")
text = string.gsub (text, "(<%s*td[^>]*>)","t")
text = string.gsub (text, "(<%s*th[^>]*>)","t")
text = string.gsub (text, "(<%s*br%s*%/%s*>)",nl)
text = string.gsub (text, "(<%s*li%s*%s*>)"," * ")
text = string.gsub (text, "(<%s*/%s*li%s*%s*>)",nl)
text = string.gsub (text, "(<%s*div[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*p[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*tr[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*%/*%s*ul[^>]*>)", nl..nl)
local addresses,c = {},0
text=string.gsub(text,"<%s*a.-href=['"](%S+)['"][^>]*>(.-)<%s*%/*%s*a[^>]->",
function (url,name)
c = c + 1
name = string.gsub (name, "<([^>]-)>","")
if name:find("%w") then print(url, name, c) table.insert (addresses, {url, name}) return name.."["..#addresses.."]" else return "" end
end)
local entities = {}
setmetatable (entities,
{
__newindex = function (tbl, key, value)
key = string.gsub (key, "(%#)" , "%%#")
key = string.gsub (key, "(%&)" , "%%&")
key = string.gsub (key, "(%:P/>/>" , "%%;")
key = string.gsub (key, "(.+)" , "("..key..")")
rawset (tbl, key, value)
end
})
entities =
{
["&nbsp;"] = " ",
["&bull;"] = " * ",
["&lsaquo;"] = "<",
["&rsaquo;"] = ">",
["&trade;"] = "(tm)",
["&frasl;"] = "/",
["&lt;"] = "<",
["&gt;"] = ">",
["&copy;"] = "(c)",
["&reg;"] = "(r)",
["%&.+%;"] = "",
}
for entity, repl in pairs (entities) do
text = string.gsub (text, entity, repl)
end
if #addresses > 0 then
text=text..nl:rep(2)..("-"):rep(2)..nl
for key, tbl in ipairs(addresses) do
text = text..nl.."["..key.."]"..tbl[1]
end
end
return text
end
local f=io.open(filename..".txt", "w")
f:write(HTML_ToText (filename))
f:close()
term.clear()
local tLines = {}
local f=io.open(filename..".txt", "r" )
local sLine = f:read()
while sLine do
table.insert( tLines, sLine )
sLine = f:read()
end
file:close()
table.insert( tLines, "" )
for n, sLine in ipairs( tLines ) do
print (tLines[n])
sleep(.2)
end
shell.run( "rm", "parse" )
print ("File saved in parse.txt")
Send/Receive Files (Before Rednet, I still use variations of these for myself)
Send
Spoiler
term.clear()
if rs.getBundledInput("back") > 0 then
print ("Someone else is currently sending a file across the server.")
end
local tArgs = { ... }
if #tArgs == 0 then
error( "You must include a valid filename." )
end
filename = tArgs[1]
ioline = "back"
if fs.exists(filename) then
print "Sending File Now..."
local function binary(num)
local bin = {}
num = math.floor(num)
repeat
table.insert(bin, num%2)
num = math.floor(num/2)
until num == 0
return table.concat(bin):reverse()
end
if luajava then javaon = true end
function bit(p)
return 2 ^ (p - 1)
end
function hasbit(x, p)
return x % (p + p) >= p
end
function setbit(x, p)
return hasbit(x, p) and x or x + p
end
function clearbit(x, p)
return hasbit(x, p) and x - p or x
end
function getline(line)
_ = 1
bin = 0
while true do
if tonumber(string.sub(line, _, _)) == 1 then bin = setbit(bin, bit(_)) end
_ = _ + 1
if _ > string.len(line) then break end
end
return bin
end
if javaon == true then
sys = luajava.bindClass("java.lang.System")
starttime = sys:currentTimeMillis()
end
lines = {}
chars = {}
y = 1
byteslong = 0
output = ""
file = io.open(filename, "r")
while true do
lines[y] = file:read()
if lines[y] == nil then break end
x = 1
while x < string.len(lines[y]) + 1 do
chars[x] = string.sub(lines[y], x, x)
byteslong = byteslong + 1
tmp = string.byte(chars[x])
tmp = binary(tmp)
tmp = tostring(tmp)
while string.len(tmp) < 8 do
tmp = "0" .. tmp
end
output = output .. tmp
x = x + 1
end
output = output .. "10101101"
byteslong = byteslong + 1
y = y + 1
end
while true do
tmp = string.sub(output,1,16)
out = getline(tmp)
rs.setBundledOutput(ioline, out)
sleep(.05)
if string.len(output) > 16 then
output = string.sub(output,17)
else
break
end
end
rs.setBundledOutput(ioline, 0)
if javaon == true then
timetaken = (sys:currentTimeMillis() - starttime) / 1000
print ("File sent in "..timetaken.." seconds")
print ("File was "..byteslong.." bytes long.")
print ("Thats "..(byteslong / timetaken).." bps")
else
print "Java isn't on or I would tell you how fast that shit flew"
end
file:close()
else
print "You can't send something that doesn't exist dummy."
end
Spoiler
local tArgs = { ... }
if #tArgs == 0 then
error( "You must include a valid filename." )
end
filename = tArgs[1]
ioline = "back"
function bit(p)
return 2 ^ (p - 1)
end
function hasbit(x, p)
return x % (p + p) >= p
end
function setbit(x, p)
return hasbit(x, p) and x or x + p
end
function clearbit(x, p)
return hasbit(x, p) and x - p or x
end
bin = {}
x = 1
while true do
event, param1, param2 = os.pullEvent()
if event == "redstone" then
bin[x] = rs.getBundledInput(ioline)
if bin[x] == 0 then break end
x = x + 1
end
end
total = x - 1
x = 1
tmp1 = ""
tmp2 = ""
output = ""
while true do
a = 1
while true do
if hasbit(bin[x],bit(a)) then
if a <= 8 then tmp1 = tmp1 .. "1" else tmp2 = tmp2 .. "1" end
else
if a <= 8 then tmp1 = tmp1 .. "0" else tmp2 = tmp2 .. "0" end
end
a = a + 1
if a == 17 then break end
end
newl = tonumber("10101101", 2)
tmp1 = tonumber(tmp1, 2)
tmp2 = tonumber(tmp2, 2)
if tmp1 == newl then tmp1 = "n" else tmp1 = string.char(tmp1) end
if tmp2 == newl then tmp2 = "n" else tmp2 = string.char(tmp2) end
output = output .. tmp1 .. tmp2
tmp1 = ""
tmp2 = ""
x = x + 1
if x > total then break end
end
file = io.open(filename, "w")
file:write(output)
file:close()
CCIRC: (ComputerCraft IRC) (Not really outdated, but 1.3 can allow connection to real IRC's through peripherals
Spoiler
Link: CCIRCAbout:
A virtual IRC server that can be used in SSP and SMP
Features:
Almost all the lovely features of a real IRC I can handle.
LuaJava CC Debugger(Requires LuaJava)
Spoiler
sys = luajava.bindClass("java.awt.datatransfer.Clipboard")
frame = luajava.newInstance("java.awt.Frame", "CC Debugger Console")
console = luajava.newInstance("java.awt.TextArea")
buttons_pn = luajava.newInstance("java.awt.Panel")
execute_bt = luajava.newInstance("java.awt.Button", "Run")
clear_bt = luajava.newInstance("java.awt.Button", "Clear")
exit_bt = luajava.newInstance("java.awt.Button", "Quit")
frame:setSize(600,300)
buttons_pn:add(execute_bt)
buttons_pn:add(clear_bt)
buttons_pn:add(exit_bt)
BorderLayout = luajava.bindClass("java.awt.BorderLayout")
frame:add(BorderLayout.NORTH, console)
frame:add(BorderLayout.SOUTH, buttons_pn)
frame:pack()
frame:show()
frame:toFront()
frame:repaint()
execute_cb = {
actionPerformed = function(ev)
_test = loadstring(console:getText())
setfenv( _test, getfenv() )
_test()
end
}
jproxy = luajava.createProxy("java.awt.event.ActionListener",execute_cb)
execute_bt:addActionListener(jproxy)
clear_cb = {actionPerformed= function (ev)
console:setText("");
end
}
jproxy = luajava.createProxy("java.awt.event.ActionListener" ,clear_cb)
clear_bt:addActionListener(jproxy)
exit_cb = { actionPerformed=function (ev)
frame:setVisible(false)
frame:dispose()
end
}
jproxyb = luajava.createProxy("java.awt.event.ActionListener" ,exit_cb)
exit_bt:addActionListener(jproxyb)
close_cb = { }
function close_cb.windowClosing(ev)
frame:setVisible(false)
frame:dispose()
end
function close_cb.windowActivated(ev)
end
jproxy = luajava.createProxy("java.awt.event.WindowListener", close_cb)
frame:addWindowListener(jproxy)
Weee