You know, Xela, I've tried being polite with you, but you either don't get polite or you don't like polite. So, here you go, an answer matching your tone.
I am not a big fan of polite but reasonably polite with a small joke or a little stab here and there doesn't hurt anyone. If I came straightout offensive at any point,
I do apologize! I greatly appreciate any help people offer to develop PyTFall!
I copied the code from a method, so I knew it was working and did not test it. Don't tell me a simple oversight like that caused you problems
You know, I could have just copied a nice, simple class that offers the same functionality. Would have been less effort for me and it would have worked without problems, because it's well tested code. However, I know you hate code not written specifically for PyTFall, so took the extra effort of copying together a function that does exactly what you asked me for. And here you are, complaining about an error that takes a few seconds to fix...
LoL
It was a joke, it didn't cause problems and it did take a few seconds to fix.
Why would it not work in RenPy? pyexiv2 knows nothing about RenPy, so giving it a path formatted RenPy-style should break, unless you are on Linux or pyexiv2 fixes the path itself. You told me specifically to write a function that takes a dirpath and a filename. Those two need to be joined into a filepath to be of any use. Don't come to me crying if I give you what you asked for...
First, where the feck did you get a hint of crying?
Instead, lets say you write a function that loads tags from the file and we call it "rudis_tagloader()" that takes file path and filename as argument (simply a variable called file in the above function) and returns a list or a dict of tags:
file = "%s/%s"%(imagedir,file)
content[key].__dict__['gfx'][acttype] = [dict(file = rudis_tagloader(file))]
Not
'specifically', I actually said 'argument' that is a single variable that includes filename and filepath... But the function you wrote for me did exactly what is required otherwise so it's all good in the end!
It will definitely work in RenPy if you give it a correct path. Why should it not? RenPy does not prevent you from accessing the file system, does it?
I did not say something contrary to that statement. Read what I write.
Contrary to your statement, you should read what I write:
Btw, 'file = "%s/%s"%(imagedir,file)' is kinda dangerous on Windows. If whatever you feed this path into expects a UNIX path, all is well, but if that thing expects a windows path, this code will fail. If it is unsure what path convention should be used, it is better to use 'file = os.path.join(imagedir, file)', because that will always return a path valid for the current OS.
You've basically said that it would have been better to use file = os.path.join(imagedir, file).
You would've been absolutely right if it was pure Python, what you suggest however has not even the slightest chance of working in RenPy.
file = "%s/%s"%(imagedir,file)
This was done proper taking the framework into consideration.
I said that it would have been better to use file = os.path.join(imagedir, file) if programming environment was pure Python. However changing that line of code in RenPy:
file = "%s/%s"%(imagedir,file)
to
file = os.path.join(imagedir, file)
simply breaks the game. The reason for that RenPy as it has it's own way of accessing system. It's not something you could have known and as I said in my previous post,
it is my responsibility to know that, but you'll have to agree that it is not very useful or rpoductive for you to keep insisting that using file = os.path.join(imagedir, file) should work in RenPy, even after I specifically told you that it isn't, taking framework into consideration...
Ah, the joy of using frameworks...
LoL
You're right, that sucked. But I can do it in 2 minutes next time since I now have learned where to put the module and that two of RenPy modules have to be imported into every .py file for the reasons I did not fully understand.
Framework does have it's charms as well! It's not only downsides
1) I already solved that problem and it is also not hard to do
It goes something like that
# store persistent data after it has been generated
import pickle
f = open(filepath, "wb")
pickle.dump(python_object_containing_data_to_store, f)
f.close()
# load persistent data when you need it
f = open(filepath, "rb")
python_object_containing_data_to_store = pickle.load(f)
f.close()
2) So? Have a button inside the games option menu, that recreates the persistent data when clicked. Or, if you think modders are too dumb to do that, detect changes automatically and recreate the persistent data when needed.
I warned you two times already that reading all image files upon character instantiation will be very slow. It's not my fault if you don't read what I write.
Btw, depending on how many characters you intend to instantiate at once, it might not be a real problem. One to five might be okay, fifty will be a problem. Still, IMHO it is not a good idea to recreate that information on every character instantation.
You do realize Otherworld takes about one minute to load all the girl XML data, and they have fewer images than you plan to have? No, you can't load tags for 15000 images in a matter of seconds from XML, especially if they are spread over several hundred XML files (one file per girl).
I use tags inside images because they are easier to maintain than XML files (for example, they don't need to change if the path to the file changes...) and they can be loaded faster than XML files if you store the information in a pickled object (=the persistent data we were talking about before). XML files are persistent data too, are they not?
I also offered to do this in XML for PyTFall, but you never came back to me about that, so I assumed you don't want to do that.
Well, they did think of that. That's why you get this nice error message telling you exactly what's wrong. They wrote a parser for image metadata, so why would you give it a non-image file?
I've solved all these problems already, but you want to learn the hard way. Here is your filter.
import os
filename, ext = os.path.splitext(filepath_or_filename)
if ext.lower() in ["jpg", "png"]:
load_tags(filepath)
All of your fixes and suggestions make sense, I'll have to try to adapt them to RenPy but I want to write some game code for now (Not exactly want to but I can rarely work on this undisturbed during the week and figuring these things out takes concentration and time) so I'll try to do it this weekend.
I remember that you offered .XML and I never came back to you about that because I had no knowledge of time that is required to load tags directly from images.
It is another option but I'll try to make it work as you suggest it right now first.You do realize Otherworld takes about one minute to load all the girl XML data, and they have fewer images than you plan to have? No, you can't load tags for 15000 images in a matter of seconds from XML, especially if they are spread over several hundred XML files (one file per girl).
And why would either of us give a damn about what happens in OtherWorld? I wonder how fast PytherWorld can do it? We are programming our games in Python for a reason, do we not? Take a look at traits.xml file Dark and SW created for PyTFall, it's a very reasonably sized .xml file:
x = 400
while x > 0:
traits = load_content('traits')
x -= 1
This code loads it 400 times. Every trait (there are like 50 of them already, maybe more) becomes an instance of Traits class. load_content() function formats the data to the required structure using a xml parser and parse() function (called from inside of load_content()) iterates over every line of the file, making sure it's all parsed into the class properly, reformatting strings, taking care of booleans and so on.
It's a lot of work and it only takes 9 second for the game to load (entire game, not just to load traits file 400 times) so .xml can at least be used as a backup option.
You said it yourself, hardware gets faster than we can program
PS:
And let's not fight over BS, I'll try to be more on target in future posts!=========================================================
@Dark and SW:You guys are not allowed to leave comments inside xml trunks:
<trait
id="Alien" #For demons, angels, etc.
desc="This girl has come from a distant dimension with absolutely other laws of physics, magic and society."
temp='0'>
Do it like this:
<trait
id="Alien"
desc="This girl has come from a distant dimension with absolutely other laws of physics, magic and society."
temp='0'> #For demons, angels, etc.