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 = {}
|
||||
c.path = path
|
||||
c.handle = proAudio.sampleFromFile(path)
|
||||
print("Created:",c.handle)
|
||||
setmetatable(c,audio)
|
||||
return c
|
||||
end
|
||||
@ -22,6 +23,7 @@ function audio:stop()
|
||||
proAudio.soundStop(self.handle)
|
||||
end
|
||||
function audio:setVolume(volume)
|
||||
local volume = tonumber(volume) or 1
|
||||
proAudio.soundUpdate(self.handle,volume,volume)
|
||||
end
|
||||
function parseManager:audio()
|
||||
|
||||
@ -74,15 +74,24 @@ function parseManager:DISABLE(fn)
|
||||
self.stats[string.lower(fn)]=false
|
||||
end
|
||||
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}
|
||||
if not m then
|
||||
self:pushError(fn.." was not found as an import that can be used!")
|
||||
else
|
||||
local ret = self[fn](self)
|
||||
if ret then
|
||||
self.mainENV[name or fn]=ret
|
||||
local ret
|
||||
if self[fn] then
|
||||
ret = self[fn](self)
|
||||
else
|
||||
ret = m
|
||||
end
|
||||
self.mainENV[name or fn]=ret
|
||||
end
|
||||
end
|
||||
--[[
|
||||
@ -852,13 +861,11 @@ local function extract(dat,name)
|
||||
return dat
|
||||
end
|
||||
end
|
||||
parseManager.isInternal={}
|
||||
function parseManager:compile(name,ctype,data)
|
||||
local isFBlock,FBArgs=ctype:match("(f)unction%((.*)%)")
|
||||
--Check if we are dealing with a FBlock
|
||||
if isFBlock=="f" then
|
||||
if not self.isInternal then
|
||||
self.isInternal = {}
|
||||
end
|
||||
self.cFuncs[name]=true
|
||||
-- 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)
|
||||
@ -918,9 +925,9 @@ function parseManager:compile(name,ctype,data)
|
||||
if cmd==1 then
|
||||
local t = extract(dat[7],name)
|
||||
if type(t)=="string" then
|
||||
t="+"..t
|
||||
t="+"..(t~="" and t or 1)
|
||||
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:compileCondition(dat[2].."=="..tonumber(dat[4])+(tonumber(dat[7]) or 1),"GOTO(\""..s.."\")","GOTO(\""..dat[1].."\")",name)
|
||||
data[i] = "::"..s.."::"
|
||||
@ -1288,8 +1295,10 @@ function parseManager:next(block,choice)
|
||||
if data.Type=="label" then
|
||||
chunk.pos=chunk.pos+1
|
||||
data=chunk[chunk.pos]
|
||||
if data then
|
||||
IRET = self.__LABEL(data.label,data.pos)
|
||||
end
|
||||
end
|
||||
if not data then self.isrunning = false return end
|
||||
chunk.pos=chunk.pos+1
|
||||
self:debug("TYPE: "..data.Type)
|
||||
@ -1313,7 +1322,7 @@ function parseManager:next(block,choice)
|
||||
else
|
||||
Func=self.methods[data.Func]
|
||||
end
|
||||
if self.isInternal[data.Func] then
|
||||
if not self.methods[data.Func] then
|
||||
rets={Func(unpack(args))}
|
||||
else
|
||||
rets={Func(self,unpack(args))}
|
||||
|
||||
7
test.lua
7
test.lua
@ -4,7 +4,7 @@ local bin = require("bin")
|
||||
local multi = require("multi")
|
||||
require("parseManager")
|
||||
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{
|
||||
external = function(self)
|
||||
return multi
|
||||
@ -14,11 +14,8 @@ test:define{
|
||||
end
|
||||
}
|
||||
parseManager.print(test:dump())
|
||||
--~ test = parseManager:loadCompiled("test.dmsc")
|
||||
--~ print(test.methods.DoMe(2))
|
||||
--~ print(test.methods.DoMe(1,2))
|
||||
print(test:dump())
|
||||
local active = true
|
||||
while active do
|
||||
active = test:think()
|
||||
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