PDA

View Full Version : Custom Attributes Question


Guiniture
06-22-2007, 05:53 PM
Hi,

Im trying to write a script based on combining ideas of cellular automata and lamarkism.

What I am trying to do is create some boxes which are capable of storing 'bits of code' within their custom attributes, I would then like to be able to have a way of compiling the bits of code from various boxes to form an executable command.

That isnt very clear but i will try and give you an example of what i would like to do:

$box01.CA = ($.pos = [0,0,0])
$box02.CA = ($.scale = [50,50,50])

The idea would then be to get all the bits of code and make box01 and box02 move to position [0,0,0] and scale down to 50% of their original size.

Is it possible to do something like this with custom attributes? Also is it possible to store functions, strings or arrays in custom attributes?

Any help anyone could give me would be great!!

Cheers

PEN
06-22-2007, 06:40 PM
Yes..yes and umm, yes. Do you need to know more?

Guiniture
06-28-2007, 06:09 PM
How do you store functions in custom attributes?

I have tried doing something like this but i cant find what code i need to write in some places?!:


boxdata = attributes boxdata
(
parameters main rollout:params
(
state type:# < something here??!>
)
rollout params "Box State"
(
< and something here?>
)
custattributes.add allboxes boxdata #unique
)


I know this is pretty vague but basically i just want to store functions within some boxes in a scene which i can then access.

Any ideas??

PEN
06-28-2007, 07:15 PM
def=attributes test
(
fn testFn=(print #yup)
)
b=box()
custAttributes.add b def

b.test.testFn()

Guiniture
06-28-2007, 07:52 PM
Thanks, I think that solves my problem! I assume if i have a function with variables i will be able to something like:

b.test.testFn variable01 variable02

Thanks again.

PEN
06-28-2007, 07:57 PM
Thanks, I think that solves my problem! I assume if i have a function with variables i will be able to something like:

b.test.testFn variable01 variable02

Thanks again.

Yep, works like any other function.

CGTalk Moderation
06-28-2007, 07:57 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.