dialogic-godot / dialogic

💬 Create Dialogs, Visual Novels, RPGs, and manage Characters with Godot to create your Game!
https://dialogic.pro
MIT License
3.26k stars 200 forks source link

Setting variables in dictionaries or arrays not working. #2195

Closed Pynthare closed 1 week ago

Pynthare commented 1 week ago

The problem

Describe the bug I am using a singleton dictionary to store the information for each quest that is currently in my game. I can fetch information from this dictionary without problem e.g: "if {Quest.quests["shipHullRepairPart1"].status} == 0:" and it works flawlessly.

However, when tring to SET a variable e.g: "set {Quest.quests["shipHullRepairPart1"].status} = 1", dialogic just trows a tantrum in the output log: Dialogic: Expression failed to parse: Expected expression. [Dialogic] Failed parsing variable/expression ''.

This also appears when tring to use other parts, like using a variable to minus itself using another variable: image If I look in the timeline files this is not even saved correcly: "set {{Itemresource.inventoryResources[0].amountOwned}} -= {}"

To Reproduce Steps to reproduce the behavior: Try setting any variable in a dictionary or .

Expected behavior I would expect dialogic to set the variables and save the entered variables.

System (please complete the following information):

Am I missing something supidly obvious?

CakeVR commented 1 week ago

Hello, please try again with the latest commit on the main branch.

Pynthare commented 1 week ago

Hi, thank you for your response. I tried updating to the latest commit, and sadly no change. I did however try to force the entry of the variable by adding it into the timeline-file manualy with code. This gave the error: "[Dialogic] Tried setting non-existant variable 'Itemresource.inventoryResources[0].amountOwned'." which leads me to belive dialogic does not recognize that this is acctualy a autoloaded gd-file for some reason.

I also wanted to add that yes, this code works from any other gd-script in the game and I have spellchecked it anyway :)

Jowan-Spooner commented 1 week ago

Hey @Pynthare The access to arrays and dictionaries is for now limited to this syntax array["my_entry"] while array.my_entry is not supported. This is simply because noone had the time to implment that, as it makes the code much more complex (because it's harder to differentiate from member access of an object).

So you should be able to do what you want with: {Itemresource.inventoryResource[0]["amountOwned"]}

I have created a new separate feature request (#2197) for that syntax so we can track the missing functionality there.