Any way to get save infos into variable?

  • z4dg9ssw135
    24th May Member 1 Permalink

    Hello.

    Is there any way to get infos about save like the name, description, creator nickname, votes amount etc into an array or variable?

    I want to challange myself making a save related script that needs to get these infos.

  • GigaCars
    24th May Member 0 Permalink

    TPT mods like Cracker1000 or Jacob1's mod can show ratings amount on saves, as for name, descriptions and the rest i doubt it, but i'm not a coder so take the opinion with a grain of salt

     

    TLDR: you can try to replicate the vote showing system from the 2 mods i mentioned and try to do the thing with them, but otherwise idk

  • Maticzpl
    24th May Member 0 Permalink

    You can look into the http part of the lua api
    I recommend using the .json endpoints like https://powdertoy.co.uk/Browse/View.json?ID=2198
    You can use smth like this to parse the json and get all the info like that

    Edited 2 times by Maticzpl. Last: 24th May
  • jacob1
    24th May Developer 1 Permalink
    And if you need to know what save is open, you can use
    sim.getSaveID()
    . After that, do what @Maticzpl said.

    Do avoid mass scraping the server. But if you have a script that makes a request whenever a save is opened, that's fine.
  • z4dg9ssw135
    26th May Member 0 Permalink

    Thanks for feedback guys.

    Appreciate yalls help

  • z4dg9ssw135
    29th May Member 0 Permalink

    ...i have got an unexpected problem.

    every time i try to get anything with http.get gives me userdata and i cant use it in any way.

    any idea how do i fix that ?

    edit: i probably didnt understand the article on tpt wiki.

    Edited once by z4dg9ssw135. Last: 29th May
  • jacob1
    29th May Developer 0 Permalink
    It returns an HTTPRequest object. You have to call methods on this object to check when it's done and get the data.

    Very rough code, be sure to not block to check the status (check it in a tick function or something) and check if there were errors before you use data.

    local req = http.get("https://something")
    ...
    if req:status() ~= "running" do
        local data, status = req:finish()
    end