List Info

Thread: external scripts, projectors, & "magical a-life avatars"




external scripts, projectors, & "magical a-life avatars"
user name
2006-11-30 16:58:32
Looking through the archives of this list and other
resources on the
web, I've been discouraged to find that you can't have an
external
linked script (.ls) file that can be changed-on-the-fly
without
opening Director and updating it. But I want to do more than
just use
an external editor like BBEdit.

I have had some volunteers who think they can improve the AI
on my
multiuser game, and I don't want to open up the whole code,
just give
them a protected file, preferably a projector, with a folder
for some
external files with basic functions that can be built on.

I'm guessing Macromedia's policy has always been, "you
want to write a
line of Lingo? buy Director" and as usual at the
expense of more
advanced programming techniques, such as the ability to
encapsulate a
project and use external libraries.

On the other hand, I remember Peter Small's strange book
"Magical
A-life Avatars" which proposed a model of people using
stub projectors
and exchanging scripts which would theoretically be
recompiled
on-the-fly.

Now, I can't find that book around the house, and I don't
remember if
anyone, Small included, ever really got that trick to work.
But if it
was possible, or is now with MX04, can someone please drop
me a
hint...

Thanks -- Alec
_______________________________________________
dirGames-L mailing list  -  dirGames-Lnuttybar.drama.uga.edu
http://nuttybar.drama.uga.edu/mailman/listinfo/dirgames
-l
external scripts, projectors, & "magical a-life avatars"
user name
2006-11-30 17:55:01
Alec Vance wrote:
> Looking through the archives of this list and other
resources on
> the web, I've been discouraged to find that you can't
have an
> external linked script (.ls) file that can be
changed-on-the-fly
> without opening Director and updating it.

Hi Alec,

Be discouraged no longer.  Call this handler or
prepareMovie():

on UpdateScripts()
---------------------------------------------------
  -- ACTION: Checks a given folder for *.ls files whose
names match
  --         existing script members, and replaces the
scriptText of
  --         those members with the contents of the *.ls
files.
 
------------------------------------------------------------
--------
  
  vFolder = the moviePath -- or a different folder
  vFileIO = xtra("fileio").new() -- assumed to be
available
  
  the itemDelimiter = "."
  n = 0
  repeat while TRUE
    n = n + 1
    vFileName = getNthFileNameInFolder(vFolder, n)
    
    if vFileName = "" then
      -- There are no more files
      exit repeat
    end if
    
    if the last item of vFileName = "ls" then
      -- We've found an *.ls file.  Let's see if its name
matches
      -- a script in this movie
      vFilePath = vFolder&vFileName
      
      delete the last item of vFileName
      vMember = member(vFileName)
      
      if ilk(vMember) = #member then
        if vMember.type = #script then
          -- Read in the new scriptText of this member
          vFileIO.openFile(vFilePath, 1) -- Read only
          vScriptText = vFileIO.readFile()
          
          if not vFileIO.status() then
            -- The following line will cause a script error
if the
            -- contents of the file cannot be compiled.
            vMember.scriptText = vScriptText
          end if
          
          vFileIO.closeFile()
        end if
      end if
    end if
  end repeat
end UpdateScripts

Tested for you in a projector.  Be sure to include the
fileio xtra.

Cheers,

James

_______________________________________________
dirGames-L mailing list  -  dirGames-Lnuttybar.drama.uga.edu
http://nuttybar.drama.uga.edu/mailman/listinfo/dirgames
-l
external scripts, projectors, & "magical a-life avatars"
user name
2006-11-30 18:05:39

Thursday, November 30, 2006, 4:58:32 PM, Alec wrote:

AV> Looking through the archives of this list and other
resources on the
AV> web, I've been discouraged to find that you can't
have an external
AV> linked script (.ls) file that can be
changed-on-the-fly without
AV> opening Director and updating it. 

You can do this, but you have to load the text into director
and then set the scriptText of an interal script cast
member. I just tested it and it worked, using this:

-----------------------------------------
on startMovie
  
  tempMem = new(#text)
  tempMem.fileName = _movie.path &
"externalBehaviorScript.txt"
  tempScript = tempMem.text
  tempMem.erase()
  
  member("custom behaviour").scriptText =
tempScript
  
end
-----------------------------------------

Where the cast member "custom behaviour" is an
internal behaviour placed on a sprite in my movie.


- Ben

_______________________
 duck_at_robotduck.com 
   www.robotduck.com   

_______________________________________________
dirGames-L mailing list  -  dirGames-Lnuttybar.drama.uga.edu
http://nuttybar.drama.uga.edu/mailman/listinfo/dirgames
-l
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )