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,9 +55,8 @@ 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()
local handle=self:varExists(item) local handle=self:varExists(item)
@ -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,37 +215,39 @@ 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)
t=test:next() ready=false
if t.Type=="text" then multi:newThread("TextHandler",function()
core.chatFrame.textHolder.text=t.text while true do
self:Pause() t=test:next()
elseif t.Type=="choice" then if t.Type=="text" then
go.Visible=false core.chatFrame.textHolder.text=t.text
local choiceframe=gui:newFrame("",0,0,300,(#t+1)*40-10) ready=false
choiceframe:newTextLabel(t.prompt,0,0,0,40,0,0,1).Color=Color.light_blue thread.hold(function() return ready==true end)
for i=1,#t[1] do elseif t.Type=="choice" then
local choice=choiceframe:newTextButton(t[1][i],0,i*40,0,40,0,0,1) go.Visible=false
choice.Color=Color.Darken(Color.saddle_brown,.15) local choiceframe=gui:newFrame("",0,0,300,(#t+1)*40-10)
choice.index=i choiceframe:newTextLabel(t.prompt,0,0,0,40,0,0,1).Color=Color.light_blue
choice:OnReleased(function(b,self) for i=1,#t[1] do
choicemade=self.index local choice=choiceframe:newTextButton(t[1][i],0,i*40,0,40,0,0,1)
end) choice.Color=Color.Darken(Color.saddle_brown,.15)
choice.index=i
choice:OnReleased(function(b,self)
choicemade=self.index
end)
end
choiceframe:centerX()
choiceframe:centerY()
thread.hold(function() return choicemade~=nil end)
go.Visible=true
choiceframe:Destroy()
local cm=choicemade
choicemade=nil
t=test:next(nil,cm)
end end
choiceframe:centerX() thread.sleep(.001)
choiceframe:centerY()
self:Pause()
while choicemade==nil do
multi:lManager()
end
self:Resume()
go.Visible=true
choiceframe:Destroy()
local cm=choicemade
choicemade=nil
t=test:next(nil,cm)
end end
end) end)
test.handle=dialogeHandler test.handle=dialogeHandler