GAH!! MY BRAIN HURTS!

Blitz3D Forums/Blitz3D Beginners Area/GAH!! MY BRAIN HURTS!

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

dang, this should be working, here's the creator:

 
AppTitle "SW:WRH Conversation creator"
Global filename$=""
Global launcher$=""
Global funcname$=""

Global quit=0
Global check$=""

Type TQuestion
Field question$
Field ans1$
Field ans2$
Field ans3$
Field fol1$
Field fol2$
Field fol3$
End Type 

Graphics 1280,1024,32,2






;createconversation
;create the conversation
Text 1, 1, "WELCOME TO THE SW:WRH CONVERSATION CREATOR.  If you quit (click the X) It WILL NOT SAVE. HIT ANY KEY TO CONTINUE"
WaitKey()
Cls 

filename$=Input$("What should the filename of this conversation be (if the file already exhists, put its name here too, extensions are unnecesary)? ") + ".bb"
check(filename$)
If quit=1 Then Goto quitlabel


funcname$=Input$("What would you like the Function name For this conversation To be?   ")
check(funcname$)
If quit=1 Then Goto quitlabel

Global initquestion$ = Input$("What should the First thing the NPC says be? ")

GetQuestion$(initquestion$)


writetofile 


Cls 


.quitlabel
End 

Function check(check$)
If check$="quit" Then quit=1
;Goto quitlabel
;EndIf 
End Function 

Function writetofile()


test = FileType(filename$)

;if it doesn't
If Not test Then
		
	;createfile
	file = WriteFile(filename$)


;if it does		
Else
	
	;open file
	file = OpenFile(filename$)
	;seek to end of file
	SeekFile file, FileSize(filename$)
	
End If
;======================================================TO BE CHANGED================================
WriteLine file, "Type TQuestion"
WriteLine file, "Field question$"
WriteLine file, "Field ans1$"
WriteLine file, "Field ans2$"
WriteLine file, "Field ans3$"
WriteLine file, "Field fol1$"
WriteLine file, "Field fol2$"
WriteLine file, "Field fol3$"
WriteLine file, "End Type"



For question1.TQuestion = Each TQuestion
WriteLine file, "question1.TQuestion = New TQuestion"
WriteLine file, "question1\question$ = " + question1\question$
WriteLine file, "question1\ans1$ = " + question1\ans1$
WriteLine file, "question1\ans2$ = " + question1\ans2$
WriteLine file, "question1\ans3$ = " + question1\ans3$

If question1\fol1$ <> "" Then WriteLine file, "question1\fol1$ = " + question1\fol1$

If question1\fol2$ <> "" Then WriteLine file, "question1\fol2$ = " + question1\fol2$

If question1\fol3$ <> "" Then WriteLine file, "question1\fol3$ = " + question1\fol3$

Next 





;======================================================TO BE CHANGED================================


CloseFile file



End Function 

Function GetQuestion$(q$)

	Print 
	Print "-----------------"
	Print 

	Print "Please enter answers that can be given for"
	Print "this question: " + q$
	a1$ = Input (" answer1=")	
	follow1$ = Input$("  followed by=")

	
	a2$ = Input (" answer2=")
	follow2$ = Input$("  followed by=")

	a3$ = Input (" answer3=")
	follow3$ = Input$("  followed by=")
	
	question1.TQuestion = New TQuestion
	question1\question$ = q$
	question1\ans1$ = a1$
	question1\ans2$ = a2$
	question1\ans3$ = a3$
	question1\fol1$ = follow1$
	question1\fol2$ = follow2$
	question1\fol3$ = follow3$
	
	
	
		
	If follow1$ <> "" Then GetQuestion$(follow1$)	
	If follow2$ <> "" Then GetQuestion$(follow2$)	
	If follow3$ <> "" Then GetQuestion$(follow3$)	

End Function	


and here's my function:
Function conversation(filename$, questiontoask$)

Include "" + filename$

;reset 'q' to empty before searching
q.TQuestion = Null

;scan all TQuestions
For temp.TQuestion = Each TQuestion

  ;if temp's question is the question to ask, then select temp and leave loop
  If temp\question$ = questiontoask$ Then q = temp: Exit

Next

If q = Null Then Return ;--> the question was not found


Repeat
UpdateWorld
RenderWorld
Flip()



If (MouseY() < ((displayheight/4)*3)+((displayheight/4)*.3) + 12) And MouseY() > ((displayheight/4)*3)+((displayheight/4)*.3) Then
Color 50, 50, 245
Rect 0, ((displayheight/4)*3)+((displayheight/4)*.3), displaywidth, 12, 1
Color 255, 255, 255
EndIf

Color 0,0,0
Rect 0,0,displaywidth,displayheight/4,1
Color 0,0,0
Rect 0,(displayheight/4)*3,displaywidth,displayheight/4,1
Color 255, 255, 255

;HIGHLIGHTS========================

If (MouseY() < ((displayheight/4)*3)+((displayheight/4)*.3) + 12) And MouseY() > ((displayheight/4)*3)+((displayheight/4)*.3) Then
Color 50, 50, 245
Rect 0, ((displayheight/4)*3)+((displayheight/4)*.3), displaywidth, 12, 1
Color 255, 255, 255
If MouseHit(1) Then followup$ = q\follow1$
EndIf

If (MouseY() < ((displayheight/4)*3)+((displayheight/4)*.3) + 12 +50) And MouseY() > ((displayheight/4)*3)+((displayheight/4)*.3)+50 Then
Color 50, 50, 245
Rect 0, ((displayheight/4)*3)+((displayheight/4)*.3)+50, displaywidth, 12, 1
Color 255, 255, 255
If MouseHit(1) Then followup$ = q\follow2$
EndIf

If (MouseY() < ((displayheight/4)*3)+((displayheight/4)*.3)+12+100) And MouseY() > ((displayheight/4)*3)+((displayheight/4)*.3)+100 Then
Color 50, 50, 245
Rect 0, ((displayheight/4)*3)+((displayheight/4)*.3)+100, displaywidth, 12, 1
Color 255, 255, 255
If MouseHit(1) Then followup$ = q\follow3$
EndIf
;====================================

Text 250,100, "" + follwup$
Text 250,((displayheight/4)*3)+((displayheight/4)*.3), "" + q\a1$ 
Text 250,((displayheight/4)*3)+((displayheight/4)*.3)+50, "" + q\a2$ 
Text 250,((displayheight/4)*3)+((displayheight/4)*.3)+100, "" + q\a2$ 

Until KeyHit(1)

End Function 



and I'm using this to call it:
If KeyHit( 43 ) Then 

conversation("testing!.bb", "Hi")
 
EndIf 


and finally the file testing!.bb is as follows:

Type TQuestion
Field question$
Field ans1$
Field ans2$
Field ans3$
Field fol1$
Field fol2$
Field fol3$
End Type
question1.TQuestion = New TQuestion
question1\question$ = Hi
question1\ans1$ = How are you?
question1\ans2$ = Bye!
question1\ans3$ = hello, I am mr. poopy head
question1\fol1$ = Good
question1\fol3$ = ???
question1.TQuestion = New TQuestion
question1\question$ = Good
question1\ans1$ = Nice to know
question1\ans2$ = Great
question1\ans3$ = I hate you
question1\fol2$ = I gotta go!
question1.TQuestion = New TQuestion
question1\question$ = I gotta go!
question1\ans1$ = K... :(
question1\ans2$ = :(
question1\ans3$ = Jerk!!
question1.TQuestion = New TQuestion
question1\question$ = ???
question1\ans1$ = that's right
question1\ans2$ = ?
question1\ans3$ = Goodbye


I'm leaving soon so if you could get me an answer ASAP I'd hugely appreciate it!

I'm getting the error message: "cannot open include file!" on the function...the file "testing!.bb" is in the same folder as the function...I don't get it!