Phaelax,
Thank you for sharing your editor. That is a bit ambitious for what I need, but the priciples you use are great.
Here is look at the nearly final DB that I made for my game.
It doesn't save yet, because I haven't decided what the best format will be. But here is the non-media code, if anyone is interested.
You <tab> forward, <shift-tab> back, or mouse-click in the fields to access.
Let me know what you think. I know it can be optimized, but that's for later.
`DBPro Quest Creator
`by J. Keyes (a.k.a. Dracula)
`11/09/06
set display mode 800,600,32
dim inpt$(17) as string
dim dialogue$(17,5) as string
dim fname$(17) as string
keypress=0
bskey=0
dim flno(17)
dialine=1
tim=timer()
fieldnum=1
for z=1 to 17
flno(z)=1
next z
`load image "quest_gen_background.png",2,1
`main loop
do
cls
mx=mousex()
my=mousey()
`paste image 2,0,0
`text 600,56,"sc="+str$(scancode())+" f#="+str$(fieldnum)+" bs="+str$(bskey)
`text 600,70,"dialine="+str$(dialine)+" flno("+str$(fieldnum)+")="+str$(flno(fieldnum))
Co=RGB(125,0,0):ink co,1
make_boxes()
`grab keystrokes and prevent unwanted repetition
if scancode()<>14 and keypress=0 or right$(entry$(),1)=right$(inpt$(i),1) and inkey$()<>"" and timer()>tim+250 and scancode()<>14 or right$(entry$(),1)=right$(dialogue$(fieldnum,dialine),1) and inkey$()<>"" and timer()>tim+250 and scancode()<>14
if asc(right$(entry$(),1))>31 and asc(right$(entry$(),1))<124
if fieldnum<13
inpt$(fieldnum)=inpt$(fieldnum)+right$(entry$(),1)
endif
if fieldnum>12
flno(fieldnum)=dialine
dialogue$(fieldnum,dialine)=dialogue$(fieldnum,dialine)+right$(entry$(),1)
if len(dialogue$(fieldnum,dialine))>97 and dialine<6
dialine=dialine+1
flno(fieldnum)=dialine
endif
if dialine>5
dialine=5
endif
endif
keypress=1
clear entry buffer
kbe$=right$(entry$(),1)
tim=timer()
endif
endif
`ready for another keystroke
if right$(entry$(),1)<>right$(inpt$(fieldnum),1) or right$(entry$(),1)<>right$(dialogue$(fieldnum,dialine),1)
keypress=0
endif
`backspace and prevent unwanted repetition
if scancode()=14 and len(inpt$(fieldnum))>0 and bskey=0 or scancode()=14 and len(dialogue$(fieldnum,dialine))>0 and bskey=0
if fieldnum<13
inpt$(fieldnum)=left$(inpt$(fieldnum),len(inpt$(fieldnum))-1)
endif
if fieldnum>12
dialogue$(fieldnum,dialine)=left$(dialogue$(fieldnum,dialine),len(dialogue$(fieldnum,dialine))-1)
endif
bskey=1
tim=timer()
endif
`backspace to previous line if in fields 13-17
if scancode()=14 and fieldnum>12 and len(dialogue$(fieldnum,dialine))=0 and bskey=0
if dialine>1 and flno(fieldnum)>1
dialine=dialine-1
flno(fieldnum)=dialine
endif
endif
if scancode()=0 and bskey=1 or bskey=1 and timer()>tim+125
bskey=0
tim=timer()
endif
`tab to next field
if scancode()=15 and bskey=0 and fieldnum<18 and shiftkey()=0
bskey=1
fieldnum=fieldnum+1
tim=timer()
if fieldnum>12
dialine=flno(fieldnum)
endif
endif
`shift+tab to previous field
if scancode()=15 and shiftkey()=1 and fieldnum>1 and bskey=0
bskey=1
fieldnum=fieldnum-1
tim=timer()
endif
`F12 Save Data Function
if scancode()=88
save_data(i)
fieldnum=1
endif
`move to field via mouse click
`fields 1-6
if mx>103 and mx<163 and my<169
if mouseclick()=1
for ymouse=0 to 5
if my>ymouse*28 and my<((ymouse+1)*28)+1
fieldnum=ymouse+1
endif
next ymouse
endif
endif
`field 7
if mx>259 and mx<670 and my<28 and mouseclick()=1
fieldnum=7
endif
`fields 8-12
if mx>490 and mx<565 and my<169
if mouseclick()=1
for ymouse=1 to 5
if my>ymouse*28 and my<((ymouse+1)*28)+1
fieldnum=ymouse+7
endif
next ymouse
endif
endif
`fields 13-17
if my>179 and my<592
if mouseclick()=1
for ymouse=0 to 4
if my>(ymouse*84)+179 and my<((ymouse+1)*84)+180
fieldnum=ymouse+13
dialine=flno(fieldnum)
endif
next ymouse
endif
endif
`fields 1 - 6, allow 4 chars per field
for lin=1 to 6
if len(inpt$(lin))>4
inpt$(lin)=left$(inpt$(lin),4)
endif
next lin
`field 7 allow 50 chars.
if len(inpt$(7))>50
inpt$(7)=left$(inpt$(7),50)
endif
`fields 8-12 allow 8 chars per line
for lin=8 to 12
if len(inpt$(lin))>8
inpt$(lin)=left$(inpt$(lin),8)
endif
next lin
`fields 13-17 allow 98 chars per line (5 dialines in dialogue$(1-5))
for dlin=1 to 5 `field
for lin=1 to 5 `subfield
if len(dialogue$(dlin,lin))>98
dialogue$(dlin,lin)=left$(dialogue$(dlin,lin),98)
endif
next lin
next dlin
`show the text, do not allow cursor to remain on above lines
for z=0 to 5
if z=fieldnum-1
text 104,(z*14)*2,inpt$(z+1)+"_"
else text 104,(z*14)*2,inpt$(z+1)
endif
next z
`place quest name in field 7
if fieldnum=7
text 265,0,inpt$(7)+"_"
else text 265,0,inpt$(7)
endif
`show text for fields 8-12
for z=8 to 12
if z=fieldnum
text 492,((z-7)*14)*2,inpt$(z)+"_"
else text 492,((z-7)*14)*2,inpt$(z)
endif
next z
`show text for fields 13-17
for z=0 to 4
for z1=0 to 4
if z=fieldnum-13 and z1=dialine-1
text 0,((z*84)+(183+(z1*14))),dialogue$(z+13,z1+1)+"_"
else text 0,((z*84)+(183+(z1*14))),dialogue$(z+13,z1+1)
endif
next z1
next z
`text 600,28,"mx="+str$(mx)
`text 600,42,"my="+str$(my)
loop
function make_boxes()
restore fields
for f=1 to 17
read fname$(f)
next f
for f=0 to 5
text f,(f*14)*2,fname$(f+1)
text f+175,(f*14)*2,fname$(f+7)
next f
text 1,(6*14)*2,fname$(13)
for f=14 to 17
text 1,((f-1)*14)+(70*(f-13)),fname$(f)
next f
endfunction
function save_data(i)
while inkey$()<>"y" or inkey$()<>"Y" or inkey$()<>"n" or inkey$()<>"N"
Co=RGB(175,100,0):ink co,1
text 1,120,"Do you wish to save this text in a file? (y)es or (n)o"
for z=1 to i
text 1,z*14,inpt$(z)
next z
if inkey$()="y" or inkey$()="Y"
text 96,134,"Very Well..."
if file exist("f:save.txt")=0
open to write 1,"f:save.txt"
for z=1 to 5
write string 1,inpt$(z)
inpt$(z)=""
next z
close file 1
endif
cls
exitfunction
endif
if inkey$()="n" or inkey$()="N"
text 96,132,"In that case, please continue above..."
exitfunction
endif
endwhile
endfunction
fields:
data "Zone Number:","Quest Num:","NPC Number:","X Location:","Y Location:","Reward Item:"
data "Quest Name:","Level Spec. #### (00 to 99):","Class Spec. ##### (0=no / 1=yes):"
data "Race Spec. ######## (0=no / 1=yes):","Cha. Spec. ######## (+/-000 to +/-999):"
data "Prereq. Item #### (0/1 + item number):"
data "Dialogue I (offer quest) 497 chars max.:"
data "Dialogue II (complete) 497 chars max.:"
data "Dialogue III (incomplete) 497 chars max.:"
data "Dialogue IV (partial completion) 497 chars max.:"
data "Dialogue V (refuse quest option) 497 chars. max.:"
Thanks,
D