input$ and text collide?
Blitz3D Forums/Blitz3D Beginners Area/input$ and text collide?
| ||
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 |
| ||
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 FunctionYour 'quit' variable also needs to be global. |
| ||
I'm not sure what the time-saving element of this idea is. In fact, I am rather fascinated. |
| ||
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 |
| ||
What you are forgetting to do is make your other variables global as well...this will solve your problem. |
| ||
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 |
| ||
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. |
| ||
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 |
| ||
? Ked?? |
| ||
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. |
| ||
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 :) |
| ||
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 |
| ||
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 |
| ||
Fourm Codes |
| ||
thanks, but what can be done to fix the bug? |
| ||
Sorry I have no idea. |
| ||
ok...any other ideas lol? |
| ||
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. |
| ||
is there a way to make a global label? |
| ||
not as far as I know. |
| ||
doesnt work |
| ||
works for me |
| ||
there we go! I did something wrong. Thanks! |
| ||
:) no problem...glad that I could help. |