print or save in pdf?

  • #1, by jf-mWednesday, 25. August 2021, 15:56 2 years ago
    hi everybody!

    I made a search but didn't find an answer.
    I would like to print or save in pdf a scene.
    Is there a way to create a button with this function?

    Thanks!

    Newbie

    39 Posts


  • #2, by afrlmeThursday, 26. August 2021, 15:44 2 years ago
    Do you mean create a screenshot?

    Imperator

    7278 Posts

  • #3, by jf-mThursday, 26. August 2021, 18:06 2 years ago
    yes, create a screenshot and save it somewhere, or print it directly

    Newbie

    39 Posts

  • #4, by afrlmeThursday, 26. August 2021, 20:41 2 years ago
    here you go.


    Add this code inside of an execute a script action in one of the key actions (released), maybe the F12 key or something.
    -- save to "screenshots" folder as "screenshot_(date)_(time).png
    
    local time = os.date("%Y-%m-%d_%Hh-%Mm-%Ss")
    
    createScreenshot("screenshots/screenshot_" .. time .. ".png")

    Quick note: screenshots folder needs to exist in the root folder of your game project/exported game project.

    Imperator

    7278 Posts

  • #5, by jf-mFriday, 27. August 2021, 19:15 2 years ago
    one more time: thank you! smilesmile

    is there a way to change the final folder for a game online?
    i would like to save the screenshot on the gamer's computer for a online game.

    I promise i have bought a lua book, but time is missing. wink


    Newbie

    39 Posts

  • #6, by jf-mWednesday, 22. September 2021, 19:41 2 years ago
    I'm sorry to go back to this question, but i really need to know if there is a way for saving the png localy from an online game.
    I think your solution works for:
    - local game with a "screenshot" folder in the root folder
    - online game with the same condition, but in the online root folder.

    Is it possible to mix them? 
    - online game with a local screenshot folder?

    Thanks smile

    Newbie

    39 Posts

  • #7, by afrlmeThursday, 23. September 2021, 11:46 2 years ago
    Er, maybe...

    You should be able to query which platform the game is being played on

    if getProperty("platform") == "html5" then
    
     -- web browser add relevant screenshot code here
    
    else
    
     -- desktop add relevant screenshot code here
    
    end

    Imperator

    7278 Posts

  • #8, by jf-mThursday, 23. September 2021, 12:48 2 years ago
    thanks for your answer smile
    I'm sorry i don't understand. Does your script mean that depending on the platform, the savepath will be different? But then, if html5 -> web folder , or not html5 -> local folder?

    and the final will be like? :

    if getProperty("platform") == "html5" then
    -- save to "screenshots" folder as "screenshot_(date)_(time).png
    
    local time = os.date("%Y-%m-%d_%Hh-%Mm-%Ss")
    
    createScreenshot("screenshots/screenshot_" .. time .. ".png")
    else
    -- save to "screenshots" folder as "screenshot_(date)_(time).png
    
    local time = os.date("%Y-%m-%d_%Hh-%Mm-%Ss")
    
    createScreenshot("screenshots/screenshot_" .. time .. ".png")
    end

    Newbie

    39 Posts

  • #9, by afrlmeFriday, 24. September 2021, 12:01 2 years ago
    No, I just meant that you can query what platform/device the game is currently being played on. I haven't actually tried uploading an html5 game, so I don't know exactly where screenshots would go. Where exactly are you wanting the screenshots to be saved to?

    Also the folder you save them to has to exist already or the screenshots will not be created  - you can create the folder with script, but the createScreenshot() function requires that the folder exists beforehand.

    Imperator

    7278 Posts

  • #10, by jf-mSaturday, 25. September 2021, 16:29 2 years ago
    in fact, i would like to save my screenshot on the local computer, not online.
    The game is online.
    Do you think there is a way?

    Have a nice we!

    Newbie

    39 Posts

  • #11, by afrlmeSunday, 26. September 2021, 16:44 2 years ago
    I know how to create a folder on windows in the documents folder, but the problem is that I don't think that would be valid for mac & linux. I have no idea if the folders would be named/accessed in the same way because the method I've shown below is using the environment variables which are - as far as I'm aware - unique to each different OS.

    Anyway, to create a folder on the desktop (on windows at least) you can use this code...
    local dir = os.getenv("userprofile") .. "\\Documents\\"
    lfs.mkdir(dir .. "\\Example Game Name")
    lfs.mkdir(dir .. "\\Example Game Name\\Screenshots")
    
    local time = os.date("%Y-%m-%d_%Hh-%Mm-%Ss")
    createScreenshot(dir .. "\\Example Game Name\\screenshots\\" .. time .. ".png")

    Imperator

    7278 Posts