rayman Posted November 19, 2013 Report Share Posted November 19, 2013 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). Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted November 19, 2013 Report Share Posted November 19, 2013 You could be seeing bugs in the debugger (heh), to be sure, try adding some manual debug output using one of our JS logging functions. All I know about the JS debugger is that it runs, I'm not sure how often it's tested or if the output is ever validated. Quote Link to comment Share on other sites More sharing options...
rayman Posted November 20, 2013 Author Report Share Posted November 20, 2013 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. Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted November 20, 2013 Report Share Posted November 20, 2013 Do you have your code somewhere (you can upload WIP patches to trac if you want)? It's probably something you're overlooking. Quote Link to comment Share on other sites More sharing options...
rayman Posted November 20, 2013 Author Report Share Posted November 20, 2013 (edited) 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 November 21, 2013 by rayman Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted November 21, 2013 Report Share Posted November 21, 2013 OnUpdate is an engine function that's run every simulation turn (normally 4 times per second), it has nothing to do with updating the object. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.