dialogic-godot / dialogic

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

if condition does not work #395

Closed skyace65 closed 2 years ago

skyace65 commented 2 years ago

The problem

Describe the bug I have set up two if conditions in my timeline. If a value is 0 it's supposed to change the timeline. The default value is 0 and the if condition is always skipped over.

To Reproduce

  1. Create an definition with a value of 0
  2. Create a timeline with an if condition for that value equaling 0
  3. Run the dialogue

Expected behavior Since the value is 0 the timeline should change

Screenshots Timeline1 Definition

System:

theludovyc commented 2 years ago

Hello !

I find where it come from. When you create new condition "equal to" is default. But its not save in the json. Example :

{
  "condition": "",
  "definition": "1625991849-648",
  "event_id": "dialogic_012",
  "value": "0"
}

But when you set equal, its works !

{
  "condition": "==",
  "definition": "1625991849-648",
  "event_id": "dialogic_012",
  "value": "0"
}
theludovyc commented 2 years ago

I think it's here

TimelineEditor.gd:467

# the Condition button adds multiple blocks 
func _on_ButtonCondition_pressed() -> void:
  if len(selected_items) != 0:
    # Events are added bellow the selected node
    # So we must reverse the adding order
    create_event("EndBranch", {'no-data': true}, true)
    create_event("Condition", {'no-data': true}, true)
  else:
    create_event("Condition", {'no-data': true}, true)
    create_event("EndBranch", {'no-data': true}, true)
coppolaemilio commented 2 years ago

I'll take a look at the issue tonight when I'm free and see if the defaults are the issue 👍🏻 Feel free to create a PR with the changes if you find a solution!

theludovyc commented 2 years ago

I found this

dialog_node.gd:1053

if condition == '':
  condition = '==' # The default condition is Equal to
match condition:
  "==":
    condition_met = converted_def_value == converted_event_value
theludovyc commented 2 years ago

On Godot 3.2.3 no issues with basics steps

image

Project : TestDialogic124.zip

theludovyc commented 2 years ago

On Godot(Mono) 3.3.2 no issues with basics steps

image

Project : TestDialogic124(Mono).zip

theludovyc commented 2 years ago

On Godot 3.2.3 no issues on change timeline (dialog close after hello and hola never appear)

image

Project : TestDialogic124_1.zip

theludovyc commented 2 years ago

@skyace65 can you send your project with issues please ? =)

skyace65 commented 2 years ago

@theludovyc I checked the json file for that timeline and you're right, it's not setting equal as the condition by default. Here's a test project I just made that has the issue. DialogicTest.zip

skyace65 commented 2 years ago

There's more to this issue than I thought. Changing the condition to something else, then back to equal does change the json file. However it still doesn't work. And when I try to print the variable to the console there's nothing. Are there any Godot editor files I should try deleting to reset settings?

coppolaemilio commented 2 years ago

the parser knows that if there is no option selected the default is equal to so it doesn't really have to pollute the json with more info than it's needed. But I don't think this is the origin of the issue. It might be something related to testing 0 as false or something like that. I will try to investigate further

skyace65 commented 2 years ago

In that case don't bother with the test project I shared. That was just to show that the default condition was blank. I tried making another test project but this one is working. I'll do some more testing and let you know if I figure something out. The project I'm having the issue in is too big to upload.

skyace65 commented 2 years ago

I just took the addons and dialogic folders and put them in a separate project, now the scripts are working properly. Since this doesn't seem to be an issue with the plugin I'll close this issue.

coppolaemilio commented 2 years ago

Thanks! If you figure out what it is let me know to see if there is anything I can do to prevent it from happening! Cheers :)