Experimenting some more with the scripting language.
Previously we added the
script base component invocation syntax which allowed things like this:
Code: Select all
@SpawnModel(Model : TitleScreenModel);
You could use command components in scripting
without having to add them to the project tree.
Now I've taken this further to allow the syntax for values in expressions as well.
A couple of examples:
Code: Select all
//Play a sound
Sound snd;
snd = @Sound(); //Create and define a new sound
@PlaySound(Sound : snd, NoteNr : 65); //Play it
Note that
this code is completely self-contained. Previously it would have needed a Sound component in the project. It can even be more compact (and hard to read?

):
Code: Select all
@PlaySound( Sound : @Sound(Osc1WaveForm : 1) , NoteNr : 60);
Write to a file:
Code: Select all
//Write to file
byte[256] buf;
for(int i=0; i<buf.SizeDim1; i++)
buf[i]=i;
File f = @File(FileName : "test.txt", Encoding : 1, TargetArray : buf);
@FileAction(File : f, Action : 1);
Or with compact syntax:
Code: Select all
@FileAction(File : @File(FileName : "test.txt", Encoding : 1, TargetArray : buf),
Action : 1);
Read from file:
Code: Select all
//Read from file
byte[256] buf;
File f = @File(FileName : "test.txt", Encoding : 1, TargetArray : buf);
@FileAction(File : f, Action : 0);
for(int i=0; i<buf.SizeDim1; i++)
if(i!=buf[i])
trace("error when reading");
It gives freedom to do more in scripting with components without having to first add them to the project tree. Some prefer component and others want to do everything in scripting so this gives more choice I think.
http://www.zgameeditor.org/files/ZGameEditor_beta.zip