Kcee wrote:... Sometimes when I look at my progress, I feel forced to give up on the game. It just seems impossible to complete. I am still amazed at how Bee-Ant...
lcl wrote:Kcee wrote:Can someone help me out with this?
At the beginning of the game, the player types in his name and later on in the game, an NPC would talk to the player and I want him to mention the player's name.
Create a new string variable, then use sscanf() to read the contents of the text box (if you don't know how to make a text actor into a text input actor, all you have to do is to select "Yes" on the "Text Input" option in the "Text" panel of the actor).
sscanf() stands for:
- string
- scan
- format
What it does is that it reads data from a string. You give it the format it uses for finding the data, and then you give it pointers to the variables you want it to store the data to. The formatting works just like the formatting on sprintf(), if you're familiar with that. Here's an example to get you started:
- Code: Select all
// The first argument "text" defines what string you want to scan.
// We want to scan the contents of the text box actor's text,
// so if we are in an event of that actor, that would be "text"
// (which is equal to "myTextInputActor.text", if that's the name of the actor).
// The second argument is the formatting used for reading.
// As we only want to read a string from the text, the formatting is simply "%s",
// which stands for string.
// The third argument is the pointer (i.e. the memory address) to the string where
// we want to store the result of the scan. As we want to read it to our variable, just
// input the name of the variable, preceded by "&", which is the "address-of" operator.
sscanf(text, "%s", &myName);
The lines that begin with "//" are comments, not code. The code alone without the comments is:
- Code: Select all
sscanf(text, "%s", &myName);
Hope this helps! If you have trouble understanding it or using it, just ask and I'll explain it to you.
whitebox.r (-=)+= 5;
Menu_Border.r=whitebox.r;
Menu_Border.g=whitebox.g;
Menu_Border.b=whitebox.b;
textactor.r=whitebox.r*-1; // I don't know if this can work. Also for green and blue
whitebox.r±=5;
whitebox.g±=5;
whitebox.b±=5;
Users browsing this forum: No registered users and 1 guest