-
Notifications
You must be signed in to change notification settings - Fork 0
/
testbios
122 lines (120 loc) · 2.39 KB
/
testbios
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
local label = "cVM"
os.loadAPI = function(path)
local f, err = loadfile(path)
if not f then
return false, err
end
local env = {}
setmetatable(env, {__index=_G})
setfenv(f, env)
local k, err = pcall(f)
if not k then
return false, err
end
_G[fs.getName(path)] = {}
for k, v in pairs(env) do
_G[fs.getName(path)][k] = v
end
return true
end
os.version = function()
return "cVMWare CraftOS 1.7"
end
os.getComputerID = function()
return 0
end
os.getComputerLabel = function()
return label
end
os.setComputerLabel = function(lbl)
if lbl then
label = lbl
else
label = "cVM"
end
end
_G.write = function(string)
term.write(string)
end
_G.sleep = function(time)
return os.sleep(time)
end
_G.printError = function(string)
local c = term.getTextColor()
term.setTextColor(16384)
print(string)
term.setTextColor(c)
end
function os.run(env, path, ...)
local tArgs = {...}
local func, err = loadfile(path)
if not func then return false, err end
setmetatable(env, {__index = _G})
setfenv(func, env)
return func(unpack(tArgs))
end
os.unloadAPI = function(name)
_G[name] = nil
end
for k, v in pairs(_G) do
term.write(k..":")
end
print("")
print("")
for k, v in ipairs(fs.list("/")) do
print(v)
end
print("Finished BIOS!")
print("NOTE: This is NOT CraftOS, many APIs you know from")
print("stock CC are not existent!!!")
print("Type 'reboot' to reboot this VM")
print("Type 'shutdown' to shut this VM down.")
print("Type 'newFile' to create a file in /")
print("Type 'ls' to list the files in /")
print("Type 'del' to delete a file in /")
while true do
local e = read()
if e == "reboot" then
_vm.reboot()
elseif e == "shutdown" then
_vm.shutdown()
elseif fs.exists(e) and fs.isDir(e) == false then
local a, err = loadfile(e)
if not a then
print(err)
else
local _, err = pcall(a)
if not _ then
print(err)
else
print("Successfully executed!")
end
end
elseif e == "newFile" then
term.write("Name: ")
e = read()
if #e < 1 then
e = "newFile"
end
local file = fs.open(e, "w")
term.write("Text: ")
e = read()
file.writeLine(e)
file.close()
print("Finished!")
elseif e == "ls" then
local list = fs.list("/")
for k, v in ipairs(list) do
print(v)
end
elseif e == "del" then
term.write("Path:")
local e = read()
local ok, err = fs.delete(e.."/")
if ok or err == nil then
print("Finished!")
else
print("Error:"..tostring(err))
end
end
end