Fixed Threading errors

Fixed an error where corotuine.yeild was being called outside of a thread

Weworked the text display manager and input manager

A graphical redesgin of the inputbox and choices are on the TODO list
This commit is contained in:
Ryan Ward 2018-02-15 09:28:32 -05:00
parent 1b8f63563f
commit f21e52b15e
3 changed files with 37 additions and 46 deletions

View File

@ -1,6 +1,6 @@
LOAD gamedata/lobby.txt LOAD gamedata/lobby.txt
[CONFIG]{ [CONFIG]{
//newThread("THREAD") // Starts a thread that handles events and stuff... Just throw this in and things flow nicely newThread("THREAD") // Starts a thread that handles events and stuff... Just throw this in and things flow nicely
SND_ELEVATOR_BG=loadAudio("audio/elevator.ogg") SND_ELEVATOR_BG=loadAudio("audio/elevator.ogg")
SND_ELEVATOR_OPEN_CLOSE=loadAudio("audio/elevator_open_close.mp3") SND_ELEVATOR_OPEN_CLOSE=loadAudio("audio/elevator_open_close.mp3")
SND_ROPE_CRACKING=loadAudio("audio/rope_cracking.mp3") SND_ROPE_CRACKING=loadAudio("audio/rope_cracking.mp3")

View File

@ -3,6 +3,8 @@
//SND_ROPE_CRACKING //SND_ROPE_CRACKING
//SND_FOOTSTEPS //SND_FOOTSTEPS
[LOBBY]{ [LOBBY]{
name=getInput("What is your name: ")
"Yo $name$ enjoy the game"
BG("images/elevator-lobby.jpg") BG("images/elevator-lobby.jpg")
"Abby: Oh no I'm running late!" "Abby: Oh no I'm running late!"
"Abby: I hope I make my interview" "Abby: I hope I make my interview"

View File

@ -20,11 +20,7 @@ parseManager:define{
inputBox.message.text=msg inputBox.message.text=msg
inputBox.Visible=true inputBox.Visible=true
go.Visible=false go.Visible=false
self.handle:Pause() thread.hold(function() return _inputvar~=nil end)
while _inputvar==nil do
multi:lManager()
end
self.handle:Resume()
local i=_inputvar local i=_inputvar
_inputvar=nil _inputvar=nil
inputBox.Visible=false inputBox.Visible=false
@ -59,8 +55,7 @@ parseManager:define{
end end
end, end,
sleep=function(self,n) sleep=function(self,n)
local num=n thread.sleep(n)
self.handle:hold(num)
end, end,
fadeSong=function(self,item) fadeSong=function(self,item)
self.handle:Pause() self.handle:Pause()
@ -142,12 +137,10 @@ parseManager:define{
item:Reset() item:Reset()
end, end,
setImage=function(self,item,path) setImage=function(self,item,path)
smartPrint(item)
item:SetImage(path) item:SetImage(path)
end, end,
setText=function(self,item,text) setText=function(self,item,text)
if type(item)=="string" then if type(item)=="string" then
print(actor)
self:pushError("item must be a gui object!") self:pushError("item must be a gui object!")
end end
item.text=text item.text=text
@ -188,11 +181,6 @@ parseManager:define{
local ThreadTest=parseManager:load(blocklink.chunks[block].path) local ThreadTest=parseManager:load(blocklink.chunks[block].path)
ThreadTest.mainENV=blocklink.mainENV ThreadTest.mainENV=blocklink.mainENV
ThreadTest.handle=loop ThreadTest.handle=loop
ThreadTest:define{
sleep=function(self,n)
thread.sleep(n)
end
}
local t=ThreadTest:next(block) local t=ThreadTest:next(block)
while true do while true do
if t.Type=="text" then if t.Type=="text" then
@ -219,7 +207,6 @@ core.chatFrame.textHolder.Visibility=0
core.chatFrame.textHolder.text="" core.chatFrame.textHolder.text=""
core.chatFrame.textHolder.TextFormat="left" core.chatFrame.textHolder.TextFormat="left"
test=parseManager:load("init.txt") test=parseManager:load("init.txt")
table.print(test)
--~ print("DUMP:") --~ print("DUMP:")
dump=test:dump() dump=test:dump()
print(dump) print(dump)
@ -228,13 +215,17 @@ test.mainENV["gui"]=workspace
test.mainENV["menu"]=top test.mainENV["menu"]=top
go=core.chatFrame.textHolder:newImageButton("images/arrow.png",-25,-25,20,20,1,1) go=core.chatFrame.textHolder:newImageButton("images/arrow.png",-25,-25,20,20,1,1)
go:OnReleased(function(b,self) go:OnReleased(function(b,self)
dialogeHandler:Resume() ready=true
end) end)
dialogeHandler=multi:newLoop(function(self,ti) --dialogeHandler=multi:newLoop(function(self,ti)
ready=false
multi:newThread("TextHandler",function()
while true do
t=test:next() t=test:next()
if t.Type=="text" then if t.Type=="text" then
core.chatFrame.textHolder.text=t.text core.chatFrame.textHolder.text=t.text
self:Pause() ready=false
thread.hold(function() return ready==true end)
elseif t.Type=="choice" then elseif t.Type=="choice" then
go.Visible=false go.Visible=false
local choiceframe=gui:newFrame("",0,0,300,(#t+1)*40-10) local choiceframe=gui:newFrame("",0,0,300,(#t+1)*40-10)
@ -249,17 +240,15 @@ dialogeHandler=multi:newLoop(function(self,ti)
end end
choiceframe:centerX() choiceframe:centerX()
choiceframe:centerY() choiceframe:centerY()
self:Pause() thread.hold(function() return choicemade~=nil end)
while choicemade==nil do
multi:lManager()
end
self:Resume()
go.Visible=true go.Visible=true
choiceframe:Destroy() choiceframe:Destroy()
local cm=choicemade local cm=choicemade
choicemade=nil choicemade=nil
t=test:next(nil,cm) t=test:next(nil,cm)
end end
thread.sleep(.001)
end
end) end)
test.handle=dialogeHandler test.handle=dialogeHandler
inputBox=gui:newFrame(0,0,500,160) inputBox=gui:newFrame(0,0,500,160)