Posted: 18th Sep 2003 5:45
this is a bit of code i finally came up with to make a chat routine in DBC
it allows you to type and the game still updates and runs
the coordinates for the chat are based on 800x600 screen and are on the bottom of the screen

i have tried for/next loops to just eliminate the repeating of the two areas but it just doesnt work

+ Code Snippet
sync on
sync rate 30
set dislpay mode 800,600,32
dim chat$(5)

DO
	rem chat routine
	if returnkey()=1
		if line$="" then goto skip
		chat$(5)=chat$(4)
		chat$(4)=chat$(3)
		chat$(3)=chat$(2)
		chat$(2)=chat$(1)
		chat$(1)=line$
		line$=""
		goto skip
	endif
	new$=entry$()
	for n=1 to len(new$)
		if asc(mid$(new$,n))=8
			line$=left$(line$,len(line$)-1)
		else
			line$=line$+mid$(new$,n)
		endif
	next n
	skip:
	clear entry buffer
	text 0,584-75,chat$(5)
	text 0,584-60,chat$(4)
	text 0,584-45,chat$(3)
	text 0,584-30,chat$(2)
	text 0,584-15,chat$(1)
	text 0,584,line$
loop
Posted: 18th Sep 2003 16:10
does any one know how to do a loop in my code up there so you wont have to repeat those commands up there?
Posted: 18th Sep 2003 17:09
i do not understand the question. perhaps this should be in the newcombers section. If your code works, just drop it into a function and forget about it until needed. If you just wish to have someone show you how to make it neater, thats a newbe question.

the way i would place it into a function is.....
dim Chat$(5)
function GetUserChat()
rem chat routine
if returnkey()=1
for n=5 to 1 step -1
Chat$(n)=Chat$(n-1)
next n
Chat$(0)=""
else
new$=entry$()
for n=1 to len(new$)
if asc(mid$(new$,n))=8
Chat$(0)=left$(Chat$(0),len(Chat$(0))-1)
else
Chat$(0)=Chat$(0)+mid$(new$,n)
endif
next n
clear entry buffer
endif

endfunction
function ShowChat(x#,y#)
yp#=0
for n=5 to 0 step -1
text x#,y#+yp#,chat$(n)
yp#=yp#+15
next n

endfunction

in this manner, you can display your text anywhere just by changing the x/y in the function call.