I've read your message a few times and I think I have an idea of what 
you are getting at.  Here's my guess.  You've turned a log into a 
list.  Then you go through this list, and each time you find a name, 
if you haven't seen this name before, then you create a new object 
for this player.

You need to create a list of player objects.  Start it out empty, and 
every time you find a new player, you create a new player object and 
add it to the end of the list.  And from reading what you wrote, it 
sounds like all this code lives inside a behavior.

If this is the case, then you want to do something like this 
(completely untested):

property ploPlayers  -- property which is a list of player objects

on beginSprite me
    -- Do your parsing thing to turn the text into a list, lets call 
this list, LogList

    ploPlayers = []  -- starts out empty
    nLogEntries = count(LogList)

    repeat with i = 1 to nLogEntries
        thisLogEntry = LogList[i]  -- pull out the current entry

        nameInThisLogEntry = <however you pull out the name>

        nPlayerObjs = count(ploPlayers)  -- how many so far
        fFoundName = FALSE  -- assume we haven't found it yet
        repeat with j = 1 to nPlayerObjs
            oPlayer = ploPlayers[j]
            thisPlayerName = oPlayer.mGetName()

            if thisPlayerName = nameInThisEntry then

                -- you've found the matching player object, do whatever you
                -- you want to, send it a message like this:
                -- oPlayer.mSomeMethodName(optional parameters)
                -- e.g., oPlayer.mChangeName(newName)

                fFoundName = TRUE
                next repeat
             end if
          end repeat

          if not(fFoundIt) then  -- did not find it, let's create a 
new player object
              oPlayer = script("playerscript").new(nameInThisLogEntry)
               -- and add it to the list of player objects
               append(ploPlayerObjs, oPlayer)
           end if
      end repeat

     -- anything else you want to do
end


Then your player script needs to look something like this:

property pName

on new me, theName
    pName = theName
end

on mGetName me
   return pName
end

on mChangeName me, theNewName
   pName = theNewName
end

-- any other handlers you want to have


In answer to your other questions, only the "new" handler needs a 
"return me" at the end.  And, the call:

     s.changeName(oldName, newName)

will only run on the current player script.  That's why I suggested 
that you create a list of player objects.  Each time you parse a 
line, you run down the whole list of player objects and query each 
one.

Hope this helps,

Irv

At 6:43 PM -0700 8/27/02, Jeremy wrote:
>I have a game log parsing project creating objects to store statictics
>that it gathers from readin a log file(big text file) When it encounters
>a new item in the log, it creates a script object and I have many
>properties in there that I will be using to store separate stats per
>object. I also have some functions within that behavior script that I
>would like to call outside the behavior script. What is the best way to
>call a function that exists inside the behavior script, from outside
>that script? Hope I'm clear enough on the question. The functions I
>would like to call are functions that will modify some properties of the
>object. Heres what I have.
>
>Person chooses the log file, hits a button, this reads the whole log
>file into a list, works great.
>
>Then I go into a repeat loop that goes through the list "line by line"
>and when it finds a line with a new name on it, it creates an object
>like so...
>
>s=script("playerscript").new(playername)
>
>I pass playername to the object so it will store its own name(this
>project is a game log parser).
>
>My behavior script also contains functions that will update the name if
>called and the oldname and newname are passed and are matched with that
>instance.
>
>Anyways, throughout the big repeat loop, each line defines another
>action that has taken place during the round, such as player1 killed
>player2 with whateverweapon.
>
>What would be the best way to call the behavior script from within the
>main repeat loop, so that I can call functions within the behavior
>scripts of the objects, and pass arguments.
>
>Would I just use:
>       script("playerscript").changename(oldname,newname)
>
>?
>
>Hoping I explained enough to get some help. Thanks
>
>Jeremy
>
>
>[To remove yourself from this list, or to change to digest mode, go 
>to http://www.penworks.com/lingo-l.cgi  To post messages to the 
>list, email [EMAIL PROTECTED]  (Problems, email 
>[EMAIL PROTECTED]). Lingo-L is for learning and helping with 
>programming Lingo.  Thanks!]


-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to