-
Notifications
You must be signed in to change notification settings - Fork 0
/
1dc.lua
122 lines (104 loc) · 4.02 KB
/
1dc.lua
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 vars = {}
local print, error = print, error
local line_count = 1
local function wait(s)
local sec = tonumber(os.clock() + s);
while (os.clock() < sec) do
end
end
function main()
for line in io.lines(arg[1]) do
line_count = line_count + 1
for printw, word in line:gmatch("(.-) ([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%d%p%s%z]+)") do
if printw == "p" then
print(word.."\n")
elseif printw == "pwn" then
print(word)
elseif printw == "pv" then
if vars[word] then
print(vars[word])
end
end
end
for vartype, key, value in line:gmatch("(.-) ([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%d%p%s%z]+) = ([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%d%p%s%z]+)") do
if vartype == "int" then
vars[key] = tonumber(value) or error("NOT AN NUMBER")
end
if vartype == "string" then
vars[key] = tostring(value)
end
end
for func, param in line:gmatch("(.-) ([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%d%p%s%z]+)") do
if func == "r" then
local r = io.read()
vars[param] = r
elseif func == "w" then
local is_var = false
if vars[param] then
if type(vars[param]) == "string" then
error "NOT A NUMBER"
end
is_var = true
wait(vars[param]/2+vars[param]/2)
elseif is_var == false then
wait(param/2+param/2)
end
elseif func == "exec" then
local is_var = false
if vars[param] then
is_var = true
os.execute(vars[param])
elseif is_var == false then
os.execute(param)
end
end
end
for filename_r, varname_r in line:gmatch('or ([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%d%p%s%z]+) = ([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%d%p%s%z]+)') do
local is_var = false
if vars[filename_r] then
is_var = true
local f = io.open(vars[filename_r], "r")
local data = f:read("*all")
f:close()
vars[varname_r] = data
elseif is_var == false then
local f = io.open(filename_r, "r")
local data = f:read("*all")
f:close()
vars[varname_r] = data
end
end
for filename_w, towrite in line:gmatch('ow ([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%d%p%s%z]+) = ([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%d%p%s%z]+)') do
local filename_is_var = false
local towrite_is_var = false
if vars[filename_w] then
if vars[towrite] then
towrite_is_var = true
local f = io.open(vars[filename_w], "w")
f:write(vars[towrite])
f:close()
elseif towrite_is_var == false then
filename_is_var = true
local f = io.open(vars[filename_w], "w")
f:write(towrite)
f:close()
end
elseif filename_is_var == false then
if vars[towrite] then
towrite_is_var = true
local f = io.open(filename_w, "w")
f:write(vars[towrite])
f:close()
elseif towrite_is_var == false then
local f = io.open(filename_w, "w")
f:write(towrite)
f:close()
end
end
end
end
end
local ok,err = pcall(main)
if not ok then
print("1DC ERROR "..err)
end