Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Creator: Bolodefchoco
- --Made in: 14/05/2016
- --Last update: 26/05/2016
- --[[ Notes:
- Does:
- Uma função que facilita a programação.
- Current Commands:
- every time_timer do function()
- create var with value
- Timers:
- s --> Segundo
- m --> Minuto
- h --> Hora
- Values:
- nil --> Nulo
- int --> Número
- str --> String
- bol --> Boolean
- Example:
- (Final das linhas)
- ]]
- string.split=function(str,id,split)
- local list={}
- for val in string.gmatch(str,(id==0 and '[^'..(split or '%s')..']+' or id==1 and split)) do
- table.insert(list,val)
- end
- return list
- end
- table.find=function(table,value)
- for k,v in next,table do
- if v == value then
- return true,k
- end
- end
- return false,0
- end
- os.lua = function(command)
- local p = string.split(command,0)
- local loopE,loopI = table.find(p,"every")
- local createE,createI = table.find(p,"create")
- if loopE then
- if p[loopI] == "every" then
- if p[loopI + 2] == "do" then
- local int,time = p[loopI + 1]:match("(%d*)(%a)")
- int = tonumber(int) or 1
- if time then
- if time == "s" then
- int = int * 1
- end
- if time == "m" then
- int = int * 60
- end
- if time == "h" then
- int = int * 60 * 60
- end
- local numb = 0
- eventLoop = function(timer)
- numb = numb + .5
- if numb == int then
- numb = 0
- local func,val = p[loopI + 3]:match("(%w+)%((.*)%)")
- local x = string.split(val,0,",")
- _G[func](table.unpack(x))
- end
- end
- end
- else
- error("<I>do</I> is missed!")
- end
- end
- end
- if createE then
- if p[createI] == "create" then
- if p[createI + 2] == "with" then
- if p[createI + 3] == "nil" then
- _G[p[createI + 1]] = nil
- elseif p[createI + 3] == "int" then
- _G[p[createI + 1]] = tonumber(p[createI + 4])
- elseif p[createI + 3] == "str" then
- _G[p[createI + 1]] = table.concat(p,' ',createI + 4)
- elseif p[createI + 3] == "bol" then
- _G[p[createI + 1]] = p[createI + 4] == "true"
- else
- error("The value is missed!")
- end
- else
- error("<I>with</I> is missed!")
- end
- end
- end
- end
- --Exemplo
- os.lua([[
- every 10s do print(Test!)
- create NUMB with int 10
- ]])
- print(NUMB+20)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement