link_jr97
2005.01.12, 04:15 PM
Ok the code is below.
I know everyone here is losing their trust in Metal Basic, But I still like using it.
I've decided I'm not going to move into a higher programming language until I've mastered using Metal completely.
This is a simple scripting engine I've made. I got the idea from my dad. I have yet to implement alot of commands but it's pretty straight foreward if you know Metal Programming Language.
Tell me what you think, thanks. This is going to read in external script files later on, then it will execute them. This will be very helpfull when working with fast pace 2d games and maps. This way I won't have to hardcode all the scripts for each level into the main code. :ninja:
'SCRIPTING ENGINE BY TYLER MATWICK FOR METAL BASIC TILE ENGINE/SPRITEWORK'
Gosub initiate
Main:
Gosub Readcommand
Gosub Execute
Goto main
Readcommand:
Input "What do you want?" ;Command$
Return
Execute:
If Left$((Command$),3)="say" Then Command$=Mid$((Command$),4,len(Command$)) : Gosub speak
If Left$((Command$),5)="print" Then Command$=Mid$((Command$),7,len(Command$)) : Gosub printtext
'textcolor command isn't working, debbugging will come later
'If Left$((Command$),9)="forecolor" Then Command$=Mid$((Command$),11,len(Command$)) : Gosub textcolor
If Left$((Command$),4)="beep" Then Command$=Mid$((Command$),5,len(Command$)) : Gosub sound
If Left$((Command$),3)="end" Then Command$=Mid$((Command$),4,len(Command$)) : Gosub quit
If Left$((Command$),10)="opensound1" Then Command$=Mid$((Command$),11,len(Command$)) : Gosub playsound1
If Left$((Command$),10)="opensound2" Then Command$=Mid$((Command$),11,len(Command$)) : Gosub playsound2
If Left$((Command$),10)="opensound3" Then Command$=Mid$((Command$),11,len(Command$)) : Gosub playsound3
If Left$((Command$),10)="stopsound1" Then Command$=Mid$((Command$),11,len(Command$)) : stop movie (movie1)
If Left$((Command$),10)="stopsound2" Then Command$=Mid$((Command$),11,len(Command$)) : stop movie (movie2)
If Left$((Command$),10)="stopsound3" Then Command$=Mid$((Command$),11,len(Command$)) : stop movie (movie3)
If Left$((Command$),11)="startsound1" Then Command$=Mid$((Command$),12,len(Command$)) : start movie (movie1)
If Left$((Command$),11)="startsound2" Then Command$=Mid$((Command$),12,len(Command$)) : start movie (movie2)
If Left$((Command$),11)="startsound3" Then Command$=Mid$((Command$),12,len(Command$)) : start movie (movie3)
Return
printtext:
? command$
Return
speak:
say command$
return
dot:
return
ranword:
return
screenshot:
return
playsound1:
sound$=open dialog$
movie1=open movie (sound$)
start movie (movie1)
return
playsound2:
sound$=open dialog$
movie2=open movie (sound$)
start movie (movie2)
return
playsound3:
sound$=open dialog$
movie3=open movie (sound$)
start movie (movie3)
return
countdown:
return
countup:
return
sound:
beep
return
quit:
:end
return
textcolor:
col1=val(mid$((command$),1,5))
col2=val(mid$((command$),6,10))
col3=val(mid$((command$),11,15))
forecolor col1,col2,col3
return
Initiate:
Set screen to console
cls
? "SCRIPTING ENGINE BY TYLER MATWICK FOR METAL BASIC TILE ENGINE/SPRITEWORK"
? "Press any key to continue"
wait key
Return
I know everyone here is losing their trust in Metal Basic, But I still like using it.
I've decided I'm not going to move into a higher programming language until I've mastered using Metal completely.
This is a simple scripting engine I've made. I got the idea from my dad. I have yet to implement alot of commands but it's pretty straight foreward if you know Metal Programming Language.
Tell me what you think, thanks. This is going to read in external script files later on, then it will execute them. This will be very helpfull when working with fast pace 2d games and maps. This way I won't have to hardcode all the scripts for each level into the main code. :ninja:
'SCRIPTING ENGINE BY TYLER MATWICK FOR METAL BASIC TILE ENGINE/SPRITEWORK'
Gosub initiate
Main:
Gosub Readcommand
Gosub Execute
Goto main
Readcommand:
Input "What do you want?" ;Command$
Return
Execute:
If Left$((Command$),3)="say" Then Command$=Mid$((Command$),4,len(Command$)) : Gosub speak
If Left$((Command$),5)="print" Then Command$=Mid$((Command$),7,len(Command$)) : Gosub printtext
'textcolor command isn't working, debbugging will come later
'If Left$((Command$),9)="forecolor" Then Command$=Mid$((Command$),11,len(Command$)) : Gosub textcolor
If Left$((Command$),4)="beep" Then Command$=Mid$((Command$),5,len(Command$)) : Gosub sound
If Left$((Command$),3)="end" Then Command$=Mid$((Command$),4,len(Command$)) : Gosub quit
If Left$((Command$),10)="opensound1" Then Command$=Mid$((Command$),11,len(Command$)) : Gosub playsound1
If Left$((Command$),10)="opensound2" Then Command$=Mid$((Command$),11,len(Command$)) : Gosub playsound2
If Left$((Command$),10)="opensound3" Then Command$=Mid$((Command$),11,len(Command$)) : Gosub playsound3
If Left$((Command$),10)="stopsound1" Then Command$=Mid$((Command$),11,len(Command$)) : stop movie (movie1)
If Left$((Command$),10)="stopsound2" Then Command$=Mid$((Command$),11,len(Command$)) : stop movie (movie2)
If Left$((Command$),10)="stopsound3" Then Command$=Mid$((Command$),11,len(Command$)) : stop movie (movie3)
If Left$((Command$),11)="startsound1" Then Command$=Mid$((Command$),12,len(Command$)) : start movie (movie1)
If Left$((Command$),11)="startsound2" Then Command$=Mid$((Command$),12,len(Command$)) : start movie (movie2)
If Left$((Command$),11)="startsound3" Then Command$=Mid$((Command$),12,len(Command$)) : start movie (movie3)
Return
printtext:
? command$
Return
speak:
say command$
return
dot:
return
ranword:
return
screenshot:
return
playsound1:
sound$=open dialog$
movie1=open movie (sound$)
start movie (movie1)
return
playsound2:
sound$=open dialog$
movie2=open movie (sound$)
start movie (movie2)
return
playsound3:
sound$=open dialog$
movie3=open movie (sound$)
start movie (movie3)
return
countdown:
return
countup:
return
sound:
beep
return
quit:
:end
return
textcolor:
col1=val(mid$((command$),1,5))
col2=val(mid$((command$),6,10))
col3=val(mid$((command$),11,15))
forecolor col1,col2,col3
return
Initiate:
Set screen to console
cls
? "SCRIPTING ENGINE BY TYLER MATWICK FOR METAL BASIC TILE ENGINE/SPRITEWORK"
? "Press any key to continue"
wait key
Return