just use something like this:
read string 1, buffer$
if buffer$ <> ""
buffer$ = upper$(buffer$)
select buffer$
case "MOVE"
move object 1, 10.0
endcase
endselect
endif
if the computer reads
move it will move object 1. Pretty simple. Here's the code I use in DarkZ as basic script interpreter:
(its not commented)
function script(n$,frame,pscore)
if frame_script_delay > 0 then dec frame_script_delay
if file open(1)=0 and score_wait <> -1000
if file exist(n$)=1 then open to read 1,n$
else
if (frame_wait = -1 or frame = frame_wait) and (score_wait = -1 or pscore = score_wait)
if pscore = score_wait then score_wait = -1
if frame = frame_wait then frame_wait = -1
while frame_wait =-1 and score_wait =-1 and upper$(buffer$)<>"[END]"
read string 1, buffer$
if len(buffer$)>0
prebuffer$ = upper$(mid$(buffer$,1))
select prebuffer$
rem pScore Wait
case "S"
buffer = 1
while mid$(buffer$,buffer)<>":" and len(buffer$)<>buffer: inc buffer : endwhile
if buffer <> len(buffer$)
inc buffer
prebuffer = 0
for a = 0 to len(buffer$)-buffer
prebuffer = prebuffer + (val(mid$(buffer$,len(buffer$)-a))*(10^a))
next a
score_wait = prebuffer
endif
endcase
case "M"
endcase
case "T"
buffer = 1
while mid$(buffer$,buffer)<>chr$(34) and len(buffer$)<>buffer: inc buffer : endwhile
if buffer <> len(buffer$)
inc buffer
tekst$ = ""
while mid$(buffer$,buffer)<>chr$(34)
tekst$ = tekst$ + mid$(buffer$,buffer)
inc buffer
endwhile
endif
if buffer <> len(buffer$)
inc buffer
prebuffer = 0
for a = 0 to len(buffer$)-buffer
prebuffer = prebuffer + (val(mid$(buffer$,len(buffer$)-a))*(10^a))
next a
ink 0,0
box 0,81,639,115
ink rgb(255,255,255),0
center text 320,85,tekst$
sync
wait prebuffer
ink 0,0
box 0,81,639,115
ink rgb(255,255,255),0
else
center text 320,85,tekst$
endif
endcase
case "C"
read string 1,prebuf$
img = val(prebuf$)
read string 1,prebuf$
x = val(prebuf$)
read string 1,prebuf$
y = val(prebuf$)
sprity = 3000
while sprite exist(sprity)=1 : inc sprity : endwhile
if sprity =< 3500
enemy_status(sprity-3000,1)=0
enemy_status(sprity-3000,4)=img
enemy_status(sprity-3000,6)=2
if sprity > highest_esprite then highest_esprite = sprity
sprite sprity,x,y,img
set sprite sprity,0,1
endif
endcase
case "F"
endcase
endselect
endif
endwhile
if upper$(buffer$)="[END]" then score_wait = -1000 : close file 1
endif
endif
endfunction
This piece of code can read and execute 4 instructions, depending on the letter it reads. This is the level1.txt script:
/Level 1 - Script Language DarkZ-Script
S: 10
/M: 200,4,"Commander: Another wave is approaching"
T: "Commander: Don't let them take New Terra",2000
C:
4
630
90
C:
4
630
120
C:
4
630
440
C:
4
630
470
S: 30
/M: 200,4,"Commander: Another wave is approaching"
T: "Commander: We've send a power-up crate for your weapons",2000
C:
4
630
90
C:
4
630
120
C:
4
630
150
C:
4
630
180
C:
4
630
380
C:
4
630
410
C:
4
630
440
C:
4
630
470
[END]
/C: 3000,630,280