components as 'scriptable functions',. .

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

components as 'scriptable functions',. .

Post by jph_wacheski »

I recall someone said something like this before, but it just came up in something I was working on.., it sometimes happens that you have a block of components that you would like to use in a few places,. and a way to use them as a library type function was talked of,. however if some or all the componets where addressable in script form then this would be handled by the current Zlibrary component,. for example;

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Timer Name="ambi_mus_t" Interval="0.1">
  <OnTimer>
    <ZExpression>
      <Expression>
<![CDATA[if (rnd()<.5) ambi_mus_t.interval=.8; else ambi_mus_t.interval=.4;

ambi_mus_nt.noteNr=random(58,3);]]>
      </Expression>
    </ZExpression>
    <PlaySound Name="ambi_mus_nt" Sound="s_bass" NoteNr="64" Channel="3"/>
  </OnTimer>
</Timer>
this Timer and the PlaySound with ZExpression are used in VectorLocust on an AppState to generate some music for the title screen,. however when you access the Info. or the settings,. the music stops. I could copy this to each AppState (but all the names would need to change each time) or add a variable and move it to the main OnUpdate to have it play,. but the point is; if the PlaySound could be done from scripte i.e playSound(s_bass,64,3,0) then I could just write it as a Zlibrary function and call the same thing from anywhere,. perhaps this is not the BEST example but perhaps you can take my intention,. . this script access would be quite usefull form most components,. however perhaps this breaks the architecture of the system,. I still haven't looked too much at the source,. just a thought for consideration.
iterationGAMES.com
Post Reply