Jump to content

StatisticsTracker.js problem?


Recommended Posts

Hello,

Been working with the codebase for a while now for an interactive music project, have constructed what I need now to do the music-y bit but I'm at a loss with the data feed I'm getting out of StatisticsTracker.js.

Am I right in thinking I can take data out of that file in real-time? I've been working under that assumption, but I've been rooting around the JS debugger and it doesn't seem to be reporting the right numbers. I've isolated it to resources gathered, specifically wood, and it seems to continually go up once the resource is collected for the first time in the game.

In the attached screenshot, you can see I've collected about 20 wood but when I used a breakpoint (set to be triggered when IncreaseResourceGatheredCounter is called), but the variable resourcesGathered on the JS debugger is reporting 32. Also, food is reporting 160 which I hadn't collected, nor is it the starting value.

I'm lost. Any help/guidance would be gratefully accepted.

(Not massively sure why I'm getting those JS errors in the top left corner, they only appear when I add the breakpoint in).

post-15629-0-48911300-1384896718_thumb.p

Link to comment
Share on other sites

Thanks, I've been meaning to look up how to print to console through the JS files. Didn't get console to work but below is the screen shot of when I used warn(msg) to print the wood gathered integer when it was being collected. Below, I can see the correct values (34, 35) hidden amongst the junk values which also seem to be increasing linearly.

This is what I got from food and wood - stone and metal just seem to print no values, regardless of whether I'm collecting the resource or not.

But from what I gather, this is how the StatusBars.js pulls the numerical information for the top of the screen? (And that is clearly working). So I don't get what I'm doing wrong, or what I need to be doing instead.

1457039_10153552402710595_327611993_a.jp

Link to comment
Share on other sites

That was what was confusing me, I wasn't using any of my own code for this. Decided to re-download the code base as I've been working between two computers on this project. Must have done something wrong along the way as I had no problems with the newly downloaded clean build.

Will now try and bring my code across and see what happens.

Edit//

Yup, it's now working in my code too. I don't think it's an elegant solution to getting data out I imagine, but as long as it works for the project I'm content with it as it is.

One problem I had introduced was using creating an OnUpdate function in StatisticsTracker.js - for some reason this created padding around the value (rather than reporting the value on the console, it would print three lines 0, the value, 0 - debugger and my code would just pick up the initial 0 for whatever reason).

Edited by rayman
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...