We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Making a game and i need to write to a/some text file(s). i need to be able to save no more than a single string to a file. How could i most simply write to and read from a text file and store the information in variables?
Answers
You can try the simple saveStrings() + loadStrings().
Or something more advanced like saveTable() + loadTable().
saveStrings(): http://processing.org/reference/saveStrings_.html
loadStrings(): http://processing.org/reference/loadStrings_.html
why would this give me a java.lang.NullPointerException?
You are attempting to set what I assume to be variables as integers, but they have not been declared in your code. They are therefore null.
map, health, stamina, mana, level, strength, defense, melee, magic, ornothology are already defined elsewhere as integers
Are they defined globally? Otherwise your savefile() function won't be able to see them.
they are indeed defined globally like this;
If I run your code, I don't get a NPE, but an IllegalArgumentException because saveTable() doesn't recognize the extension, so doesn't know which format to use for saving.
Should be:
for example.
ok this just isnt going to work, and i dont think it supports int's anyways, is there any way i can just save a few ints to a text document, what the hell its easier to write to a file in python.
nevermind on that the null was from elsewhere, my bad