Script Dictionaries hurt my head

So, as you might know, I'm working on some libraries. With a lot of input needed by the creator, script dictionaries are an absolute must, but... these things are cursed in libraries. I've had three distinct problems, which I'm not even sure if I could replicate them?

Problem Number 1:

The entire dictionary, all the entries added via a nicely made tab that I double checked exist in an attribute now, just... disappears when the game starts. Completely empty in the debugger.

I have no idea why that happened and this is the one I can't replicate either, but it certainly happened and the only way of getting around it was to rewrite the entire script to not use a script dictionary.

Problem Number 2:

Not getting around one for a function, I try the script dictionary again and... it works! Too well. Whenever I add something to the script dictionary provided by a custom Object Type, it changes the value for the entire Type, giving the key and script to every single object inheriting it. Why? I don't know, no other attribute type does that, it's just scripts.
But fine, I can work around that, just check if the attribute exists before I search it, to handle if the creator doesn't need it.

Problem Number 3:
Now that I worked around #2, let me just revert the library and delete the Dictionary from the type and... now the attribute is still present on the affected objects and I can't delete them... great. Luckily I managed to work around that as well by putting the attribute back into the library, copying the type, deleting it there and then deleting it out of the library. Quest crashed twice but it worked, so.

Now. I have absolutely 0 idea why any of that happened the way it did, all I know is that these things are so broken they may as well be haunted... which sucks, given how important they are to libraries.

So I really hope that these get looked at. But for now I'm off to soothe my head.


I Haven't started working with the Script dictionaries yet, but I think I will eventually.

I seem to remember that Pixie put somewhere in documentation that Dictionaries shouldn't be added to libraries generally, because if they need to be updated during the game, they won't be. You would have to create them in the Game start/initialisation script or something like that. So like, separate from the library include it with the instructions that the creator must put them there.

As far as types, are you saying that adding a script dictionary to an individual object that has an inherited a type adds it to the type template? Or are you saying that you'd added the dictionary to the type template, and now are surprised that it shows up on every object that inherits the type?

Sometimes when I'm tired, (or my brain hurts for some reason) I do things like changing something where I shouldn't be changing it, and then wondering what happened. So don't think I'm picking on you about the types. But everything you add to the "type" at the bottom of the game in the advanced section gets added to everything that inherits. But it shouldn't be added to the type automatically if you've changed an individual object. That would surprise me.

Also, there have been times when I changed something that had auto-added attributes to a bunch of objects, changed it back, and then wondered why they didn't go away for a moment. I learned the hard way (but still sometimes forget) that if I'm going to change a library, or type, or really anything largely significant... I want a copy named with a new test-version decimal to work in. That way both versions exist.

I can go to an earlier version before those attributes were mass added by the type and add the new type that doesn't do that. Then it runs fine.

In your case, maybe start a clean game and then re-add the objects after putting the type that doesn't have those attributes? Or go into code mode and find and delete those attributes you don't want?


I've fixed everything up by now, but no, I've worked enough with this to at least mostly know what I'm doing... writing a cool 1000+ lines worth of libraries in a short span of time will do that to you!

It's a script dictionary added to a type, which in turn was added and edited at a single exit which then added both key and value to the type itself, in turn adding it to everything else... it's fixed now, by removing it from the type and creating it via a tab, while treating its possible non-existense accordingly. I have no idea why this happened and I think I don't want to!

But string dictionaries are working fine, is the other thing. Not a single problem encountered there! Object ones I have yet to use, but so far only string dictionaries are causing these massive, confusing problems... but hey, that library should be fully done and the next one will... need them as well... great...

But hey, by now I know how to abuse quest as much as it abuses me, so we'll see who breaks first!


Issue 2 is because of the way lists and dictionaries are implemented; they act as pointers in some ways.

It should give an error if you try to add or remove dictionary items on an inherited dictionary; maybe scriptdictionary isn't checked.

It's the same reason libraries which play with displayverbs have to do something like

object.displayverbs = object.displayverbs

first; disconnecting the object's list from the type's list.


Well... yes and no.

Inherited dictionaries need to be copied first by modifying them on the object in the editor (or via that script), yes. I assume that's the same for script dictionaries, though I hope I will never have to add to them midgame.

But this isn't that problem. This is worse. This is in the editor. With an already copied attribute.


@ThatGoddess

I wrote a bunch of libraries without using script dictionaries; they may not be that necessary - though I do not know what you are trying to do, so they might be!

Problem 1: Are you using the Quest editor as opposed to a text editor? I do recall adding something to a game using the editor and it not getting saved. I think that was a type (or something to do with a type), so yes, there are issues... Use a text editor, if you can deal with the XML.

@Ip Man

With regards to "Dictionaries shouldn't be added to libraries generally" that is for QuestJS, which saves games in a very different way to Quest 5. Quest 5 saves everything, so should be fine.


@The Pixie

It's a pretty comprehensive movement overhaul, which needs script dictionaries for a few things, including handling the descriptions and exits! Somehow caused me less trouble than making a Questing system though, that one really made me respect yours a whole lot more!

And yeah, I'm using the quest editor to put everything together! It's only happened that one time, and I'm guessing the empty attributed provided by the type had overruled the edited one on the object? IIRC it didn't show up as copied in the attribute view so it's probably an issue with editing type provided attributes via a tab, now that I think about it?


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums