Modding Help How do I save a variable?

Discussion in 'Starbound Modding' started by Tracey, Jun 12, 2019.

  1. Tracey

    Tracey Aquatic Astronaut

    So everything is working alright but I have a small problem with saving a variable.



    So what exactly is the problem?

    If you upgrade and press the reset button before closing the matter manipulator upgrading menu everything works fine but when you upgrade and close it and reopen it to reset the upgrades the payback variable gets set back to 0.

    Is there anyway I can save the variable and call it when I reopen the menu?

    So the "payback = 0" is probably the reason why it gets set back to 0 but I don't know any other place to put it besides in the same file if I delete it and write it in the mmupgradegui.config (via patch) it can't reach it and the whole menu crashes.

    I'm open and thankful for every idea because I really need that system working. :c
     
  2. Tracey

    Tracey Aquatic Astronaut

    I still need help with this problem if you have an idea just say it and I'll try!

    Thanks!
     
  3. The | Suit

    The | Suit Agent S. Forum Moderator

    So this is more of a logistics issue

    So it matters where the information is being called and what is being edited.

    If Point A is only a GUI interface and Point B is a physical object
    You are editing the code in Point A - there really is no way to "store" it as GUIs tend to read data and apply changes.
    ( The main reason for this is - you want the code to work in mutliplayer - so storing information directly into the GUI means it affects all players. Which is why it is used to only read data and manipulate from another source. )

    So you need to either store data on something the GUI reads
    or use work around by creating a new stat on the player which stores the data which can be globally read.
    Then modify the value on the player character.

    For the 2nd example you can see my old mod ( no longer works - but concept still does )
    https://github.com/xxswatelitexx/Starbound_Temperature/tree/master/temperature

    I added a new state in the player.config to track my temperature changes
     
  4. Tracey

    Tracey Aquatic Astronaut

    Thank you very much! Everything works now without any problem.

    Appreciate it!^°^
     
    The | Suit likes this.

Share This Page