3D textsystem - VERY FEW problems

Blitz3D Forums/Blitz3D Programming/3D textsystem - VERY FEW problems

Guy Fawkes(Posted 2011) [#1]
Hi all, I have decided to release my text code to the public. I would give credit to the creator, but the creator said he didn't want any credit due to how screwy the code looks. it works like a charm though. but i'm gonna give him / her credit anyway. Credit: The Creator / Rez.

I credit myself as well as I added a few new features to this textsystem including only activating the textbox when you're both A) Near a character, and B) Looking close to straight at him.

ANYWAYS, without further adieu, the screenshot:



and the zip file:

http://www.mediafire.com/?ijf4lp797ew3hu1

Enjoy, and hopefully you guys can help me fix this with the below fixes, once and for all! :)


Guy Fawkes(Posted 2011) [#2]
im still having a bit of an issue. u see, i want it when i talk to a character the second time, to revert to a 2nd message and stay on that second message.

i also need for it to check and see if the end of the paragraph has been reached, if it has, set the timer for 30 seconds which is about 2 seconds in game time, and press enter automatically for u if the user hasnt already. if they have pressed enter, stop the timer from running and reset it.

i also need it so it detects if your close to a hidden pivot, in which case, auto start the story and do the above. :)


Guy Fawkes(Posted 2011) [#3]
anyone?


Guy Fawkes(Posted 2011) [#4]
Can someone please help me with this? It is SO close to being done T_T I just wanna see it done.


Axel Wheeler(Posted 2011) [#5]
Um, among the possible reasons no one responded to this:

1. The mediafire page also downloaded a "Setup243.exe" file that I certainly did not ask for.

2. What is that gibberish in the upper left corner "I_want_key_advance"?

3. No text box comes up, unless I hit Enter, and then a blank one comes up. What exactly is supposed to happen?

4. You need to ask for something more distinct, with a small chunk of code that illustrates the problem.

Good luck...


Guy Fawkes(Posted 2011) [#6]
1. I wasn't aware the mediafire page was forcing u to download something other than the demo. I will switch hosts.

2. those are debug variables

3. when u get close, and i_want_keypress = 0 then i_want_key_advance = 1, and if it is 1, then if u get close enough, it is supposed to auto talk to the object the player is close to, and it should have a timer to slow down the advance of the object talking.

4. this is basically all i need TO illustrate the problem.


Who was John Galt?(Posted 2011) [#7]
4. this is basically all i need TO illustrate the problem.
That's not what Axel means. You're asking for help and you're much more likely to get it if you can post a short code snippet that demonstrates the problem here. That does not mean paste the entire source in a code box; it means cut out the unrelated stuff so we can see the problem in a basic form.


Rob the Great(Posted 2011) [#8]
So...you've already written a word wrapper. I'm confused, what was the problem in your other post? Maybe I didn't quite follow the question.


Guy Fawkes(Posted 2011) [#9]
I already have a 98% working word wrapper for my game's story.

The thing I need, is a word wrapper for my NPC's names above their heads :)


Graythe(Posted 2011) [#10]
Why not use the one that's 98% working? With fewer characters the error quotient should be less than one character and therefore invisible.


Ross C(Posted 2011) [#11]
I believe the problem is the word wrapping function he got, I wrote. It word wraps and scrolls the letters one by one. I don't think Rez knows enough about how it works to get it just to word wrap the words, without the scrolling, and limit the line width.

I have a word wrap function I wrote for my text adventure that takes an image and margins, and wraps the text to that image width. I would post it here, but I know that i'll get tons of requests to modify it beyond it's orginal usage. So, i'll post it here later, but I don't have any time to go through it and modify it. It is mostly self contained and anyone can use it (Though I reckon most folk here can knock together there own. Might save some time?)

Last edited 2011


Ross C(Posted 2011) [#12]
Here is the text wrapping function I wrote. It is heavily cut down from my own version I used, as it processed tags and what not, and therefore might be on the heavy side code wise:

All you need is a string of text you wish to wrap, an image to write to, and a font. I have put the need of a font as I changed the font quite alot in my game. You could replace this with stringheight() if need be. Take it as it is :)


Graphics 800,600
SetBuffer BackBuffer()

; you are best creating a duplicate sized image to display the text on.
Global test_image = CreateImage(400,400)

Global test_text$ = "Hello, I want this piece of text to be wrapped across the image, and across multiple line. Here's hoping it works! Only spaces are used as word seperators."

Global font = LoadFont("Arial",12)


While Not KeyHit(1)

	Cls
	
	
	If KeyHit(57) Then
		text_wrap(test_text,font,test_image)
	End If
	
	DrawImage test_image,10,10

	Flip
Wend
End




;--------------------------------------------------------------------------;
; text_to_wrap = the entire text line you want to wrap
; font = the current font used. This must be provided.
; image = the image the text is being drawn onto. The text will wrap to the image width. Doesn't check height, so be generous!
; line_spacing = the line spacing between lines. OPTIONAL
; left_margin, top_margin and right margin. All specify distance from the edge of the image.

Function text_wrap(text_to_wrap$,font,image,line_spacing = -1, left_margin = 5, top_margin = 5, right_margin = 5)

	;item_count ; number of items in the array. Sent from another function, directly based of of no_of_current_items
	Local start_x = left_margin
	Local start_y = top_margin

	Local text_char = 1
	Local text_line = 0
	Local max_line_width = ImageWidth(image) - left_margin - right_margin
	Local word_spacing = -1 ; -1 = use the strings current spacing, any other number, use that distance
	Local word$ = "" ; use this to return a word from "read_next_word" function
	Local tstring$ = ""
	
	Local finish = 0
	Local font_height = FontHeight()
	SetBuffer ImageBuffer(image)

	Repeat

		word$ = read_next_word$(text_to_wrap$,text_char)


		If word = "<NOMOREWORD>" Then

			finish = 1

			tstring = trim_space_from_front(tstring)

			Text start_x,start_y ,tstring$ ; draw string to image

		Else

			;---------------------------------------------;
			; If word takes line length over maximum then ;
			;---------------------------------------------;
			If StringWidth(tstring+word) > max_line_width Then
	
				tstring = trim_space_from_front(tstring)
	
				Text start_x,start_y ,tstring$ ; draw string to image
				text_line = text_line + 1
	
				If line_spacing = -1 Then
					start_y = start_y + font_height
				Else
					start_y = start_y + line_spacing
				End If
	
				text_char = text_char + Len(word)
				tstring = ""
				tstring = tstring + word 
				
			Else
				tstring = tstring + word 
				text_char = text_char + Len(word)
			End If
		End If



	Until finish = 1
	
	SetBuffer BackBuffer()
	
End Function


Function trim_space_from_front$(t_string$)


	If Mid$(t_string,1,1) = " " Then
		;DebugLog(" line starts with a space #"+t_string)
		t_string = Mid(t_string,2,Len(t_string)-1)
		;DebugLog("           line now reads #"+t_string)
	End If

	Return t_string

End Function




;-----------------------------------------------------------;
; This function will return the next whole word as a string ;
;-----------------------------------------------------------;

Function read_next_word$(search_text$,char)

	Local start_char = char
	Local finish_char = char - 1
	Local finish = 0
	Local return_string$ = ""

	Repeat

		finish_char = finish_char + 1

		If Mid$(search_text,finish_char,1) = " " Then ; if the last char is a space then
			finish = 1
			If finish_char = start_char Then
				return_string = " "
				DebugLog("   read_next_word() - Returning - '"+return_string+"'. Returned because of first char space")
			Else
				DebugLog("   read_next_word() - Returning - '"+return_string+"'")
				return_string = Mid(search_text,start_char,finish_char-start_char)
			End If
		End If

		If finish = 0 Then
			If start_char => Len(search_text) Then
				If Mid(search_text,start_char,1) = "." Then
					return_string = "."
				Else
					return_string = "<NOMOREWORD>"
				End If
				DebugLog("   read_next_word() - Returning - "+return_string)
				Return return_string
			End If
			If finish_char > (Len(search_text)-1) Then
				return_string = Mid(search_text,start_char,finish_char-start_char+1)
				;DebugLog("   read_next_word() - Returning - '"+return_string+"'. Returned because of end of string.")
				Return return_string
			End If
		End If
	
	Until finish = 1

	Return return_string

End Function



stayne(Posted 2011) [#13]
Thanks Ross