Python Scripting, saving to file

This forum is currently in read-only mode.
From the Asset Store
Source File, music and art pack for Android Negotiator
  • I'm attempting to save the current score of the player to a .txt file and I can't seem to get it right... <img src="smileys/smiley19.gif" border="0" align="middle" />

    Here's what I have so far:

    "t = System.globalvar('CurScore') f = open('scores.txt', 'a')

    f.write t

    f.closed"

    At some point, I'd also like to get the program to display the highest score within the file but right now I just want this.

    Any ideas?

    Thanks.

  • Why Python script if you don't mind me asking? CC's events are much faster I've heard.

  • Well I couldn't find any of them to save just a integer, like 4845, to a file.

  • Ahh, okay, well the best bet is to use the INI object if you don't mind storing the values in plain text.

    You can find an example for that here (level editor example): http://69.24.73.172/scirra/forum/viewtopic.php?f=8&t=1721

    It's also in my Construct Classic examples pack (beginners to advanced examples and my game source codes), which you can get from the link in my signature

  • Oh ok awesome thank you! Yeah I don't mind that they are in plain text, just want them to be saved somehow.

    And thanks for making that examples .zip file. Hopefully those will come in handy. Just to make sure, may I use them (as examples, not direct copy and paste) within my games that I potentially sell?

  • Sure thing timyo, I'm happy for any of the techniques in the examples to be used in commercial products <img src="smileys/smiley1.gif" border="0" align="middle" /> Credit not required, but appreciated.

    This applies to the game graphics included as well (unless they have a separate usage permission assigned in their respective folders).

    The full game source files and resources (in the "Games" subfolder), are free for learning purposes/non-commercial works. Credit is again optional, but commercial use is currently not permitted of those exact files.

    I hadn't thought of this question and updated the blog page with this information, thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Oh ok awesome. Thanks a lot for making them! Currently working a break-out kinda game as well as a couple others. Maybe OnE dAy I'll actually sell something and make bookooz of pennies. <img src="smileys/smiley2.gif" border="0" align="middle" />

  • No problem! I'm happy to help <img src="smileys/smiley1.gif" border="0" align="middle" /> Sounds like a fun game!

    And good luck, I hope you do! <img src="smileys/smiley4.gif" border="0" align="middle" />

  • Thanks! <img src="smileys/smiley1.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)