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.

DarkBASIC Professional Discussion / textbox function doesnt work?

Author
Message
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 02:28
hi all. my friend wrote a basic template of functions for a textbox with word wrap and special colored word selection which i combined with mobiius' code in my earlier post.

now the prob is that its not displaying the text correctly.

can someone please run this and help me fix this?



thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 30th Jul 2010 11:42 Edited at: 30th Jul 2010 11:44
Okay I had a look at your code and changed three parts:

This here

has to be something like this

or else it will immediatly show the whole text.

Second fix:
In the "display_text"-function, after printing a word you have to do this:

Or else all words in one line are printed at the starting x position.

and third:
at the end of "__build_word_array()" you need to put the last word into the array at the end, after the FOR-loop and before clearing the string:


Oh and i put in a longer text
Here is the full code:
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 14:12
thanks!
Also, how do
I activate special
words?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 30th Jul 2010 14:29 Edited at: 30th Jul 2010 14:29
Well you just have to add a call to the function "add_special_word()" after "gosub setup_specialwords".

And in the "display_text"-function the line
last_type = -1
has to be
last_type = 0

I don't know why it was set to -1

Here is the full code with "this" highlighted:
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 14:31
how can
i make
it so
that the
colored
word
displays
automatically
instead of
typing it
1st then
changing the
color?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 30th Jul 2010 14:47 Edited at: 30th Jul 2010 16:22
Honestly, why do you write posts like that?! It's kinda hard to read it

Would be much easier if you just made it one sentence, like this?
Quote: "how can i make it so that the colored word displays automatically instead of typing it 1st then changing the color?"

And if by that you mean coloring the word while it is being typed out, well, the system you use seems kinda strange to me. Would be better to highlight certain words in the text, not one word all the time.
I'd use some kind of formatting or "tags" in the text string... I'll post a simple example soon.
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 16:06
ok

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 30th Jul 2010 16:29
okay here is the example:

It gets the job done, but it's really messy
So you can use it, but it's pretty weird/comlicated...

I'll just explain the "Escape-squences" ( i think that is the name) i added:
- If there is a "\n" in your Text there will be a new line, like with the Chr$(13) you used.
- If there is a "\b" in your Text the next word will be printed bold.
- If there is a "\c" in your Text the next word will be printed in special color.
- If there is a "\s" in your Text it will be printed as a space, but not wrap around at that point (no-break space).
- If there is a "\\" in your Text it will be printed as single backslash "\".

See the code for a example string. And it doesn't matter if there is a space in front or behind the sequence. (except for \s, you wouldn't do that anyways)
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 16:47
thanks, redflame!

is there anyway to make the fps the same? it seems to be lagging the game by 10 fps.



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 16:50 Edited at: 30th Jul 2010 16:54
also, is it possible to call more than 1 text function so that way i can call more than one textbox?

only if the 1st box is done typing of course

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 20:13
this code isnt working..



its acting weird.

why idk..

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 20:37
still not working. but fixed the distance.



now its not allowing me to talk to my objects

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 22:13
what's going on?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 30th Jul 2010 22:34 Edited at: 30th Jul 2010 22:34
well there's a lot of "TEXT" commands everytime the Teletype is printed, so that's why it is slowing down everything ( I get 30 fps when typing the text)

And for your text not working: In the last Code you put it at position "screen height()", so at the bottom of the screen, and it's not visible anymore.

For the second teletype: It could be updated, but the first text would not be shown anymore.

And in general, is this part of your project, or why did you throw all those camera / player functions in there? If this is some kind of Game you're working on you really have to organize your code, and put it into different include-files (for example seperate the functionality into "modules").

But in general all that code, includeing mine is pretty chaotic... it should be organized and/or rewritten.
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 22:35
its a simulation for now.

Which Im learning how to turn into a game.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 30th Jul 2010 22:36
its part of my talk to 3d objects simulation

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 31st Jul 2010 13:58
what's wrong with this?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 31st Jul 2010 16:16
i still cant get it to update the text for every new paragraph..



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 31st Jul 2010 18:10 Edited at: 31st Jul 2010 18:31
Well you got this part here:

Which does this:
If Camera 0 is less than 40 Units away from Object 1 AND Space is pressed -> show the teletype1
Else means: either more than 40 Units away or Space is not pressed. In that else-part you ask again: Is Camera 0 less than 40 Units away from Object 1 AND Space pressed? But If one of those things would be true you wouldn't have entered the ELSE-part at all!
Same goes for the following "else"-stuff, i guess.

Here, try replacing it with this:


Edit: just tested it, it shows the two messages based on the distance. And what is that white box for


if you want a Box behind the message, put this BEFORE calling display_text():
Mugen Wizardry
User Banned
Posted: 31st Jul 2010 18:28
that works.

but i sorta need a "press enter to continue" thing and it will automatically go to the next paragraph, then when it reaches the end and u press enter, it closes the text

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 31st Jul 2010 18:34
I was just editing my post while you posted.

Okay about that, you would put some kind of "counter" into your main loop and Increase it when the user advances to the next Textbox.
If you only want to be able to go to the next box after the current one finished typing you should compare "Len(Teletype.Text$) = Teletype.Char", that should tell you if all text is shown.
If you need more help, just post how far you got with this.
Mugen Wizardry
User Banned
Posted: 31st Jul 2010 18:35
i have NO idea how to do this

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 31st Jul 2010 19:39 Edited at: 31st Jul 2010 19:41
Okay here is a small example of what i mean:


Try to understand what this code does (you have to know why every line is where it is) and then try putting the same things into your own Code. If you somehow break your code, just start over with what you have right now.
If there's anything unclear with the above example, just ask.
Mugen Wizardry
User Banned
Posted: 31st Jul 2010 19:48
do I put Msg$() in setTeleType?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 31st Jul 2010 20:10
it sorta works.

idk why it wont..



thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 31st Jul 2010 20:39 Edited at: 31st Jul 2010 20:41
Quote: "idk why it wont.."


Because you just copy&pasted my example into your code? That obviously does not work.

And "REM just for the example..." meant you won't need these variables i declared there: Those would be the ones from the teletype!

Try changing that. And while you're at it, don't use "If Counter < 3" after the "if Returnkey()", but use this:
"If (Counter >= 0) and (Counter < 3)"
to prevent -1 from being used as a Message-Number.

And in my example it says:
"` <- assign new teletype-message: you'd call SetTeletype for this."
so you'd have to replace that as well.

Good luck, with that, and if you really have no clue how to change these things in your main loop... (if you do know how to fix it, go ahead and continue this project ) if you don't you should really start over with the basics, for example do a tutorial to understand how things are done. Later you can come back to this Project and see if you are able to understand how it works and apply the right changes.
Mugen Wizardry
User Banned
Posted: 31st Jul 2010 20:53
I'm not quitting this. Not when I'm this far. Can you do me a favor this one time and help me out? I'll let you keep the credit for the code.
thanks, redflame!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 31st Jul 2010 21:02
Okay... here's my working version. I think i might have changed that box again... you used the d3d one in your latest code.



But from now on I won't do all the coding for you. You'll have to try and figure out stuff for yourself.
Mugen Wizardry
User Banned
Posted: 31st Jul 2010 21:12
thanks, redflames!

ok, now im having one more problem.

Why cant i use \c?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 31st Jul 2010 21:21 Edited at: 31st Jul 2010 21:42
Oops sorry that's my fault, I broke "display_text()" and didn't notice

Here the fixed function:
[Edit: was still wrong, see post below]
Mugen Wizardry
User Banned
Posted: 31st Jul 2010 21:24
\i and \b are broke too.

among with the other commands.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 31st Jul 2010 21:42 Edited at: 31st Jul 2010 21:43
Okay was still flawed. New one:

Sorry. And i never had "\i".
Mugen Wizardry
User Banned
Posted: 31st Jul 2010 23:44 Edited at: 31st Jul 2010 23:55
Ok, why is the text repeating?

and i can't get the box to position in an absolute position so that way i can control where the box is, and the text will be in the box.

and i cant set the text will be in the same place in the box, but the box will be bigger or smaller. i need to be able to change the x/y size.

the text position is also wrong.



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 1st Aug 2010 02:43 Edited at: 1st Aug 2010 02:44
Well your first SetTeleType()-call is this:
SetTeleType( Msg$(x), XPos,YPos, 150, 100 )
but you don't have a variable "x". You need to put a 0 there to use the first message.

And the second call is this:
SetTeleType( Msg$(0), XPos,YPos, 150, 100 )
Here you're always using message 0 where you should be using "Counter".

I had this in my examples, why did you change it?

And you put this into "DisplayTeleType":

but only use it for the upper left corner of the box, nothing else. What did you want to achieve with this?
TeleType.XPos and TeleType.YPos are already absolute screen coordinates, so you can't really "center" it with your calculations. the XPos and YPos you have in your mainloop do that.
(Except for "Text Width()" gives you the actual width of the whole text, but when its wrapped you'd use the value you use for wrapping. Same for the Height: It is more than one line!)

Well that's it for now. Try working on the coordinates, based on what i just told you. And if something works, you change it and then it doesn't work: Go back to the working version and think about what and how you want to make it different.
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 03:15
I'm closer.

but still doesnt work.

i got the text fixed.

it doesnt repeat.

but the coordinates are off.



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 1st Aug 2010 03:49
Well the box is off because of this part:

What are you trying to do? This way the upper left corner is not where it should be. You should really use the Teletype.Xpos and YPos for that, and set the position of the TeleType to something else.
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 04:02
well. the box a little off center
the thing is though it has to be not only the middle. i need to be able to control the absolute position
not just the position
the text is also not in the box
its a little off

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 14:29
more info?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 14:33 Edited at: 1st Aug 2010 16:05
fixed it. i have a few more questions.

1) how can i make the box transparent, or add a background image thats transparent?

2) how can i add "Press Enter To Continue" to the bottom of the message in the middle?

3) how can i add an id to an object to tell it which object says which messages?



also, here is the Press Enter, but it's not pushing the text that gets typed out up. So the text overlaps.



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 14:47
do you need more
info?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 16:42
update for text code

now freezes moving until text is done.

Still the same problems

as above



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 1st Aug 2010 17:48
Well you can't add this:

into the DisplayteleType function, because your counter is local to your main loop. The function can't access the value of "Counter". Try putting that part of code into the main loop as well, and see if that works.

For the transparent background: You'd have to make your message a sprite and set it's transparency. Would be better performance-wise if you print the text onto the sprite too, so it doesn't call "Text x,y,t$" 20 times per loop.
But all this is pretty complex, and again if you don't know how to achieve it yourself, start with something simpler and work your way up.
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 17:52 Edited at: 1st Aug 2010 17:55
added id code.

still cant get the press enter to work.



i am NOT quitting.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 18:28
cant fix lag



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 1st Aug 2010 19:05
Replace this:

with this:


Fixes jerky movement for me. You have to base all movement on that Speed-Factor when using timerbased movement, i think.

Text-messages look good for me.
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 19:07
text is still slowing it down.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 19:23
forgot to post code.



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 19:29
how would i do that sprite thing that supposedly stops lag now?

i have a sprite code.

but can't figure out how to put the text on the sprite without it lagging then.



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 19:41
small update

still not working



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 1st Aug 2010 19:59
collision update.



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/

Login to post a reply

Server time is: 2026-07-25 08:29:59
Your offset time is: 2026-07-25 08:29:59