How do I get values using console

Get help using Construct 2

Post » Tue Sep 06, 2016 8:41 am

My question is:
How I can get values using the Developer Tools (console)
For example I can run Construct functions by entering the console:
"c2_callFunction("Function Name", [array of params])"

But is there is some kind of DOM system that let me enter and see the values of my spriter, texts...
Their instance values and regular values...

Examples of what I want:
spriteName.instanceValue
spriteName.height
someText.text
system.time
and etc...

Or is there other solutions to get values of things rather than console.

We just want to make some automation testing without adding scripts to the games.

Thank you.
B
61
S
31
G
6
Posts: 125
Reputation: 7,895

Post » Tue Sep 06, 2016 8:51 am

Be sure to use the debugger and otherwise, use the Browser plugin's action "Log" to log whatever you want in the console.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
291
S
114
G
95
Posts: 7,293
Reputation: 70,144

Post » Tue Sep 06, 2016 1:54 pm

Kyatric wrote:Be sure to use the debugger and otherwise, use the Browser plugin's action "Log" to log whatever you want in the console.


No, I need the other way around.
Not the game telling me what the values are, but to be able to see the values inside the game from the browser.

For example if I want to see the content of this forum comment, I would press F12 (on Crome) and look inside the elements of the DOM to find out that my comment containing:
"[quote="Kyatric.... ....those values?"
Or using console to get the element by its ID and geting the data.

The same I want to do with my game, I know the names of the variables and etc, everything is happening on the client-side inside JavaScript, that mean that all I need is the API to get values from the construct2-canvas...
Some body knows how I can get those values?
B
61
S
31
G
6
Posts: 125
Reputation: 7,895

Post » Tue Sep 06, 2016 3:34 pm

From the web browser debug console you can type cr_getC2Runtime() to get a snapshot of the entire c2 runtime that you can browse. It doesn't have the object names so it's a bit trickier, but if you know the uid of the object you can get it with cr_getC2Runtime().objectsByUid[2] where 2 is the uid. It's probably more of a novelty that you can access everything that way if you locate where to look, in practice it's better to use C2's debugger.
B
92
S
32
G
109
Posts: 5,290
Reputation: 70,991

Post » Wed Sep 07, 2016 11:22 am

R0J0hound wrote:From the web browser debug console you can type cr_getC2Runtime() to get a snapshot of the entire c2 runtime that you can browse. It doesn't have the object names so it's a bit trickier, but if you know the uid of the object you can get it with cr_getC2Runtime().objectsByUid[2] where 2 is the uid. It's probably more of a novelty that you can access everything that way if you locate where to look, in practice it's better to use C2's debugger.


Thank you! That is exactly what I needed!!!
B
61
S
31
G
6
Posts: 125
Reputation: 7,895


Return to How do I....?

Who is online

Users browsing this forum: 25games, Ashley, Bootfit, mcscooter, TRMG and 25 guests