This uses cloggy's text plugin.
Here are the functions.
`---------------------------------------------------------------------------------
`I wrote this function but used some code from Cloggy's function
`Make sure to "clear entry buffer" at the end of each loop. Otherwise the text will
`repeat itself until it fills the box. In the program you must put-
`variable$=Cloggy_Input(variable$,...,...,...,...,...)
`Use a different variable and message$ for each input box
`active$ must not be used in the rest of the program, it must be global
`---------------------------------------------------------------------------------
function Cloggy_Input(current$,message$,x,y,font,align)
if active$=message$
active=1
endif
text$=current$
if mouseclick()=1
mx=mousex()
my=mousey()
width=d3d_gettextwidth(font,message$+text$)
height=d3d_gettextheight(font,message$+text$)
if my>y and my<y+height
if align=0 and mx>x and mx<x+width or align=1 and mx>x-width/2 and mx<x+width/2 or align=2 and mx>x-width and mx<x
active=1
active$=message$
endif
else
active=0
endif
endif
if active=1
buf$=entry$()
for i=1 to len(buf$)
select asc(mid$(buf$,i))
case 8
text$=left$(text$,len(text$)-1)
endcase
case 13
endcase
case default
text$=text$+mid$(buf$,i)
endcase
endselect
next i
endif
if active=1
if timer()/500 mod 3=0
cursor$="|"
else
cursor$=" "+chr$(183)
endif
d3d_starttext
d3d_text font,x,y,align,message$+text$+cursor$
d3d_endtext
else
d3d_starttext
d3d_text font,x,y,align,message$+text$+" "+chr$(183)
d3d_endtext
if active$=message$
active$=""
endif
endif
endfunction text$
`---------------------------------------------------------------------------------
`Same as Cloggy_Input except now with it word wraps into a nice little box
`Input Boxes must have a different message$ from other input boxes and regular
`input as they both store it to active$
`active$ must be global
`---------------------------------------------------------------------------------
function Cloggy_Input_Box(current$,message$,x,y,width,height,font,halign,valign)
if active$=message$
active=1
endif
text$=current$
if mouseclick()=1
mx=mousex()
my=mousey()
if my>y and my<y+height and mx>x and mx<x+width
active=1
active$=message$
else
active=0
endif
endif
if active=1
buf$=entry$()
for i=1 to len(buf$)
select asc(mid$(buf$,i))
case 8
text$=left$(text$,len(text$)-1)
endcase
case 13
endcase
case default
text$=text$+mid$(buf$,i)
endcase
endselect
next i
endif
if active=1
if timer()/500 mod 3=0
cursor$="|"
else
cursor$=" "+chr$(183)
endif
d3d_starttext
d3d_boxtext font,x,y,width,height,halign,valign,message$+text$+cursor$
d3d_endtext
else
d3d_starttext
d3d_boxtext font,x,y,width,height,halign,valign,message$+text$+" "+chr$(183)
d3d_endtext
if active$=message$
active$=""
endif
endif
endfunction text$
And a demonstration-
`Demo of both input functions
sync on
sync rate 0
autocam off
global active$
color backdrop 0
d3d_init
d3d_font 1,"Gunsuh",20,0,0,1
d3d_font 2,"Bradley Hand ITC",10,0,0,1
make object cube 1,10
position object 1,0,0,15
d3d_color 10,255,255,200
name$="Enter your name"
yourmessage$="Enter your message"
text$="Enter text"
w=0
do
sync
yrotate object 1,object angle y(1)+0.1
d3d_starttext
d3d_text 1,screen width()/2,10,1,"Input Function Demo",d3d_rgba(255,255,255,128)
d3d_endtext
name$=Cloggy_Input(name$,"Name: ",0,35,2,0)
d3d_box 10,50,screen width()-20,150,d3d_rgba(100,100,0,100)
yourmessage$=Cloggy_Input_Box(yourmessage$,"Text: ",10,50,screen width()-30,95,2,1,0)
d3d_box 100,180,screen width()-100,230,d3d_rgba(100,0,100,200)
text$=Cloggy_Input_Box(text$,"What else do you wish to say: ",100,180,screen width()-210,40,2,2,2)
if returnkey()=1 and w=0
w=50
select active$
case "Name: "
active$="Text: "
endcase
case "Text: "
active$="What else do you wish to say: "
endcase
endselect
endif
if w>0 then dec w
clear entry buffer
loop
`---------------------------------------------------------------------------------
`I wrote this function but used some code from Cloggy's function
`Make sure to "clear entry buffer" at the end of each loop. Otherwise the text will
`repeat itself until it fills the box. In the program you must put-
`variable$=Cloggy_Input(variable$,...,...,...,...,...)
`Use a different variable and message$ for each input box
`active$ must not be used in the rest of the program, it must be global
`---------------------------------------------------------------------------------
function Cloggy_Input(current$,message$,x,y,font,align)
if active$=message$
active=1
endif
text$=current$
if mouseclick()=1
mx=mousex()
my=mousey()
width=d3d_gettextwidth(font,message$+text$)
height=d3d_gettextheight(font,message$+text$)
if my>y and my<y+height
if align=0 and mx>x and mx<x+width or align=1 and mx>x-width/2 and mx<x+width/2 or align=2 and mx>x-width and mx<x
active=1
active$=message$
endif
else
active=0
endif
endif
if active=1
buf$=entry$()
for i=1 to len(buf$)
select asc(mid$(buf$,i))
case 8
text$=left$(text$,len(text$)-1)
endcase
case 13
endcase
case default
text$=text$+mid$(buf$,i)
endcase
endselect
next i
endif
if active=1
if timer()/500 mod 3=0
cursor$="|"
else
cursor$=" "+chr$(183)
endif
d3d_starttext
d3d_text font,x,y,align,message$+text$+cursor$
d3d_endtext
else
d3d_starttext
d3d_text font,x,y,align,message$+text$+" "+chr$(183)
d3d_endtext
if active$=message$
active$=""
endif
endif
endfunction text$
`---------------------------------------------------------------------------------
`Same as Cloggy_Input except now with it word wraps into a nice little box
`Input Boxes must have a different message$ from other input boxes and regular
`input as they both store it to active$
`active$ must be global
`---------------------------------------------------------------------------------
function Cloggy_Input_Box(current$,message$,x,y,width,height,font,halign,valign)
if active$=message$
active=1
endif
text$=current$
if mouseclick()=1
mx=mousex()
my=mousey()
if my>y and my<y+height and mx>x and mx<x+width
active=1
active$=message$
else
active=0
endif
endif
if active=1
buf$=entry$()
for i=1 to len(buf$)
select asc(mid$(buf$,i))
case 8
text$=left$(text$,len(text$)-1)
endcase
case 13
endcase
case default
text$=text$+mid$(buf$,i)
endcase
endselect
next i
endif
if active=1
if timer()/500 mod 3=0
cursor$="|"
else
cursor$=" "+chr$(183)
endif
d3d_starttext
d3d_boxtext font,x,y,width,height,halign,valign,message$+text$+cursor$
d3d_endtext
else
d3d_starttext
d3d_boxtext font,x,y,width,height,halign,valign,message$+text$+" "+chr$(183)
d3d_endtext
if active$=message$
active$=""
endif
endif
endfunction text$
I called them Cloggy_Input and Cloggy_Input_Box to remind myself to have d3d_init before them. (Cloggy does not endorse these functions
) If you are going to use them you also have to make active$ global and clear entry buffer each loop with input in it. I had to put a dot after the text, because I found that when Cloggy's function centers text is does not include spaces after the text.
You don't need to ask to use them.