Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Moving a string to a new line. Need help.

Author
Message
Stormwire
13
Years of Service
User Offline
Joined: 3rd Sep 2010
Location:
Posted: 6th Feb 2012 14:25
I have a little prog that uses one string to hold all the characters a person types in. What I want to do is when the cursor reaches the side of the screen I want the cursor to move down a line and start writing to a new line. Just like it would normaly do in any text editor. The problem is the Carriage Return doesnt do anything. I have tried SetTextCharPosition but that doesnt seem to work either. I would prefer to keep everything to one string if thats possible. Any ideas please?
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 6th Feb 2012 17:32
If you happen to use C++, it's:

"Blablabla\nBlablabla"

\n won't be displayed. Instead it'll produce a new line.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Feb 2012 18:12
You can't do it with current AppGameKit functionality, each string is converted to a graphic representation of the characters. This doesn't include word-processing style functionality to break up a sentence into multiple lines. You need to do this bit yourself.

Stormwire
13
Years of Service
User Offline
Joined: 3rd Sep 2010
Location:
Posted: 6th Feb 2012 18:51
@kamac Thanks but it is basic I am using

@BatVink There is a function called SetTextCharPosition which I cant seem to get it to do anything. If this function works the way I think it does then I should be able to move each character anywhere. Right? As long as I dont do anything to the string like resize etc.
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 6th Feb 2012 19:15 Edited at: 6th Feb 2012 19:23
What you need to do is shift from a single string, to an array. Then manually count the number of characters within that string and divide it by the maximum number of characters, use the mid() command to isolate the characters you want and place them inside each cell of the array. I do this all the time in my text adventure program for DarkBASIC Professional, the same logic applies to AGK.

You will either need to use print statments to display this, or you will need to dynamically generate text objects for each array entry.

Check out the UCF project there's several string processing functions there that can help speed this up for you.

http://forum.thegamecreators.com/?m=forum_view&t=193433&b=41

In regards to input, you can't access a multi-line text box, but you can keep adding lines to the master string. It won't be as pretty but it will work.

----

Having said that, another way you could do this, is to create your own keyboard in the game. You could setup a sprite based keyboard yourself, and manually generate string characters from each input which get added into a string. This would avoid the input text box all together and you can simply type all this out directly into the game.
Stormwire
13
Years of Service
User Offline
Joined: 3rd Sep 2010
Location:
Posted: 6th Feb 2012 19:25
Quote: "In regards to input, you can't access a multi-line text box, but you can keep adding lines to the master string. It won't be as pretty but it will work. "


This is what I am doing now. It worked well until I reached this snag. I think your right I think it is time to move from the one string. Thanks for the help.
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 6th Feb 2012 20:56
Dim Text[x] as String

is your friend

Login to post a reply

Server time is: 2024-05-05 22:57:36
Your offset time is: 2024-05-05 22:57:36