Accessing "Box Object" Private variables from Python?

For questions about using Classic.

Post » Sun Mar 27, 2011 1:10 pm

Is it possible to access a "Box" object's private variables from Python?

(Just to be clear, by "Box" object, I mean the object found in the "Insert new object" dialogue you get from right clicking in the layout editor.)

I've tried using the following python expression,
[code:38ktw271]Box.Value( 'privateValueName' )[/code:38ktw271]

but it does not seem to work. I get nothing back.

Now, for other object types, such as "Sprites" or "Panels", it does work.

Am I doing something wrong, or can python simply not access "Box" object variables?
B
21
S
13
G
8
Posts: 306
Reputation: 5,458

Post » Sun Mar 27, 2011 6:06 pm

[quote:1iw8l0zl]Is it possible to access a "Box" object's private variables from Python? [/quote:1iw8l0zl]
No, not directly. A recompile of Box.csx would probably fix it so it uses the updated code that Sprite uses.

A current solution is to use a hybrid event/python approach by setting a python variable to one of the box private variables with the "Run Script" System action.

+ System: Start of layout
-> System: Run Script ("foo=" & Box.Value('foo'))
B
79
S
24
G
54
Posts: 4,744
Reputation: 40,751


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests