The short answer is; accessor methods. You should have a special
routine for each piece of data that the object wants to give out:
on getName me
return myname
end
on getage me
return myage
end
on getcolor me
return mycolor
end
A longer answer is what else will these 'Objects" do. If they are
just there for storage, then you might want to reconsider using
objects and use a list of lists or a list of propertyLists instead:
myThings = [["Joe", 26, "Blue"],\
["Irv", 47, "Purple"],\
["Howdy", 41, "Green"],\
...
or
myThings = [[#Name:"Joe", #age:26, #color:"Blue"],\
[#Name:"Irv", #age47, #color:"Purple"],\
[#"Howdy", #age:41, #color:"Green"],\
...
Then index into the list of lists to get your information.
But the really long answer is that if these things really are
objects, that is, they have handlers associated with them, then you
probably want to have a list (maybe a global list) of object
references. You create 10 objects, and put the returned object
references into a list:
global gListOfObjects
gListOfObjects = []
repeat with i = 1 to 10
NewObjectRef = new(script "SomeScriptName", someparams)
append(gListOfObjects, NewObjectRef)
end
Now you use the object reference in the list to refer to the object
you want. For example, if you want the color of the sixth object,
then you do this:
theObjectRef = gListOfObjects[6]
theColor = theObjectRef.GetColor() -- which calls the accessor
routine of the 6th object
Good luck,
Irv
At 6:14 AM +0100 5/10/02, Kevin McCarthy wrote:
>Hi all,
>
>I'm having trouble with a little script, what I need to do is, say I
>have ten items in my game and each item has three properties, properties
>are name, age and colour.
>I am creating each object using the following:
>
>set objOne = new(script "buildObject","PeterPan",10,"WHITE")
>
>I have a script castmember "buildObject", and it looks like this
>
>
>on new me, n, a,c
> set myname = n
> set myage = a
>set mycolor = c
> return me
>
>end
>
--
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!]