REGARDING PROGRAM REQUESTS
I will always try to fullfill your requests. So just go ahead and ask!
REGARDING BANNER REQUEST
Started to create animated banners 4everyone. Just post your request(or PM) and I try to do it
Hey guys Wolvan here. I started making some programs/mods and want to publish them in this thread now
COUNTER
API - 2
Programs - 4
Program Modifications - 1
Operating systems - 0
Other - 0
API
Spoiler
Rednet Advanced API 0.4Spoiler
An API that allows you to open and close rednet connections on all sites at once ,print received text on a monitor, detect attached modems and open that side(Not tested, Thx to BigSHinyToys) and gives a simple chat systemView on pastebin.com - Here
Get with cc-get - cc-get install rna
USAGE
Spoiler
rna.openAll() - Opens all sides - returns truerna.closeAll() - Closes all sides - returns true
rna.monitor(side of monitor) - prints a received string on a monitor - returns sender_id, message, true
rna.sr(side of screen - optional) - a loop, sends and receives at the same time. If a side is specified it prints the text on the monitor
rna.sendFile(path, <id>) - Sends a file to a receiving computer(s), id is optional(If not defined -> broadcast), returns (true|false)and "Success" or "File does not exist"
rna.writeIncoming(path, <id>) - Writes a received rednet text to a specified file, id is optional(only accepts text from that PC), returns (true|false)and "Success" or "File exists"
Spoiler
function openModem()
local listOfSides = rs.getSides()
local listofPossibles = {}
local counter1 = 0
while true do
counter1 = counter1 +1
if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then
table.insert(listofPossibles,tostring(listOfSides[counter1]))
end
if counter1 == 6 and table.maxn(listofPossibles) == 0 then
print("no wifi present")
return nil
end
if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
for k,v in pairs(listofPossibles) do
rednet.open(listofPossibles[k])
end
return #listofPossibles
end
end
end
function openAll()
rednet.open("right")
rednet.open("left")
rednet.open("top")
rednet.open("bottom")
rednet.open("front")
rednet.open("back")
return true
end
function closeAll()
rednet.close("right")
rednet.close("left")
rednet.close("top")
rednet.close("bottom")
rednet.close("front")
rednet.close("back")
return true
end
function sendFile(path, id)
if fs.exists(path) then
local file = fs.open(path, "r")
local fileDataString = file.readAll()
if id == nil then
rednet.broadcast(fileDataString)
else
rednet.send(id, fileDataString)
end
return true, "Success"
else
return false, "File does not exist"
end
end
function writeIncoming(path, id)
if fs.exists(path) then
return false, "File exists"
end
if id ~= nil then
while true do
id2, text = rednet.receive()
if id2 == id then
break
end
end
else
id2, text = rednet.receive()
end
file = fs.open(path, "w")
file.write(text)
file.close()
return true, "Success"
end
function monitor(side, msg)
if msg == nil then
sender, msg = rednet.receive()
end
term.redirect(peripheral.wrap(side))
print(msg)
term.restore()
return sender, msg, true
end
function rec(msg2)
if msg2 == nil then
sender, msg2 = rednet.receive()
end
print(msg2)
return sender, msg2, true
end
function sr(screen)
term.clear()
term.setCursorPos(1,1)
parallel.waitForAll(
function()
if screen == nil then
rec()
else
monitor(screen)
end
end,
function()
while true do
if screen == nil then
mess = read()
rednet.broadcast(mess)
else
term.clear()
term.setCursorPos(1,1)
mess = read()
rednet.broadcast(mess)
monitor(screen, mess)
end
end
end)
end
Spoiler
Provides a simple Login system with a pre-made login mask (View the pictures)View on pastebin.com - Here
get with cc-get - cc-get install slapi
Usage
Spoiler
slapi.login(username, password) - Returns success of login(true|false),info("success" if successful/"user" if wrong username/"pass" if wrong pass)slapi.loginmask() - Returns username, password
slapi.getSuccessLogin() - Returns if logged in or not(true|false)
slapi.logout() - Returns true if successful
Spoiler
local success = false
local oldpull = os.pullEvent
os.pullEvent = os.pullEventRaw
local widthRaw, heightRaw = term.getSize()
width = widthRaw / 2
height = heightRaw / 2
function login(user, pass)
term.clear() term.setCursorPos(1,1)
term.setCursorPos(width - 16, 1)
print("|| +----+ / + / +---- +\\")
term.setCursorPos(width - 16, 2)
print("|| | | / | / | | \\")
term.setCursorPos(width - 16, 3)
print("|| | | / |/ +-- | \\")
term.setCursorPos(width - 16, 4)
print("|| | | \\ |\\ | | /")
term.setCursorPos(width - 16, 5)
print("||______ | | \\ | \\ | | /")
term.setCursorPos(width - 16, 6)
print("||______ +----+ \\ + \\ +---- |/")
term.setCursorPos(width - 13, height - 1)
print("+------------------------+")
term.setCursorPos(width - 13, height - 0)
print("| Username: |")
term.setCursorPos(width - 13, height + 1)
print("| Password: |")
term.setCursorPos(width - 13, height + 2)
print("+------------------------+")
term.setCursorPos(width - 1, height - 0)
username = read()
term.setCursorPos(width + 12, height - 0)
write("|")
term.setCursorPos(width - 1, height + 1)
password = read("*")
term.setCursorPos(width + 12, height + 1)
write("|")
term.setCursorPos(1, height + 4)
if username == user then
if password == pass then
success = true
os.pullEvent = oldpull
return success, "success"
else
success = false
os.pullEvent = oldpull
return success, "pass"
end
else
success = false
os.pullEvent = oldpull
return success, "user"
end
end
function logindialog()
term.clear() term.setCursorPos(1,1)
term.setCursorPos(width - 16, 1)
print("|| +----+ / + / +---- +\\")
term.setCursorPos(width - 16, 2)
print("|| | | / | / | | \\")
term.setCursorPos(width - 16, 3)
print("|| | | / |/ +-- | \\")
term.setCursorPos(width - 16, 4)
print("|| | | \\ |\\ | | /")
term.setCursorPos(width - 16, 5)
print("||______ | | \\ | \\ | | /")
term.setCursorPos(width - 16, 6)
print("||______ +----+ \\ + \\ +---- +/")
term.setCursorPos(width - 13, height - 1)
print("+------------------------+")
term.setCursorPos(width - 13, height - 0)
print("| Username: |")
term.setCursorPos(width - 13, height + 1)
print("| Password: |")
term.setCursorPos(width - 13, height + 2)
print("+------------------------+")
term.setCursorPos(width - 1, height - 0)
username = read()
term.setCursorPos(width + 12, height - 0)
write("|")
term.setCursorPos(width - 1, height + 1)
password = read("*")
term.setCursorPos(width + 12, height + 1)
write("|")
term.setCursorPos(1, height + 4)
os.pullEvent = oldpull
return username, password
end
function getSuccessLogin()
return success
end
function logout()
success = false
return true
end
Programs
Spoiler
Keycode ProgramSpoiler
Helps you find they right Number for the pressed keysView on Pastebin.com - Here
Get with cc-get - cc-get install keycode
Spoiler
shell.run("clear")
print("+----------------------------+")
print("| KeyCode Program |")
print("| by Wolvan |")
print("+----------------------------+")
print("Hold CTRL + T to exit")
while true do
event, key = os.pullEvent()
if event == "key" then
term.setCursorPos(1,7)
print("The ID of the pressed key is:")
term.setCursorPos(1,8)
term.clearLine()
term.setCursorPos(1,8)
print(key)
elseif event == "terminate" then
textutils.slowPrint("Exiting program...")
sleep(1)
os.reboot()
end
end
Spoiler
Start it, give in the required information and burn an infite amount of DiskView on pastebin.com - Here
Get on cc-get - cc-get install mdb
Usage:
1. Type in the program you want to burn
2. Type in the filename on the disk
3. Type in the name of the disk
4. Put one disk after another in an attached disk drive
5. Quit with pressing [Q]
Spoiler
path1 = "disk"
program = ""
name = ""
lab = ""
nr = 0
width, height = term.getSize()
hw = math.ceil(width/2)
hh = math.ceil(height/2)
-- Initialize
shell.run("clear")
term.setCursorPos(hw - 9, 1)
print("+----------------+")
term.setCursorPos(hw - 9, 2)
print("|Mass-Disk-Burner|")
term.setCursorPos(hw - 9, 3)
print("| By Wolvan |")
term.setCursorPos(hw - 9, 4)
print("+----------------+")
print("")
print("Please enter the program you want to burn")
write("From: ")
program = read()
print("Please enter the file on the disk")
write("To: ")
name = read()
print("Please enter the label name")
write("Label: ")
lab = read()
shell.run("clear")
print("Waiting for disk...")
print("Press [Q] to exit")
-- Waiting for disk/Burn disk
while true do
event, p1 = os.pullEvent()
if event == "disk" then
shell.run("clear")
print("Disk found! Starting process")
nr = (nr + 1)
path1 = disk.getMountPath(p1)
print("Deleting old versions...")
fs.delete(path1.."/"..name)
print("Burning Disk...")
fs.copy(program, path1.."/"..name)
print("Labeling disk...")
disk.setLabel(p1, lab)
print("Disk Nr."..nr.." burned")
print("")
print("Waiting for disk...")
print("Press [Q] to exit")
disk.eject(p1)
elseif event == "key" then
if p1 == 16 then
print("Stopping Mass-Disk-Burner by Wolvan")
sleep(2)
os.reboot()
end
end
end
Spoiler
Change bootability of your PC's from 1 main PC. Integrated Light Switch and First Time config (Build on mad's Variable API - Integrated)View on Pastebin.com - Client|Controller
Get with cc-get - Client: cc-get install wsc_client | Host: cc-get install wsc_host
Spoiler
Client
Arg = {...}
os.pullEvent=os.pullEventRaw
-- Start of persistent variables
--Copyright (C) 2012 Mads Clausen, Tomoyo Apps http://www.tomoyo.uphero.com
function exists(name)
if fs.exists('.vars/'..name..'.txt') then
return true
end
end
function getType(name)
if exists(name) then
local file = io.open('.vars/'..name..'.txt', 'r')
local line = file:read('*l')
file:close()
return line
else
print('var.getType(): Variable does not exist')
error()
end
end
function getValue(name)
if exists(name) then
if getType(name) ~= 'table' then
local file = io.open('.vars/'..name..'.txt', 'r')
local line = file:read('*l')
line = file:read('*l')
file:close()
if getType(name) == 'number' then
return tonumber(line)
elseif getType(name) == 'string' then
return line
elseif getType(name) == 'boolean' then
if line == 'true' then
return true
elseif line == 'false' then
return false
end
elseif getType(name) == 'nil' then
return nil
end
else
local file = io.open('.vars/'..name..'.txt', 'r')
local line = file:read('*l')
local lines = {}
local returnTable = {}
local i = 1
line = file:read('*l')
while line ~= nil do
lines[i] = line
line = file:read('*l')
i = i + 1
end
for _i = 1, #lines do
local pos = string.find(lines[_i], '_')
local _type = string.sub(lines[_i], 1, pos - 1)
local value = string.sub(lines[_i], pos + 1)
if _type == 'number' then
returnTable[_i] = tonumber(value)
elseif _type == 'string' then
returnTable[_i] = value
elseif _type == 'boolean' then
if value == 'true' then
returnTable[_i] = true
elseif value == 'false' then
returnTable[_i] = false
end
elseif _type == 'nil' then
returnTable[_i] = nil
elseif _type == 'table' then
print('var.getValue(): You cannot have a table inside a table')
end
end
return returnTable
end
else
print('var.getValue(): Variable does not exist')
error()
end
end
function setType(name, _type)
if string.lower(_type) ~= 'number' and string.lower(_type) ~= 'string' and string.lower(_type) ~= 'boolean' and string.lower(_type) ~= 'nil' and string.lower(_type) ~= 'table' and exists(name) then
print('var.setType(): Unsupported type, or the variable already exists')
error()
else
local file = io.open('.vars/'..name..'.txt', 'w')
file:write(_type)
file:close()
end
end
function setValue(name, value)
if exists(name) then
if tostring(type(value)) ~= getType(name) then
print('var.setValue(): Wrong type: '..type(value))
error()
end
if getType(name) ~= 'table' then
local file = io.open('.vars/'..name..'.txt', 'r')
local firstLine = file:read('*l')
file:close()
local file = io.open('.vars/'..name..'.txt', 'w')
file:write(firstLine..'\n'..tostring(value))
file:close()
else
local file = io.open('.vars/'..name..'.txt', 'r')
local firstLine = file:read('*l')
file:close()
local file = io.open('.vars/'..name..'.txt', 'w')
file:write(firstLine..'\n')
for i = 1, #value do
file:write(type(value[i])..'_'..tostring(value[i])..' \n')
end
file:close()
end
else
print('var.setValue(): Variable does not exist')
error()
end
end
function create(name, _type)
if not fs.exists('.vars') then fs.makeDir('.vars') end
if string.lower(_type) ~= 'number' and string.lower(_type) ~= 'string' and string.lower(_type) ~= 'boolean' and string.lower(_type) ~= 'nil' and string.lower(_type) ~= 'table' and exists(name) then
print('var.create(): Unsupported type, or the variable already exists')
error()
else
local file = io.open('.vars/'..name..'.txt', 'w')
file:write(_type)
file:close()
end
end
function delete(name)
if exists(name) then
fs.delete('.vars/'..name..'.txt')
else
print('var.delete(): Variable does not exist')
error()
end
end
-- End of persistant variables
function Use()
print("Use: [FILENAME] <reconf>")
print("<> optional")
end
function FC()
shell.run("clear")
print("Welcome to the First Time Configuration")
if exists("pass") then
print("Please type the password")
write("Password: ")
pass3 = read('*')
if pass3 == getValue("pass") then
shell.run("clear")
writeconf()
else
print("Wrong password")
sleep(2)
os.reboot()
end
else
writeconf()
end
end
function writeconf()
print("")
print("Where is the Redstone-Input located?")
side = read()
print("How's the terminal called?")
write("Name: ")
termn = read()
print("Redstone has to be on to start PC?")
write("y/n: ")
redon = read()
print("Please set a config pass")
write("Password: ")
pass1 = read("*")
write("Confirm: ")
pass2 = read("*")
if pass1 == pass2 then
if redon == "Y" then redon = "y" end
if redon == "N" then redon = "n" end
shell.run("clear")
print("Are these options correct?")
print("")
print("Side: "..side)
print("Name of the terminal: "..termn)
print("Redstone on to start: "..redon)
print("")
write("y/n: ")
confirm = read()
if confirm == "Y" or confirm == "y" then
if exists ("pass") then delete("pass") end
if exists ("fconf") then delete("fconf") end
if exists ("stside") then delete("stside") end
if exists ("stredon") then delete("stredon") end
if exists ("termn") then delete("termn") end
print("Saving config")
create("pass", "string")
create("fconf", "string")
create("stside", "string")
create("stredon", "string")
create("termn", "string")
setValue("stredon", redon)
setValue("stside", side)
setValue("termn", termn)
setValue("pass", pass1)
setValue("fconf", "true")
os.reboot()
else
os.reboot()
end
else
print("Passwords do not match")
sleep(2)
os.reboot()
end
end
if #Arg == 0 then
if exists("fconf") then
if getValue("fconf") == "true" then
shell.run("clear")
if getValue("stredon") == "n" then
print("Welcome to the terminal "..getValue("termn"))
else
if rs.getInput(getValue("stside")) == false then
os.shutdown()
end
print("Welcome to terminal "..getValue("termn"))
end
else
FC()
end
else
FC()
end
elseif #Arg == 1 and Arg[1] == "reconf" then
FC()
else
Use()
end
Controller
os.pullEvent=os.pullEventRaw
width, height = term.getSize()
-- Start of persistent variables
--Copyright (C) 2012 Mads Clausen, Tomoyo Apps http://www.tomoyo.uphero.com
function exists(name)
if fs.exists('.vars/'..name..'.txt') then
return true
end
end
function getType(name)
if exists(name) then
local file = io.open('.vars/'..name..'.txt', 'r')
local line = file:read('*l')
file:close()
return line
else
print('var.getType(): Variable does not exist')
error()
end
end
function getValue(name)
if exists(name) then
if getType(name) ~= 'table' then
local file = io.open('.vars/'..name..'.txt', 'r')
local line = file:read('*l')
line = file:read('*l')
file:close()
if getType(name) == 'number' then
return tonumber(line)
elseif getType(name) == 'string' then
return line
elseif getType(name) == 'boolean' then
if line == 'true' then
return true
elseif line == 'false' then
return false
end
elseif getType(name) == 'nil' then
return nil
end
else
local file = io.open('.vars/'..name..'.txt', 'r')
local line = file:read('*l')
local lines = {}
local returnTable = {}
local i = 1
line = file:read('*l')
while line ~= nil do
lines[i] = line
line = file:read('*l')
i = i + 1
end
for _i = 1, #lines do
local pos = string.find(lines[_i], '_')
local _type = string.sub(lines[_i], 1, pos - 1)
local value = string.sub(lines[_i], pos + 1)
if _type == 'number' then
returnTable[_i] = tonumber(value)
elseif _type == 'string' then
returnTable[_i] = value
elseif _type == 'boolean' then
if value == 'true' then
returnTable[_i] = true
elseif value == 'false' then
returnTable[_i] = false
end
elseif _type == 'nil' then
returnTable[_i] = nil
elseif _type == 'table' then
print('var.getValue(): You cannot have a table inside a table')
end
end
return returnTable
end
else
print('var.getValue(): Variable does not exist')
error()
end
end
function setType(name, _type)
if string.lower(_type) ~= 'number' and string.lower(_type) ~= 'string' and string.lower(_type) ~= 'boolean' and string.lower(_type) ~= 'nil' and string.lower(_type) ~= 'table' and exists(name) then
print('var.setType(): Unsupported type, or the variable already exists')
error()
else
local file = io.open('.vars/'..name..'.txt', 'w')
file:write(_type)
file:close()
end
end
function setValue(name, value)
if exists(name) then
if tostring(type(value)) ~= getType(name) then
print('var.setValue(): Wrong type: '..type(value))
error()
end
if getType(name) ~= 'table' then
local file = io.open('.vars/'..name..'.txt', 'r')
local firstLine = file:read('*l')
file:close()
local file = io.open('.vars/'..name..'.txt', 'w')
file:write(firstLine..'\n'..tostring(value))
file:close()
else
local file = io.open('.vars/'..name..'.txt', 'r')
local firstLine = file:read('*l')
file:close()
local file = io.open('.vars/'..name..'.txt', 'w')
file:write(firstLine..'\n')
for i = 1, #value do
file:write(type(value[i])..'_'..tostring(value[i])..' \n')
end
file:close()
end
else
print('var.setValue(): Variable does not exist')
error()
end
end
function create(name, _type)
if not fs.exists('.vars') then fs.makeDir('.vars') end
if string.lower(_type) ~= 'number' and string.lower(_type) ~= 'string' and string.lower(_type) ~= 'boolean' and string.lower(_type) ~= 'nil' and string.lower(_type) ~= 'table' and exists(name) then
print('var.create(): Unsupported type, or the variable already exists')
error()
else
local file = io.open('.vars/'..name..'.txt', 'w')
file:write(_type)
file:close()
end
end
function delete(name)
if exists(name) then
fs.delete('.vars/'..name..'.txt')
else
print('var.delete(): Variable does not exist')
error()
end
end
-- End of persistant variables
local int = 1
function newi(inp)
if inp == "reset" then
int = 1
elseif inp == "more" then
int = int + 1
if int > 5 then
int = 1
end
elseif inp == "less" then
int = int - 1
if int < 1 then
int = 5
end
end
draw()
end
function fc()
shell.run("clear")
print("Where is the Redstone-Output for the PCs located?")
write("PCs: ")
pcside = read()
print("Where is the Redstone-Output for the Lamps located?")
write("Lamps: ")
lside = read()
print("On logout?")
print("[1]Turn off lamps and disable PCs")
print("[2]PCs and lamps stay the way they are")
write("On logout: ")
onlogout = read()
if onlogout == "1" then onlogout = 1
elseif onlogout == "2" then onlogout = 2
else onlogout = 1 end
print("Set a terminal Login")
write("User: ")
user = read()
write("Password: ")
pass1 = read("*")
write("Confirm: ")
pass2 = read("*")
if pass1 == pass2 then
shell.run("clear")
print("Are these options correct?")
print("")
print("PC-Side: "..pcside)
print("Lamp-Side: "..lside)
write("On Logout: ")
if onlogout == 1 then
print("Turn off everything")
elseif onlogout == 2 then
print("Keep state of devices")
end
print("Username: "..user)
print("")
write("y/n: ")
confirm = read()
if confirm == "Y" or confirm == "y" then
if exists ("pass") then delete("pass") end
if exists ("fconf") then delete("fconf") end
if exists ("pcside") then delete("pcside") end
if exists ("user") then delete("user") end
if exists ("lside") then delete("lside") end
if exists ("logout") then delete("logout") end
print("Saving config")
create("logout", "number")
create("pass", "string")
create("fconf", "string")
create("pcside", "string")
create("user", "string")
create("lside", "string")
setValue("logout", onlogout)
setValue("pcside", pcside)
setValue("lside", lside)
setValue("user", user)
setValue("pass", pass1)
setValue("fconf", "true")
os.reboot()
else
os.reboot()
end
else
print("Passwords do not match")
sleep(2)
os.reboot()
end
end
function draw()
shell.run("clear")
print("What do you want to do?")
print("")
if int == 1 then
print("<Unlock computers>")
print(" Change lights")
print(" Reconfigure")
print(" Show Current State")
print(" Logout")
elseif int == 2 then
print(" Unlock computers")
print("<Change lights>")
print(" Reconfigure")
print(" Show Current State")
print(" Logout")
elseif int == 3 then
print(" Unlock computers")
print(" Change lights")
print("<Reconfigure>")
print(" Show Current State")
print(" Logout")
elseif int == 4 then
print(" Unlock computers")
print(" Change lights")
print(" Reconfigure")
print("<Show Current State>")
print(" Logout")
elseif int == 5 then
print(" Unlock computers")
print(" Change lights")
print(" Reconfigure")
print(" Show Current State")
print("<Logout>")
end
print("")
print("")
print("[UP][DOWN] - Navigate")
print("[ENTER] - Select")
print("[S] - Shutdown the terminal")
listen()
end
function listen()
while true do
event, key = os.pullEventRaw('key')
if key == 200 then
newi('less')
elseif key == 208 then
newi('more')
elseif key == 31 then
os.shutdown()
elseif key == 28 then
domenuentry()
end
end
end
pc = false
function pct()
shell.run("clear")
if pc == false then
print("Activate Computers...")
rs.setOutput(getValue("pcside"), true)
pc = true
print("Booting PCs enabled")
elseif pc == true then
print("Deactivate Computers...")
rs.setOutput(getValue("pcside"), false)
pc = false
print("Booting PCs disabled")
end
sleep(2)
newi("reset")
end
light = false
function tl()
shell.run("clear")
if light == false then
print("Turning on the lights...")
rs.setOutput(getValue("lside"), true)
light = true
elseif light == true then
print("Turning off the Lights...")
rs.setOutput(getValue("lside"), false)
light = false
end
print("Light toggled")
sleep(2)
newi("reset")
end
function show()
shell.run("clear")
print("PC-Side: "..getValue("pcside"))
print("Lamp-Side: "..getValue("lside"))
print("Lamps on: "..tostring(light))
print("PCs active: "..tostring(pc))
write("On logout: ")
if getValue("logout") == 1 then
print("Turn everything off")
elseif getValue("logout") == 2 then
print("Keep State")
end
print("Username: "..getValue("user"))
shell.run("time")
print("Press any key to continiue...")
while true do
event, key = os.pullEventRaw('key')
if key == 1 then
else
newi("reset")
end
end
end
function logout()
if getValue("logout") == 1 then
os.reboot()
elseif getValue("logout") == 2 then
login()
end
end
function domenuentry()
if int == 1 then pct()
elseif int == 2 then tl()
elseif int == 3 then fc()
elseif int == 4 then show()
elseif int == 5 then logout()
end
end
function login()
shell.run("clear")
if exists("fconf") then
term.setCursorPos(width/2 - 12, height/2 - 2)
print("+----------------------+")
term.setCursorPos(width/2 - 12, height/2 - 1)
print("|Username: |")
term.setCursorPos(width/2 - 12, height/2)
print("|Password: |")
term.setCursorPos(width/2 - 12, height/2 + 1)
print("+----------------------+")
term.setCursorPos(width/2 - 1, height/2 - 1)
user = read()
term.setCursorPos(width/2 + 11, height/2 - 1)
write("|")
term.setCursorPos(width/2 - 1, height/2)
pass2 = read("*")
term.setCursorPos(width/2 + 11, height/2)
write("|")
if user == getValue("user") then
if pass2 == getValue("pass") then
newi("reset")
else
print("Wrong password")
sleep(2)
os.reboot()
end
else
print("Wrong username")
sleep(2)
os.reboot()
end
else
fc()
end
end
login()
Spoiler
Control a Stream Player of the Infestation Mod with keys and let the Volume and Currently playing stream get printed on a monitor. Locations of Modems, Screen and Stream Player as well as Stream Names and Stream Links are configurable in the file.View on pastebin.com - Host | Client
get on cc-get - cc-get install mbox
Code
Spoiler
Host
--[[
Change these Settings
]]--
local rnconnect = "left" -- Side of Modem
local player = "right" -- Side of Stream Player
local screen = peripheral.wrap("top") -- Side of Screen
local Stream1 = "[Insert Livestream Link here]" -- Stream URL 1
local Stream2 = "[Insert Livestream Link here]" -- Stream URL 2
local Stream3 = "[Insert Livestream Link here]" -- Stream URL 3
local Stream4 = "[Insert Livestream Link here]" -- Stream URL 4
--[[
Do NOT change these variables
]]--
local on = false
local vol = nil
function init()
rednet.open(rnconnect)
shell.run("clear")
print("CONTROLLER HOST STARTED")
print("Waiting for incoming connections...")
render()
waitForCon()
end
function waitForCon()
while true do
event, id, p1 = os.pullEventRaw("rednet_message")
action(p1)
render()
end
end
function action(p1)
if p1 == "louder" then
vol = streamplayer.getVolume(player)
streamplayer.setVolume(player, vol + 10)
print("System louder")
elseif p1 == "lower" then
vol = streamplayer.getVolume(player)
streamplayer.setVolume(player, vol - 10)
print("System lower")
elseif p1 == "PlayPause" then
if on == true then
streamplayer.off(player)
print("System paused")
on = false
else
streamplayer.on(player)
print("System play")
on = true
end
elseif p1 == "SW1" then
streamplayer.setURL(player, Stream1)
streamplayer.on(player)
print("Setting Stream URL to "..Stream1)
elseif p1 == "SW2" then
streamplayer.setURL(player, Stream2)
print("Setting Stream URL to "..Stream2)
streamplayer.on(player)
elseif p1 == "SW3" then
streamplayer.setURL(player, Stream3)
streamplayer.on(player)
print("Setting Stream URL to "..Stream3)
elseif p1 == "SW4" then
streamplayer.setURL(player, Stream4)
streamplayer.on(player)
print("Setting Stream URL to "..Stream4)
elseif p1 == "render" then
render()
print("Rendering...")
end
end
function render()
term.redirect(screen)
shell.run("clear")
print("Volume: "..streamplayer.getVolume(player))
if on == true then
if streamplayer.getInfoTitle(player) == nil then
print("Now playing Unknown Livestream")
elseif streamplayer.getInfoTitle(player) == "" then
print("Now playing Unknown Livestream")
else
print("Now playing "..streamplayer.getInfoTitle(player))
end
else
print("Not playing")
end
term.restore()
end
init()
Client
--[[
Change these settings
]]--
local rnconnect = "bottom" -- Side of Modem
local Stream1_Name = "[Insert Stream Name here]" -- Display Name of Stream 1
local Stream2_Name = "[Insert Stream Name here]" -- Display Name of Stream 2
local Stream3_Name = "[Insert Stream Name here]" -- Display Name of Stream 3
local Stream4_Name = "[Insert Stream Name here]" -- Display Name of Stream 4
--[[
Do NOT change these variables
]]--
local looper = 0
local p1 = 0
local x = 0
function init()
rednet.open(rnconnect)
control()
keyInput()
end
function control()
shell.run("clear")
print("--Controls--")
print("Up Arrow - Louder")
print("Down Arrow - Lower")
print("Space - Pause/Play")
print("M - Stream Change Menu")
print("R - Reload screen information")
print("Q - Exit the program")
end
function keyInput()
while looper == 0 do
event, p1 = os.pullEventRaw("key")
action(p1)
end
end
function action(p1)
if p1 == 200 then
rs("louder")
elseif p1 == 208 then
rs("lower")
elseif p1 == 57 then
rs("PlayPause")
elseif p1 == 50 then
streammenurender()
elseif p1 == 9996 then
rs("SW1")
elseif p1 == 9997 then
rs("SW2")
elseif p1 == 9998 then
rs("SW3")
elseif p1 == 9999 then
rs("SW4")
elseif p1 == 16 then
print("Goodbye! And thx for using this Program")
sleep(2)
shell.run("clear")
looper = 1
elseif p1 == 19 then
rs("render")
end
end
function streammenurender()
shell.run("clear")
print("1.) "..Stream1_Name)
print("2.) "..Stream2_Name)
print("3.) "..Stream3_Name)
print("4.) "..Stream4_Name)
print("A.) Abort")
print("")
print("Please choose your Stream")
streammenu()
end
function streammenu()
x = 0
while x == 0 do
event, key = os.pullEventRaw("key")
if key == 2 or key == 79 then
p1 = 9996
x = 1
elseif key == 3 or key == 80 then
p1 = 9997
x = 1
elseif key == 4 or key == 81 then
p1 = 9998
x = 1
elseif key == 5 or key == 75 then
p1 = 9999
x = 1
elseif key == 30 then
x = 1
control()
keyInput()
end
action(p1)
control()
end
end
function rs(text)
rednet.broadcast(text)
end
init()
Program Modifications
Spoiler
Dirkus7's Remote Controlled TurtleSpoiler
Control an infinite amount of turtles with one computerView on Pastebin.com - Turtle|Computer
Get with cc-get: Controller: cc-get install remote-turtle_computer | Turtle: cc-get install remote-turtle_turtle
Spoiler
Turtle
shell.run('clear')
print('Turtle-Remote by Dirkus7')
print('Modified by Wolvan')
print('Please type in the ID of the controlling')
print('Computer. Find it out with the Program <ID>')
print('')
write('Host ID: ')
sender = read()
shell.run('clear')
rednet.open("right")
while true do
action, senderID, text = os.pullEvent()
if action == "rednet_message" then
if text == 'drop' then
local int = 0
repeat
turtle.drop()
int = int + 1
until int == 9
int = 0
elseif text == '1' then
turtle.select(1)
elseif text == '2' then
turtle.select(2)
elseif text == '3' then
turtle.select(3)
elseif text == '4' then
turtle.select(4)
elseif text == '5' then
turtle.select(5)
elseif text == '6' then
turtle.select(6)
elseif text == '7' then
turtle.select(7)
elseif text == '8' then
turtle.select(8)
elseif text == '9' then
turtle.select(9)
elseif text == 'forward' then
turtle.forward()
elseif text == 'backward' then
turtle.back()
elseif text == 'stop' then
stop = 'stop'
sleep(0.1)
stop = ''
elseif text == 'left' then
turtle.turnLeft()
elseif text == 'right' then
turtle.turnRight()
elseif text == 'up' then
if turtle.detectUp() then
turtle.digUp()
else
turtle.up()
end
elseif text == 'down2' then
turtle.down()
elseif text == 'down' then
if turtle.detectDown() then
turtle.digDown()
else
turtle.down()
end
elseif text == 'disconnect' then
rednet.close("right")
os.reboot()
elseif text == 'dance' then
print('TURTLE DANCE!')
end
if text == 'dig' then
turtle.dig()
end
if text == 'place' then
turtle.place()
end
if text == 'rs' then
redstone.setOutput('front', true)
end
end
if action=="key" and senderID == sender then
x=0
end
end
Computer
shell.run('clear')
rednet.close("back")
rednet.close("front")
rednet.close("bottom")
rednet.close("top")
rednet.close("left")
rednet.close("right")
print('Computer ID: '..os.getComputerID())
print('Remote-Turtle by Dirkus7')
print('Modified by Wolvan')
print('CONTROLS')
print('W --- Forwards')
print('S --- Backwards')
print('A --- Turn Left')
print('D --- Turn Right')
print('Space --- Dig/Place (Depends on mode)')
print('Left Arrow Key --- Select Dig')
print('Right Arrow Key --- Select Place')
print('Left CTRL --- Enable Redstone Output')
print('Up --- Goes up')
print('Down --- Goes down')
print('1 - 9 --- Select Inventory Slot')
print('T --- Turtle Dancing')
print('V --- Disconnects Turtle, Exit Program')
mode = 0
rednet.open("back")
rednet.open("front")
rednet.open("bottom")
rednet.open("top")
rednet.open("left")
rednet.open("right")
while true do
event, key = os.pullEvent()
shell.run('clear')
if key == 's' then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('backward')
print('Backward')
else
rednet.broadcast('backward')
print('Backward')
end
end
if key == 'a' then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('left')
print('Left')
else
rednet.broadcast('left')
print('Left')
end
end
if key == 'w' then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('forward')
print('Forward')
else
rednet.broadcast('forward')
print('Forward')
end
end
if key == 'd' then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('right')
print('Right')
else
rednet.broadcast('right')
print('Right')
end
end
if key == 200 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('up')
print('Up')
else
rednet.broadcast('up')
print('Up')
end
end
if key == 208 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('down')
print('Down')
else
rednet.broadcast('down')
print('Down')
end
end
if key == 'i' then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('drop')
print('Dropping all stuff')
else
rednet.broadcast('drop')
print('Dropping all stuff')
end
end
if key == '1' or key == 79 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('1')
print('Switch to slot 1')
else
rednet.broadcast('1')
print('Switch to slot 1')
end
end
if key == '2' or key == 80 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('2')
print('Switch to slot 2')
else
rednet.broadcast('2')
print('Switch to slot 2')
end
end
if key == '3' or key == 81 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('3')
print('Switch to slot 3')
else
rednet.broadcast('3')
print('Switch to slot 3')
end
end
if key == '4' or key == 75 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('4')
print('Switch to slot 4')
else
rednet.broadcast('4')
print('Switch to slot 4')
end
end
if key == '5' or key == 76 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('5')
print('Switch to slot 5')
else
rednet.broadcast('5')
print('Switch to slot 5')
end
end
if key == '6' or key == 77 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('6')
print('Switch to slot 6')
else
rednet.broadcast('6')
print('Switch to slot 6')
end
end
if key == '7' or key == 71 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('7')
print('Switch to slot 7')
else
rednet.broadcast('7')
print('Switch to slot 7')
end
end
if key == '8' or key == 72 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('8')
print('Switch to slot 8')
else
rednet.broadcast('8')
print('Switch to slot 8')
end
end
if key == '9' or key == 73 then
if dance == true then
rednet.broadcast('stop')
dance = false
rednet.broadcast('9')
print('Switch to slot 9')
else
rednet.broadcast('9')
print('Switch to slot 9')
end
end
if key == 'v' then
if dance == true then
rednet.broadcast('stop')
dance = false
textutils.slowPrint('Disconnecting all Turtles...')
rednet.broadcast('disconnect')
rednet.close("back")
rednet.close("front")
rednet.close("bottom")
rednet.close("top")
rednet.close("left")
rednet.close("right")
sleep(3)
os.reboot()
else
textutils.slowPrint('Disconnecting all Turtles...')
rednet.broadcast('disconnect')
rednet.close("back")
rednet.close("front")
rednet.close("bottom")
rednet.close("top")
rednet.close("left")
rednet.close("right")
sleep(3)
os.reboot()
end
end
if key == 't' then
local bEnd = false
local updown = 0
print('TURTLE DANCE!')
print('Press any key to exit')
rednet.broadcast('dance')
parallel.waitForAll(
function()
while not bEnd do
local event, key = os.pullEvent("key")
if key ~= 1 then
bEnd = true
end
end
end,
function()
while not bEnd do
local int2 = math.random(1,6)
if int2 == 1 then
rednet.broadcast('forward')
elseif int2 == 2 then
rednet.broadcast('backward')
elseif int2 == 3 then
rednet.broadcast('up')
updown = updown + 1
if updown == 3 then
rednet.broadcast('down2')
updown = updown - 1
end
elseif int2 == 4 then
rednet.broadcast('down2')
updown = updown - 1
elseif int2 == 5 then
rednet.broadcast('left')
elseif int2 == 6 then
rednet.broadcast('right')
else
print('Error')
end
sleep(0.7)
end
end)
bEnd = false
shell.run('clear')
print('Exited')
print('Please type the next command')
end
if key == ' ' then
if mode == 0 then
rednet.broadcast('dig')
print('Dig')
elseif mode == 1 then
rednet.broadcast('place')
print('Place')
end
end
if key == 203 then
mode = 0
print('Dig mode selected.')
end
if key == 205 then
mode = 1
print('Place mode selected.')
end
if key == 29 then
rednet.broadcast('rs')
print('Redstone activated.')
end
end
Operating systems
Spoiler
NONEOther
Spoiler
NONEVideos
Spoiler
NONEScreenshots
Spoiler
KeyCode ProgramSpoiler
Spoiler
Spoiler
Spoiler
Spoiler
Support me/Banners
Spoiler
Add this to your signature as HTML-Code
[url="http://www.computercraft.info/forums2/index.php?/topic/565-apiturtlecomputer13wolvans-programs-count-4more-to-come/"][img]http://img269.imageshack.us/img269/4620/bannerwolvan.gif[/img][/url]
Changelog
Spoiler
* 07/01/2012 ( 01.07.2012 )- Added MediaBox
* 04/10/2012 ( 20.04.2012 )
- Updated RNA to 0.4
- Added new poll
* 04/05/2012 ( 05.04.2012 )
- Added Simple Login API
- Added Pictures of Wolvan's Super Controller
* 03/20/2012 ( 30.03.2012 )
- Changed "Modifications" to "Program Modifications"
- Added Wolvan's Super Controller
- Added cc-get links
* 03/29/2012 ( 29.03.2012 )
- Added Program Request Service
- Added Banner Request Service
- Fixed code ( again )
- Updated RNA to 0.3a
- Fixed an error in RNA 0.3a
* 03/24/2012 ( 24.03.2012 )
- Added a Banner
* 03/20/2012 ( 20.03.2012 )
- Updated Rednet Advanced API to 0.2
* 03/19/2012 ( 19.03.2012 )
- Added MDB
- Added 2 polls