i want to make some sort of scripting for my game, and what i had in mind is to incorporate something like mechanism for handling materials at evolved's advanced lighting. But i get confused by what evolved did with his scripting system.
my approach is: these are the function used for scripting
`--------------
` Get Key/Val
`--------------
function KeyValue_Get(S$)
r=0
for s=0 to len(S$)
if mid$(S$,s)="=" then r=1
next s
endfunction r
function KeyValue_Key(S$)
mid=0
repeat
mid=mid+1
until mid$(S$,mid)="=" or mid$(S$,mid)=";" or mid$(S$,mid)=""
St$=left$(S$,mid-1)
if mid$(St$,len(St$))=";" then St$=left$(St$,len(St$)-1)
endfunction St$
function KeyValue_Value(S$)
mid=0
repeat
mid=mid+1
until mid$(S$,mid)="=" or mid$(S$,mid)=";" or mid$(S$,mid)=""
St$=Right$(S$,(len(S$)-1)-(mid-1))
if mid$(St$,len(St$))=";" then St$=left$(St$,len(St$)-1)
endfunction St$
function KeyValue_InnerValue(S$,i)
v=0
for t=0 to i
a$=""
repeat
a$=a$+mid$(S$,v):v=v+1
until mid$(S$,v)="," or mid$(S$,v)=";" or mid$(S$,v)=""
v=v+1
next t
r#=val(a$)
endfunction r#
function GetString(script$,string$)
script#=find free file()
if file exist(script$)=1
open to read script#,script$
repeat
read string script#,S$
if KeyValue_Get(S$)=1
if KeyValue_Key(S$)="common"
read string 1,string$
if string$="{"
repeat
read string script#,string$
if KeyValue_Get(string$)=1
Val$=KeyValue_Value(string$)
if Key$=string$
WriteLog(Val$)
endif
endif
until string$="" or string$="}"
endif
endif
endif
until S$=""
close file script#
endif
endfunction
and this is a script file
common
{
str_00001=Fists
}
and the script would be called before main game loop
GetString("strings.data","str_00001")
with this i wanted to make first step in my scripting system by writing a string after '=' in the script file to the log file, but it doesn't work, can someone help me with this?