> 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
>
> what I need to know is how to get the value of objone properties,
> currently I have tried objone.myname and it's not working

"it's not working" doesn't give much of an insight into exactly what the
error is, but there are several possibilities. Quoting the error message you
receive when attempting to access the object's properties would help.

1). You must store the necessary properties in the object by declaring them
as properties, or they are simply local variables within the object's/parent
script's "new" handler:
---------------------
property myName, myAge, myColor

on new me, n, a, c
  myName = n
  myAge = a
  myColor = c
  return me
end
---------------------

2). Assuming you are doing this, you also have to store a reference to the
returned object properly, eg:
---------------------
global objOne, objTwo, etc.

on mHandler1
  objOne = script("buildObject").new("PeterPan", 10, "WHITE")
  -- etc.
end
---------------------

3). Then your object's properties should be directly accessible like you are
trying - as long as the script/handler where you are trying this also has
access to the variable pointing at the object. ie:
---------------------
global objOne, objTwo, etc.

on mHandler2
  aProp = objOne.myName
  -- etc.
end
---------------------

I'll let someone else take up the merits or otherwise of "direct access" and
private/public properties.

HTH,
-Sean.

[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