-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.lua
More file actions
57 lines (50 loc) · 1.24 KB
/
util.lua
File metadata and controls
57 lines (50 loc) · 1.24 KB
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
function shallowcopy(t)
local newt = {}
for k,v in pairs(t) do
newt[k] = v
end
return newt
end
function chr(str,i)
return string.sub(str,i,i)
end
function isalpha(c)
local cc = string.byte(c)
return (cc >= string.byte("a") and cc <= string.byte("z")) or (cc >= string.byte("A") and cc <= string.byte("Z"))
end
function isdigit(c)
local cc = string.byte(c)
return (cc >= string.byte("0") and cc <= string.byte("9"))
end
function isnumber(str) --will i ever use this? IDK
return tonumber(str) ~= nil
end
function printTable(tabl)
print("{")
for k,v in pairs(tabl) do
if type(v) == "table" then
print(k,"=")
printTable(v)
else
print(k,"=",v)
end
end
print("}")
end
function string.split(str,splitting)
local encTpos = 1
local encTtable = {""}
while encTpos <= #str do
local encTchr = chr(str,encTpos)
if encTchr == splitting then
encTtable[#encTtable+1] = ""
else
encTtable[#encTtable] = encTtable[#encTtable]..encTchr
end
encTpos = encTpos + 1
end
return encTtable
end
function string.startswith(str,starts)
return string.sub(str,1,#starts) == starts
end