Re: my new online engine, coded in python

Hi, I would like to ask you for advice on this code. I was able to use saving and loading a file using Lucia, saving the state of an object and then loading it. Is the method I use correct or are there other methods integrated in Lucia? Here I use lucia.data and pickle.
X Amerikranian. If the example seems correct, you can include it among Lucia's examples. Feel free to edit it.
Thank you.

The code is like this. Say I have a Player class and an object called player1. I define it shortly for clarity

from lucia import data
import pickle

class Player:
    def __init__ (self, x, y):
        self.x= x
        self.y= y

player1 = Player(3, 5)

#Saving it to a variable
c= pickle.dumps(player1)
#Compress it
c=data.compress(c)
#Set a key
key = "KeyKeyKeyKeyKey123123123"
#Encrypt
c= data.encrypt(c, key)
#Create a file
file = open("save.dat","wb")
pickle.dump(c, file)
file.close()



And now load method
file = open("save.dat","rb")
c = pickle.load(file)
#Decrypt
c= data.decrypt(c, key)
#Decompress
c= data.decompress(c)
#Load to the object
player1= pickle.loads(c)
file.close()

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : mechaSkyGuardian via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Jaidon Of the Caribbean via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : kianoosh via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : MichaelJ via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector

Reply via email to