input$ and text collide?

Blitz3D Forums/Blitz3D Beginners Area/input$ and text collide?

chwaga(Posted 2007) [#1]
I'm making a program designed to create conversations, so each don't have to be individually coded, saving a lot of time, I hope. This involves multiple inputs asking you what you want the npc to say, and then input a set of responses, etc. I want the responses and npc prompts to be posted real-time. But, for some reason, the text containing the responses and promps will NOT appear until all inputs have been completed. Also, I want to be able to type within the inputs "\quit" or "\endconv" and have a check, searching each input for those or other commands. How can I fix the text/input bug, and what command is used for searching a variable (hopefully the Input$? that way i can put the check in a function, saving a lot of time, not having to check each individual variable)

Here's some sample code.

launcher$=""
funcname$=""
npc1$=""
r1$=""
r2$=""
r3$=""
npc2$=""
quit=0
Graphics3D 1280,1024,32,1
SetBuffer BackBuffer()

Function check()
If Input$="quit" Then quit=1
End Function

While Not quit=1
RenderWorld

;createconv
launcher$=Input$("WELCOME TO THE SW:WRH CONVERSATION CREATOR. FOLLOW GIVEN INSTRUCTIONS. TYPE 'quit' AT ANY TIME TO QUIT WITHOUT SAVING YOUR CONVERSATION. HIT ENTER TO CONTINUE")
funcname$=Input$("What would you like the Function name For this conversation To be? ")
check
npc1$=Input$("What would the first thing the NPC says be? ")
Text 1000,0,"npc1= " + npc1
check
r1$=Input$("What do you want response1 to be? ")
Text 1000, 15,"r1= " + r1
check
r2$=Input$("What do you want response2 to be? ")
Text 1000, 30,"r2= " + r2
check
r3$=Input$("What do you want response3 to be? ")
Text 1000, 45,"r2= " + r3
check


Flip


Wend

End


GfK(Posted 2007) [#2]
I'm not sure exactly what you're trying to do, but you need to pass a string (r1$, r2$ etc) to your check() function. Then:
Function check(txt$)
If txt$="quit" Then quit=1
End Function
Your 'quit' variable also needs to be global.


puki(Posted 2007) [#3]
I'm not sure what the time-saving element of this idea is.

In fact, I am rather fascinated.


chwaga(Posted 2007) [#4]
I'm working on a program to create conversations, as you can see, it's not nearly completed. once the conversation "tree" has been set up, I will code in a process that the computer will create a conversation, and save it into a function into an include file, for later use in my game. I still can't get the quit thing to work. However, the check function for some reason updates the text and shows it. Here's my current code.

AppTitle "SW:WRH Conversation creator"
launcher$=""
funcname$=""
npc1$=""
r1$=""
r2$=""
r3$=""
npc2$=""
Global quit=0
Graphics3D 1280,1024,32,2
SetBuffer BackBuffer()

Function check()
If (funcname$="quit") Or (npc1$="quit") Or (r1$="quit") Or (r2="quit") Or (r3="quit") Then quit=1
End Function

While quit=0
RenderWorld

;createconv
launcher$=Input$("WELCOME TO THE SW:WRH CONVERSATION CREATOR. FOLLOW GIVEN INSTRUCTIONS. TYPE 'quit' AT ANY TIME TO QUIT WITHOUT SAVING YOUR CONVERSATION. HIT ENTER TO CONTINUE")
funcname$=Input$("What would you like the Function name For this conversation To be? ")
check
npc1$=Input$("What would the first thing the NPC says be? ")
Text 1000,15,"npc1= " + npc1
check
r1$=Input$("What do you want response1 to be? ")
Text 1000, 30,"r1= " + r1
check
r2$=Input$("What do you want response2 to be? ")
Text 1000, 45,"r2= " + r2
check
r3$=Input$("What do you want response3 to be? ")
Text 1000, 60,"r3= " + r3
check

Flip


Wend

End


kevin8084(Posted 2007) [#5]
What you are forgetting to do is make your other variables global as well...this will solve your problem.


chwaga(Posted 2007) [#6]
I dont get what you mean by pass a string through it, if you could give an example using r1$, r2$, etc. That'd be nice. kevin8084, I put all variables global but it still didn't work, here's my current code:

AppTitle "SW:WRH Conversation creator"
Global filename$=""
Global launcher$=""
Global funcname$=""
Global npc1$=""
Global r1$=""
Global r2$=""
Global r3$=""
Global npc2$=""
Global quit=0
Graphics3D 1280,1024,32,2
SetBuffer BackBuffer()

Function check(quit)
If (funcname$="quit") Or (npc1$="quit") Or (r1$="quit") Or (r2="quit") Or (r3="quit") Then quit=1
End Function

While quit=0
RenderWorld

;createconv
launcher$=Input$("WELCOME TO THE SW:WRH CONVERSATION CREATOR. FOLLOW GIVEN INSTRUCTIONS. TYPE 'quit' AT ANY TIME TO QUIT WITHOUT SAVING YOUR CONVERSATION. HIT ENTER TO CONTINUE")
filename$=Input$("What should the filename of this conversation be?")
funcname$=Input$("What would you like the Function name For this conversation To be? ")
check(1)
npc1$=Input$("What would the first thing the NPC says be? ")
Text 1000,15,"npc1= " + npc1
check(1)
r1$=Input$("What do you want response1 to be? ")
Text 1000, 30,"r1= " + r1
check(1)
r2$=Input$("What do you want response2 to be? ")
Text 1000, 45,"r2= " + r2
check(1)
r3$=Input$("What do you want response3 to be? ")
Text 1000, 60,"r3= " + r3
check(1)

Flip


Wend

End


Yo! Wazzup?(Posted 2007) [#7]
First:
change check() into
Function check(var$)
If var$="quit" quit = 1
Else

and check(1) should be check(funcname$) and so on...

Second:
If the condition is true at the start of a loop, it can't be false until the loop is done with its first irritation.
Because of this, you can only type quit on response3 if you want it to work.


Ked(Posted 2007) [#8]
First:
change check() into

Function check(var$)
If var$="quit" quit = 1
Else


and check(1) should be check(funcname$) and so on...

Second:
If the condition is true at the start of a loop, it can't be false until the loop is done with its first irritation.
Because of this, you can only type quit on response3 if you want it to work.



There is no way you're 9. Unless you copied and pasted. :P


chwaga(Posted 2007) [#9]
? Ked??


Yo! Wazzup?(Posted 2007) [#10]
I don't care if you belive me or not. At least you have the solution to your problem.(and no, I didn't copy+paste.)

I don't know how to prove that I'm 9, but I am weather you belive me or not.


chwaga(Posted 2007) [#11]
that works, ked, but is there any way to make it not work only on the r3$ phase? I can't think of anything. my "var$" starts as Global var$="".


PS:
*shrug* I'd believe it, I'm 13 and i know what axonometric projection is :)


Yo! Wazzup?(Posted 2007) [#12]
You could just put a label at the end of the program (right before "End") and if one of the variables is "quit" it would go to the label.

So check() could be
Function check(var$)
    If var$ = "quit" Or var$ = "Quit" Or var$ = ...etc... Then
    Goto endofprogramlabel
EndIf



chwaga(Posted 2007) [#13]
I thought that would work, but for some reason it's giving me "undefined label" here's my current code: (if someone could give me a link to the forum codes, that'd be nice)


AppTitle "SW:WRH Conversation creator"
Global filename$=""
Global launcher$=""
Global funcname$=""
Global npc1$=""
Global r1$=""
Global r2$=""
Global r3$=""
Global npc2$=""
Global quit=0
Global check$=""

Graphics3D 1280,1024,32,2
SetBuffer BackBuffer()

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

Function createconversation()
Color 0,0,0
Rect 0,0,displaywidth,displayheight/4,1

Rect 0,(displayheight/4)*3,displaywidth,displayheight/4,1
Color 255,255,255
Text 250,100,""+npc1$
Text 250,((displayheight/4)*3)+((displayheight/4)*.3),""+r1$

End Function

While quit=0

RenderWorld
createconversation
;create the conversation
launcher$=Input$("WELCOME TO THE SW:WRH CONVERSATION CREATOR. FOLLOW GIVEN INSTRUCTIONS. TYPE 'quit' AT ANY TIME TO QUIT WITHOUT SAVING YOUR CONVERSATION. HIT ENTER TO CONTINUE")
filename$=Input$("What should the filename of this conversation be?")
check(filename$)
funcname$=Input$("What would you like the Function name For this conversation To be? ")
check(funcname$)
npc1$=Input$("What would the first thing the NPC says be? ")
Text 1000,15,"npc1= " + npc1
check(npc1$)

r1$=Input$("What do you want response1 to be? ")
Text 1000, 30,"r1= " + r1
check(r1$)
r2$=Input$("What do you want response2 to be? ")
Text 1000, 45,"r2= " + r2
check(r2$)
r3$=Input$("What do you want response3 to be? ")
Text 1000, 60,"r3= " + r3
check(r3$)

Flip


Wend
.quitlabel
End


Yo! Wazzup?(Posted 2007) [#14]
Fourm Codes


chwaga(Posted 2007) [#15]
thanks, but what can be done to fix the bug?


Yo! Wazzup?(Posted 2007) [#16]
Sorry I have no idea.


chwaga(Posted 2007) [#17]
ok...any other ideas lol?


kevin8084(Posted 2007) [#18]
Function check(check$)
If check$="quit"
quit = 1
EndIf 
End Function

************
Then after each check() call put:
if quit=1 then goto quitlabel

**********************
Not elegant, by any means, but it works :)
The problem with "undefined label" is that .quitlabel is a local label and you were trying to reference it from within a function. Being local, the function couldn't see it and complained.


chwaga(Posted 2007) [#19]
is there a way to make a global label?


kevin8084(Posted 2007) [#20]
not as far as I know.


chwaga(Posted 2007) [#21]
doesnt work


kevin8084(Posted 2007) [#22]
works for me


chwaga(Posted 2007) [#23]
there we go! I did something wrong. Thanks!


kevin8084(Posted 2007) [#24]
:) no problem...glad that I could help.