Word Engine by Caleb73rd Aug 2009 0:26
|
---|
Summary This provides simple notepad interface, allowing the machine to constantly refresh the array and apply any saved changes. Description This provides simple notepad interface, allowing the machine to constantly refresh the array and apply any saved changes. While simple, this proves to be exceptionally usefull in RPG games when the Artificial Characters need to call you by name. It allows for a more interactive conversation between you and the Computer. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com set display mode 1024,768,16 set window size 1040,804 sync on sync rate 15 ink RGB(0,0,0),RGB(255,255,255) cls RGB(255,255,255) dim mscript$(10) mscript$(0)="Write in the notepad and save it. /$/double underlined/$/ /&/underlined/&/ /*/ Bold Black /blue/ Blue /brown/ Brown /green/ Green" mscript$(1)="/red/ Red /orange/ Orange /purple/ Purple /yellow/ Yellow /grey/ Grey/black */.You can even save an array as a Random Noun, Adjective or Verb" mscript$(2)=" and fill it with tons of random words to build a random sentence generator... Its fun to see what the computer comes up with" Global h$ h$="/" if file exist("Current Text.txt")=1 then load array "Current Text.txt",mscript$(10) else save array "Current Text.txt",mscript$(10) execute file "Current Text.txt","","" set text font "Arial" set text size 20 do load array "Current Text.txt",mscript$(10) : script$=mscript$(10) cls RGB(255,255,255) tx=0 ty=0 underline=0 doubleline=0 for s=0 to 10 if len(mscript$(s))>0 script$=mscript$(s) for l=1 to len(script$) letter$=Mid$(script$,l) Rletter$=lower$(Mid$(script$,l)) lh=text height(letter$) lw=text width(letter$) if letter$=h$ then inc skip : if skip>1 then skip=0 : hold=1 if skip=0 if hold=0 Text tx,ty,letter$ if underline=1 then line tx,ty+lh-2,tx+lw,ty+lh-2 if doubleline=1 then line tx,ty+lh-2,tx+lw,ty+lh-2 : line tx,ty+lh,tx+lw,ty+lh inc tx,lw if tx>screen width()-100 and letter$=" " then inc ty,lh : tx=0 endif else cword$=lower$(getword(script$,l,14)) if letter$="&" then inc underline : if underline>1 then underline=0 if letter$="$" then inc doubleline : if doubleline>1 then doubleline=0 if letter$="*" inc bold if bold>1 then bold=0 if bold=0 then set text font "Arial" else set text font "Arial Bold" endif if Rletter$="b" if cword$="black" then ink RGB(0,0,0),RGB(255,255,255) if cword$="blue" then ink RGB(0,0,255),RGB(255,255,255) if cword$="brown" then ink RGB(128,64,0),RGB(255,255,255) endif if Rletter$="g" if cword$="green" then ink RGB(0,128,0),RGB(255,255,255) if cword$="grey" then ink RGB(128,128,128),RGB(255,255,255) endif if cword$="orange" then ink RGB(255,128,0),RGB(255,255,255) if cword$="purple" then ink RGB(128,0,128),RGB(255,255,255) if cword$="red" then ink RGB(255,0,0),RGB(255,255,255) if cword$="white" then ink RGB(255,255,255),RGB(255,255,255) if cword$="yellow" then ink RGB(255,255,0),RGB(255,255,255) if cword$="randomv" then Ran$=randomV(10) : Text tx,ty,Ran$ : inc tx,text width(Ran$) if cword$="randomvp" then Ran$=randomVP(10) : Text tx,ty,Ran$ : inc tx,text width(Ran$) if cword$="randomn" then Ran$=randomN(10) : Text tx,ty,Ran$ : inc tx,text width(Ran$) if cword$="randoma" then Ran$=randomA(17) : Text tx,ty,Ran$ : inc tx,text width(Ran$) if cword$="myname" then Text tx,ty,myName$ : inc tx,text width(myName$) endif hold=0 next l endif next s sync dly=0 while joystick fire a()=0 and inkey$()="r" and mouseclick()=0 inc dly if dly>100 then exit endwhile loop function getword(txt$,start,mx) word$="" for l=start to start+mx if Mid$(txt$,l)=" " or Mid$(txt$,l)=h$ then exit word$=word$+Mid$(txt$,l) next l endfunction word$ function randomV(total) dim random$(total) load array "RandomVerb.txt",random$(total) ran$=random$(rnd(total)) endfunction ran$ function randomVP(total) dim random$(total) load array "RandomVerbPastT.txt",random$(total) ran$=random$(rnd(total)) endfunction ran$ function randomN(total) dim random$(total) load array "RandomNoun.txt",random$(total) ran$=random$(rnd(total)) endfunction ran$ function randomA(total) dim random$(total) load array "RandomAdjective.txt",random$(total) ran$=random$(rnd(total)) endfunction ran$ |