fixed some bugs that i didn't even know existed
This commit is contained in:
parent
05cc166925
commit
87e13c42bc
30
audiotest.dms
Normal file
30
audiotest.dms
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
ENTRY init
|
||||||
|
USING audio as audio
|
||||||
|
[init]{
|
||||||
|
bgm = audio:new("Audio/Lost World - myuu.ogg")
|
||||||
|
bgm:play(1)
|
||||||
|
bgm:setVolume(.1)
|
||||||
|
JUMP("CHOOSE")
|
||||||
|
}
|
||||||
|
[CHOOSE]{
|
||||||
|
"Choose"<
|
||||||
|
"fade in" JUMP("FADEIN")
|
||||||
|
"fade out" JUMP("FADEOUT")
|
||||||
|
"exit" JUMP("quit")
|
||||||
|
>
|
||||||
|
}
|
||||||
|
[FADEIN]{
|
||||||
|
for x = 100,1,-1 <
|
||||||
|
sleep(.1)
|
||||||
|
bgm:setVolume(100/x)
|
||||||
|
>
|
||||||
|
}
|
||||||
|
[FADEOUT]{
|
||||||
|
for x = 100,1,-1 <
|
||||||
|
sleep(.1)
|
||||||
|
bgm:setVolume(x/100)
|
||||||
|
>
|
||||||
|
}
|
||||||
|
[quit]{
|
||||||
|
QUIT()
|
||||||
|
}
|
||||||
@ -6,6 +6,7 @@ function audio:new(path)
|
|||||||
local c = {}
|
local c = {}
|
||||||
c.path = path
|
c.path = path
|
||||||
c.handle = proAudio.sampleFromFile(path)
|
c.handle = proAudio.sampleFromFile(path)
|
||||||
|
print("Created:",c.handle)
|
||||||
setmetatable(c,audio)
|
setmetatable(c,audio)
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
@ -22,8 +23,9 @@ function audio:stop()
|
|||||||
proAudio.soundStop(self.handle)
|
proAudio.soundStop(self.handle)
|
||||||
end
|
end
|
||||||
function audio:setVolume(volume)
|
function audio:setVolume(volume)
|
||||||
|
local volume = tonumber(volume) or 1
|
||||||
proAudio.soundUpdate(self.handle,volume,volume)
|
proAudio.soundUpdate(self.handle,volume,volume)
|
||||||
end
|
end
|
||||||
function parseManager:audio()
|
function parseManager:audio()
|
||||||
return audio
|
return audio
|
||||||
end
|
end
|
||||||
|
|||||||
@ -74,15 +74,24 @@ function parseManager:DISABLE(fn)
|
|||||||
self.stats[string.lower(fn)]=false
|
self.stats[string.lower(fn)]=false
|
||||||
end
|
end
|
||||||
function parseManager:USING(fn,name)
|
function parseManager:USING(fn,name)
|
||||||
local m = require("parseManager."..fn)
|
local loaded, m = pcall(require,"parseManager."..fn)
|
||||||
|
if not loaded then
|
||||||
|
loaded, m = pcall(require,fn)
|
||||||
|
if not loaded then
|
||||||
|
self:pushError("Unable to load module "..fn.."!")
|
||||||
|
end
|
||||||
|
end
|
||||||
self.usings[#self.usings]={fn,name}
|
self.usings[#self.usings]={fn,name}
|
||||||
if not m then
|
if not m then
|
||||||
self:pushError(fn.." was not found as an import that can be used!")
|
self:pushError(fn.." was not found as an import that can be used!")
|
||||||
else
|
else
|
||||||
local ret = self[fn](self)
|
local ret
|
||||||
if ret then
|
if self[fn] then
|
||||||
self.mainENV[name or fn]=ret
|
ret = self[fn](self)
|
||||||
|
else
|
||||||
|
ret = m
|
||||||
end
|
end
|
||||||
|
self.mainENV[name or fn]=ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--[[
|
--[[
|
||||||
@ -852,13 +861,11 @@ local function extract(dat,name)
|
|||||||
return dat
|
return dat
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
parseManager.isInternal={}
|
||||||
function parseManager:compile(name,ctype,data)
|
function parseManager:compile(name,ctype,data)
|
||||||
local isFBlock,FBArgs=ctype:match("(f)unction%((.*)%)")
|
local isFBlock,FBArgs=ctype:match("(f)unction%((.*)%)")
|
||||||
--Check if we are dealing with a FBlock
|
--Check if we are dealing with a FBlock
|
||||||
if isFBlock=="f" then
|
if isFBlock=="f" then
|
||||||
if not self.isInternal then
|
|
||||||
self.isInternal = {}
|
|
||||||
end
|
|
||||||
self.cFuncs[name]=true
|
self.cFuncs[name]=true
|
||||||
-- if self.methods[name] then
|
-- if self.methods[name] then
|
||||||
-- self:pushError("You cannot create a method with the same name as a standard method or duplicate method names!",name)
|
-- self:pushError("You cannot create a method with the same name as a standard method or duplicate method names!",name)
|
||||||
@ -918,9 +925,9 @@ function parseManager:compile(name,ctype,data)
|
|||||||
if cmd==1 then
|
if cmd==1 then
|
||||||
local t = extract(dat[7],name)
|
local t = extract(dat[7],name)
|
||||||
if type(t)=="string" then
|
if type(t)=="string" then
|
||||||
t="+"..t
|
t="+"..(t~="" and t or 1)
|
||||||
end
|
end
|
||||||
-- parseManager.print(dat[2] .. (t or "+1"))
|
parseManager.print(dat[2] .. (t or "+1"))
|
||||||
self:compileAssign(dat[2],dat[2] .. (t or "+1"),name)
|
self:compileAssign(dat[2],dat[2] .. (t or "+1"),name)
|
||||||
self:compileCondition(dat[2].."=="..tonumber(dat[4])+(tonumber(dat[7]) or 1),"GOTO(\""..s.."\")","GOTO(\""..dat[1].."\")",name)
|
self:compileCondition(dat[2].."=="..tonumber(dat[4])+(tonumber(dat[7]) or 1),"GOTO(\""..s.."\")","GOTO(\""..dat[1].."\")",name)
|
||||||
data[i] = "::"..s.."::"
|
data[i] = "::"..s.."::"
|
||||||
@ -1288,7 +1295,9 @@ function parseManager:next(block,choice)
|
|||||||
if data.Type=="label" then
|
if data.Type=="label" then
|
||||||
chunk.pos=chunk.pos+1
|
chunk.pos=chunk.pos+1
|
||||||
data=chunk[chunk.pos]
|
data=chunk[chunk.pos]
|
||||||
IRET = self.__LABEL(data.label,data.pos)
|
if data then
|
||||||
|
IRET = self.__LABEL(data.label,data.pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if not data then self.isrunning = false return end
|
if not data then self.isrunning = false return end
|
||||||
chunk.pos=chunk.pos+1
|
chunk.pos=chunk.pos+1
|
||||||
@ -1313,7 +1322,7 @@ function parseManager:next(block,choice)
|
|||||||
else
|
else
|
||||||
Func=self.methods[data.Func]
|
Func=self.methods[data.Func]
|
||||||
end
|
end
|
||||||
if self.isInternal[data.Func] then
|
if not self.methods[data.Func] then
|
||||||
rets={Func(unpack(args))}
|
rets={Func(unpack(args))}
|
||||||
else
|
else
|
||||||
rets={Func(self,unpack(args))}
|
rets={Func(self,unpack(args))}
|
||||||
|
|||||||
7
test.lua
7
test.lua
@ -4,7 +4,7 @@ local bin = require("bin")
|
|||||||
local multi = require("multi")
|
local multi = require("multi")
|
||||||
require("parseManager")
|
require("parseManager")
|
||||||
require("multi")
|
require("multi")
|
||||||
test=parseManager:load("test.dms")--parseManager:compileToFile("test.dms","test.dmsc")--
|
test=parseManager:load("audiotest.dms")--parseManager:compileToFile("test.dms","test.dmsc")--
|
||||||
test:define{
|
test:define{
|
||||||
external = function(self)
|
external = function(self)
|
||||||
return multi
|
return multi
|
||||||
@ -14,11 +14,8 @@ test:define{
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
parseManager.print(test:dump())
|
parseManager.print(test:dump())
|
||||||
--~ test = parseManager:loadCompiled("test.dmsc")
|
print(test:dump())
|
||||||
--~ print(test.methods.DoMe(2))
|
|
||||||
--~ print(test.methods.DoMe(1,2))
|
|
||||||
local active = true
|
local active = true
|
||||||
while active do
|
while active do
|
||||||
active = test:think()
|
active = test:think()
|
||||||
end
|
end
|
||||||
--~ multi:mainloop()
|
|
||||||
|
|||||||
16
test2.dms
Normal file
16
test2.dms
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
USING multi as multi
|
||||||
|
USING bin as bin
|
||||||
|
ENTRY INIT
|
||||||
|
[INIT]{
|
||||||
|
// "Hi!"
|
||||||
|
// "Lets do a test"
|
||||||
|
file = bin.new()
|
||||||
|
file.data = "We can write data like this too!"
|
||||||
|
print(file)
|
||||||
|
file:tofile("hey.txt")
|
||||||
|
// multi:newTLoop(test,1)
|
||||||
|
// multi:mainloop()
|
||||||
|
}
|
||||||
|
[test:function(self,a)]{
|
||||||
|
print("Loops: $a$")
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user