How to read in txt file in panda?

Hello, I need some help in reading txt files in panda.
Its about creating a level editor.

Thanks in advance

very simple (and if done over network somewhat unsecure) way to save stuff like variabl,lists and so on is to use python’s pickle module and the OS module
for example put what you want to save into a list or something, in this case called filedata.

you need to import the modules “pickle” and “os” if i’m not totaly wrong

        fileOut = open("./yourfile.txt","w")
        pickle.dump(filedata,fileOut,-1)
        fileOut.close()

reading it again:

        fileIn = open("./yourfile.txt","r")
        filedata = pickle.load(fileIn)
        fileIn.close()

that’s basically it :slight_smile: … should work, cant test it right now. but should

hmm i see. Thanks!

Is there any way to do it in a C++ method?
I am not really into using python to do it… Sorry for the misunderstanding.

Panda doesn’t provide anything on top of the standard C++ library to read and write text files. So, you should just use the standard C++ library.

Unless, of course, you’re talking about reading Panda-specific kinds of text files, like egg files and whatnot. But just for reading your own game data, you can either use the iostream or stdio libraries, or find a third-party library you like better, or roll your own.

David

How about if i want to read in egg files?
Is there any way to open them?

If you plan to load it as a model, please check this manual page.
If you want to just load the text as a string, I think you will need to use the standard C++ stuff, (tutorial)