Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Custom loadstring(In progress,have to make) -.-
- function runstring(string)
- local create = function(text)
- local t
- local type
- local vars = {}
- if string.sub(text,1,1) == [=["]=] then
- t = ""
- for i = 1,#text-1 do
- if i ~= 1 then
- local n = string.sub(text,i,i)
- if n ~= [["]] then
- t = t..n
- else
- table.insert(vars,t)
- t = nil
- break
- end
- end
- end
- end
- return unpack(vars)
- end
- local newtype = function(text)
- local n = {}
- local s = ""
- local rec
- for i = 1,#text+1 do
- local r = string.sub(text,i,i)
- if r:match("%w") then
- print(r)
- s = s ..r
- elseif r == [["]] then
- rec = '"'
- print(r)
- s = s..[["]]
- elseif r == [[=]] then
- local a = n[#n]
- print("EQ:"..a)
- local g = {Variable=a,Equal={}}
- n[#n]=g
- -- print("EQ:"..tostring(n[#n]))
- else
- if rec then
- s = s..rec
- rec = nil
- end
- if #s > 0 then
- print("Fin: " ..s,#s)
- local p = n[#n]
- if type(p) ~= "table" then
- table.insert(n,s)
- else
- print("Added to " ..p.Variable..", "..s)
- table.insert(p.Equal,s)
- end
- end
- s = ""
- end
- end
- print(n[1].Variable,n[1].Equal)
- name,equals = n[1].Variable,n[1].Equal
- local cr = n[1].Equal
- local fn = {}
- for i,v in pairs(cr) do
- table.insert(fn,create(v))
- end
- if name and equals then
- getfenv()[name]=(getfenv()[equals] or unpack(fn))
- end
- end
- newtype(string)
- end
- runstring([[asd = "test"]])
- print(tostring(asd))
- print(asd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement