- ComputerCraft | Programmable Computers for Minecraft
- → ViperLordX's Content
ViperLordX's Content
There have been 43 items by ViperLordX (Search limited from 10-February 22)
#245455 Virus Remover (Disk)
Posted by
ViperLordX
on 12 February 2016 - 10:00 PM
in
APIs and Utilities
#245407 Virus Remover (Disk)
Posted by
ViperLordX
on 11 February 2016 - 09:50 PM
in
APIs and Utilities
#245373 Virus Remover (Disk)
Posted by
ViperLordX
on 11 February 2016 - 01:08 PM
in
APIs and Utilities
#245339 Local variables by default
Posted by
ViperLordX
on 11 February 2016 - 01:11 AM
in
APIs and Utilities
local oldload = load
function _G.load(str, arg1, arg2, arg3)
local func,err = oldload(str, arg1, arg2, arg3)
if not (func) then
return func, err
end
local env = getfenv(func)
for k, v in pairs(env) do
_G[k] = v
end
if (env == _G) then
env = {}
end
setmetatable(env, {__index = _G})
setfenv(func, env)
return func,err
end
loadstring = load
#245313 Local variables by default
Posted by
ViperLordX
on 10 February 2016 - 09:40 PM
in
APIs and Utilities
#245307 Local variables by default
Posted by
ViperLordX
on 10 February 2016 - 09:06 PM
in
APIs and Utilities
#245305 Local variables by default
Posted by
ViperLordX
on 10 February 2016 - 08:47 PM
in
APIs and Utilities
local oldload = load
function _G.load(str, arg1, arg2, arg3)
local func,err = oldload(str, arg1, arg2, arg3)
if not (func) then
return func, err
end
local env = getfenv(func)
if (env == _G) then
env = {}
end
setmetatable(env, {__index = _G})
setfenv(func, env)
return func,err
end
loadstring = load
#245243 Local variables by default
Posted by
ViperLordX
on 10 February 2016 - 04:44 AM
in
APIs and Utilities
local oldload = load
function _G.load(str, arg1, arg2, arg3)
local func = oldload(str, arg1, arg2, arg3)
local env = getfenv(func)
if (env == _G) then
env = {}
end
setmetatable(env, {__index = _G, __newindex =
function(table, var, val)
rawset(env, var, val)
end})
return func
end
#245226 java.lang.ArrayIndexOutOfBoundsException at line 5?
Posted by
ViperLordX
on 09 February 2016 - 10:39 PM
in
Ask a Pro
#245223 java.lang.ArrayIndexOutOfBoundsException at line 5?
Posted by
ViperLordX
on 09 February 2016 - 10:36 PM
in
Ask a Pro
args = {...}
if (#args == 1) then
func = loadfile(args[1])
env = {}
setmetatable(env, {__index = _G, __newindex = function(table, val, var) env[var] = val end})
setfenv(func, env)
func()
end
However, when I run it on a simple program,
a = 1 print(a)
It tells me there's an ArrayIndexOutOfBoundsException at line 5 in gman, which is the one setting the metatable on env. Does anyone know why this is happening and how to fix it?
Ah, I found two problems after looking at my code for a while. I got two variables backwards, and I got a stack overflow by doing env[var] = val in the __newindex metamethod.
#237600 Quarantine program not functioning
Posted by
ViperLordX
on 10 November 2015 - 12:00 AM
in
Ask a Pro
#237598 Quarantine program not functioning
Posted by
ViperLordX
on 09 November 2015 - 11:53 PM
in
Ask a Pro
#237475 Quarantine program not functioning
Posted by
ViperLordX
on 08 November 2015 - 07:36 PM
in
Ask a Pro
Oh, does fs.combine() use shell.resolve() so when I do cover() in shell.resolve(), it calls itself recursively?
#237461 Quarantine program not functioning
Posted by
ViperLordX
on 08 November 2015 - 06:50 PM
in
Ask a Pro
#237371 Quarantine program not functioning
Posted by
ViperLordX
on 07 November 2015 - 10:35 PM
in
Ask a Pro
Still not working, getting the same exact error at line 16.
#237336 Quarantine program not functioning
Posted by
ViperLordX
on 07 November 2015 - 06:22 PM
in
Ask a Pro
#237284 Quarantine program not functioning
Posted by
ViperLordX
on 07 November 2015 - 06:18 AM
in
Ask a Pro
local function contains(table, value)
for k, v in pairs(table) do
if (v == value) then
return true;
end
end
return false;
end
function main()
local es = {}
for k, v in pairs(fs) do
es[k] = v
end
allowed = {"rom", "disk[1-6]"}
function cover(file)
file = es.combine(file, "")
file = string.gsub(file, "%.%.", "")
permitted = false
for _, v in pairs(allowed) do
if (string.find(file, v)) then
permitted = true
end
end
if (not (permitted)) then
file = "q/"..file
end
return file
end
function uncover(file)
file = es.combine(file, "")
file = string.gsub(file, "^q/", "")
return file
end
if (not es.exists("q")) then
es.makeDir("q")
end
files = es.list("/")
for k, v in pairs(files) do
if (not (v == "start") and not (v == "q")) then
if (not (es.exists(cover(v)))) then
es.copy(v, cover(v))
end
if (not (es.isReadOnly(v)) and not (v == "q")) then
es.delete(v)
end
end
end
local vfs = {}
function vfs.list(path)
r = es.list(cover(path))
if (path == "") then
r[#r + 1] = "rom"
end
for k, v in pairs(r) do
r[k] = uncover(v)
end
return r
end
function vfs.exists(path)
return es.exists(cover(path))
end
function vfs.isDir(path)
return es.isDir(cover(path))
end
function vfs.isReadOnly(path)
return es.isReadOnly(cover(path))
end
function vfs.getDrive(path)
return es.getDrive(cover(path))
end
function vfs.getSize(path)
return es.getSize(cover(path))
end
function vfs.getFreeSpace(path)
return es.getFreeSpace(cover(path))
end
function vfs.makeDir(path)
es.makeDir(cover(path))
end
function vfs.move(fromPath, toPath)
es.move(cover(fromPath), cover(toPath))
end
function vfs.copy(fromPath, toPath)
es.copy(cover(fromPath), cover(toPath))
end
function vfs.delete(path)
es.delete(cover(path))
end
function vfs.open(path, mode)
return es.open(cover(path), mode)
end
function vfs.find(wildcard)
value = es.find(cover(wildcard))
for k, v in pairs(value) do
value[k] = uncover(v)
end
return value
end
vfs.complete = es.complete
vfs.combine = es.combine
vfs.getName = es.getName
fs = vfs
local hell = {}
function hell.resolve(name)
return hell.resolve(cover(name))
end
function hell.resolveProgram(name)
return hell.resolveProgram(cover(name))
end
setmetatable(hell, {__index = shell})
shell = hell
end
main()
#237283 Quarantine program not functioning
Posted by
ViperLordX
on 07 November 2015 - 05:01 AM
in
Ask a Pro
#237275 Quarantine program not functioning
Posted by
ViperLordX
on 07 November 2015 - 02:55 AM
in
Ask a Pro
#237273 Quarantine program not functioning
Posted by
ViperLordX
on 07 November 2015 - 02:52 AM
in
Ask a Pro
#237271 Quarantine program not functioning
Posted by
ViperLordX
on 07 November 2015 - 02:47 AM
in
Ask a Pro
function shell.resolve(name) return blah.resolve(name) end
#237249 Quarantine program not functioning
Posted by
ViperLordX
on 06 November 2015 - 09:38 PM
in
Ask a Pro
Ok, I tested it, and it only seems to freeze shell, and nothing else. If I use lua to manually overwrite it, then exit lua, the shell freezes. It also happens if I make shell.resolve() return the value of blah.resolve() where blah = shell.
#237248 Quarantine program not functioning
Posted by
ViperLordX
on 06 November 2015 - 09:18 PM
in
Ask a Pro
#237197 Quarantine program not functioning
Posted by
ViperLordX
on 06 November 2015 - 01:03 AM
in
Ask a Pro
function main()
local es = fs
allowed = {"rom", "disk[1-6]"}
function cover(file)
file = es.combine(file, "")
file = file:gsub("%.%.", "")
permitted = false
for _, v in pairs(allowed) do
if (string.find(file, v)) then
permitted = true
end
end
if (not (permitted)) then
file = "q/"..file
end
return file
end
function uncover(file)
file = es.combine(file, "")
file = string.gsub(file, "^q/", "")
return file
end
if (not es.exists("q")) then
es.makeDir("q")
end
files = es.list("/")
for k, v in pairs(files) do
if (not (v == "start") and not (v == "q")) then
if (not (es.exists(cover(v)))) then
es.copy(v, cover(v))
end
if (not (es.isReadOnly(v)) and not (v == "q")) then
es.delete(v)
end
end
end
local vfs = {}
function vfs.list(path)
r = es.list(cover(path))
if (path == "") then
r[#r + 1] = "rom"
end
for k, v in pairs(r) do
r[k] = uncover(v)
end
return r
end
function vfs.exists(path)
return es.exists(cover(path))
end
function vfs.isDir(path)
return es.isDir(cover(path))
end
function vfs.isReadOnly(path)
return es.isReadOnly(cover(path))
end
function vfs.getDrive(path)
return es.getDrive(cover(path))
end
function vfs.getSize(path)
return es.getSize(cover(path))
end
function vfs.getFreeSpace(path)
return es.getFreeSpace(cover(path))
end
function vfs.makeDir(path)
es.makeDir(cover(path))
end
function vfs.move(fromPath, toPath)
es.move(cover(fromPath), cover(toPath))
end
function vfs.copy(fromPath, toPath)
es.copy(cover(fromPath), cover(toPath))
end
function vfs.delete(path)
es.delete(cover(path))
end
function vfs.open(path, mode)
return es.open(cover(path), mode)
end
function vfs.find(wildcard)
value = es.find(cover(wildcard))
for k, v in pairs(value) do
value[k] = uncover(v)
end
return value
end
vfs.complete = es.complete
vfs.combine = es.combine
vfs.getName = es.getName
fs = vfs
end
main()
#221405 Wanted: The Best Community Made Programs To Include In Computercraft. Seeking...
Posted by
ViperLordX
on 14 June 2015 - 09:22 PM
in
Programs
- ComputerCraft | Programmable Computers for Minecraft
- → ViperLordX's Content


