1. Stuck, Having problems with creating your mod? Let us help you: Mod Support

can't access stats stream in lua script?

Discussion in 'Programming' started by LCom, Dec 2, 2017.

  1. LCom

    LCom
    Expand Collapse

    Joined:
    Aug 12, 2016
    Messages:
    3
    Sorry if this question has been answered before, but I haven't been able to find an answer in at least an hour of looking.

    I'm working on a modified outguage.lua, and right now I'm trying to get the display lines to basically replicate what the nodeBeamDebug UI app does - present a simple damage percentage based on deformed beams / total beams.

    From what I can find I should be able to access this though data.stats.beam_count. But even trying to read it from the vehicle lua console using dump() this doesn't seem to exist. Looking at the guistreams.lua it looks like it should exists within just stats.beam_count, but dump(stats) doesn't seem to return anything at all? But looking at the app.js of nodeBeamDebug also looks like it would be in a similar place, since the UI app works.

    Has there been some change to structure that has depreciate stats as a guistream? Has lua ever had a way to access data.stats values? Am I missing something simple because I'm really not used to reading lua or js code?

    Any help is appreciated.
     
  2. metalmuncher

    metalmuncher
    Expand Collapse

    Joined:
    Aug 6, 2012
    Messages:
    255
    Seems a bit weird to try and extract the data from the guistream when you can just ask the engine to give you the data whenever you need using obj:calcBeamStats(). Try print(obj:calcBeamStats().beams_broken) in vlua console. ;) Probably would be best to put the result into a variable and get the bits you need rather than call calcBeamStats multiple times, like in guistreams.
     
  3. LCom

    LCom
    Expand Collapse

    Joined:
    Aug 12, 2016
    Messages:
    3
    The only reason I was doing it that way was because I was learning by looking at what the rest of the script did. I honestly didn't know this was available to me.

    But yes, that gets me the data I want and now it's working perfectly. Thank you very much!

    Is there a good reference page where I can read up on what else I can be doing by that method? I don't think I've even seen "obj:" anything yet in what I've looked through, but I'd like to actually have an understanding of what I've just implemented, and I don't wanna waste anyone's time with 1,000 questions.
     
  4. tdev

    tdev
    Expand Collapse
    Developer
    Staff Member

    Joined:
    Aug 3, 2012
    Messages:
    2,728
    We are currently working on documentation, it's not ready yet :/
     
    • Informative Informative x 1
  5. LCom

    LCom
    Expand Collapse

    Joined:
    Aug 12, 2016
    Messages:
    3
    Understandable. Dev is hard.

    Thanks again for the help!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice