Running Lua script when opening save

  • ArolaunTech
    4th Mar 2023 Member 0 Permalink

    Is there any way to make it such that whenever a save is opened, a Lua function runs?

  • catLoveChips_2
    15th May 2023 Member 0 Permalink

    No for security reasons. Because if saves could have scripts then you could add malware to a save.

  • RebMiami
    15th May 2023 Member 0 Permalink

    @catLoveChips_2 (View Post)

     I assume he doesn't mean code in a save, just a function in a script that runs when the game loads a save.

  • jacob1
    16th May 2023 Developer 0 Permalink
    You can scan for sim.getSaveID() changes to try to detect when a save is loaded. I don't see an equivalent function for local saves.

    Then, you could also detect mouseclicks on the reload button, because reloading won't change the save id but should probably trigger this event.