Python Scripting, saving to file

New releases and general discussions.

Post » Wed Nov 06, 2013 10:05 pm

I'm attempting to save the current score of the player to a .txt file and I can't seem to get it right...

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.
B
2
Posts: 8
Reputation: 166

Post » Fri Nov 08, 2013 4:26 am

Why Python script if you don't mind me asking? CC's events are much faster I've heard.
Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
125
S
43
G
17
Posts: 2,231
Reputation: 20,024

Post » Sat Nov 09, 2013 3:08 am

Well I couldn't find any of them to save just a integer, like 4845, to a file.
B
2
Posts: 8
Reputation: 166

Post » Sat Nov 09, 2013 7:17 am

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 signatureJayjay2013-11-09 07:17:34
Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
125
S
43
G
17
Posts: 2,231
Reputation: 20,024

Post » Mon Nov 11, 2013 3:11 am

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?
B
2
Posts: 8
Reputation: 166

Post » Mon Nov 11, 2013 3:34 am

Sure thing @timyo, I'm happy for any of the techniques in the examples to be used in commercial products 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!
Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
125
S
43
G
17
Posts: 2,231
Reputation: 20,024

Post » Mon Nov 11, 2013 3:51 am

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.
B
2
Posts: 8
Reputation: 166

Post » Mon Nov 11, 2013 4:19 am

No problem! I'm happy to help Sounds like a fun game!

And good luck, I hope you do!
Construct Classic - Examples Kit Dropbox is a pile of trash and if you need my old files PM me! :)
B
125
S
43
G
17
Posts: 2,231
Reputation: 20,024

Post » Mon Nov 11, 2013 4:38 am

Thanks!
B
2
Posts: 8
Reputation: 166


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 6 guests