Ok, ill try -.-
Thread 1 is the thread that randomly sends out messages.
Thread 2 allows the person controlling the application to input stuff into the application.
Thread 2: Player starts typing a command, he/she gets this far: "/ban kia" (The full command would be "/ban kiazads", so you can see that the command hasnt been typed fully yet, and the person controlling the application has not yet pressed enter to submit his/her input)
Thread 1: Outputs a message saying: "Monster has spawned in world 1"
Now because Thread 1 did an output before Thread 2 got to finnish the command input, the output gets sent like this: "/ban kiaMonster has spawned in world 1" Because when thread1 did the output, it joined with the input from thread 2, after that message sent, the input screen was back to an empty string.
This is what im trying to do:
Thread 2: Player starts typing a command, he/she gets this far: "/ban kia" (The full command would be "/ban kiazads", so you can see that the command hasnt been typed fully yet, and the person controlling the application has not yet pressed enter to submit his/her input)
Thread 1: Cuts the applications half done input, so that it can place it back after the random message has sent, and to make it also not join with the input.
Sends random message (as shown in the first example: "Monster has spawned in world 1")
Places cut input text back into the writing input.
Heres an example in text:
Code key:
User input = The half finnished input that the person operating the application has typed.
oldtext = A variable to save the user input in so we dont loose it when we remove it!
Random output/message = The message that the other thread is sending that screws up the half done input.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
What its doing now:
step 1:
User input = "/ban kia"
Random output = "Monster has spawned in world 1"
Step 2:
// Half finnished user input gets sent along with the output.
First line of console = "/ban kiaMonster has spawned in world 1"
What i want it to do:
step 1:
User input = "/ban kia"
Random output = "Monster has spawned in world 1"
Step 2:
// Cut user input into a variable called.. 'oldtext'? :P
oldtext = User input;//Assing the user input to another variable so we dont loose it.
User input = "";//Remove the user input so it doesnt join with the output.
step 3:
Send the message ("Monster has spawned in world 1")
step 4:
//Paste back the user input
User input = oldtext;
|
Basically, i want to save the half done input, then remove it, then send a message, and put the input back, so the input ends up infront of the output instead of joining with it when the output gets sent.
OK ive explained it in three different ways, hope this helps >.<