diff --git a/addons/dialogic/Modules/Variable/event_variable.gd b/addons/dialogic/Modules/Variable/event_variable.gd index f23c347db..c812d4eff 100644 --- a/addons/dialogic/Modules/Variable/event_variable.gd +++ b/addons/dialogic/Modules/Variable/event_variable.gd @@ -89,14 +89,14 @@ func _execute() -> void: VarValueType.NUMBER, VarValueType.BOOL, VarValueType.EXPRESSION, VarValueType.RANDOM_NUMBER: interpreted_value = dialogic.VAR.get_variable(str(value)) - if operation != Operations.SET and (not str(original_value).is_valid_float() or not str(interpreted_value).is_valid_float()): + if operation == Operations.SET: + result = interpreted_value + elif (DialogicUtil.get_variable_type(name) == DialogicUtil.VarTypes.STRING and _value_type == VarValueType.STRING and interpreted_value and operation == Operations.ADD): + result = original_value + interpreted_value + elif not str(original_value).is_valid_float() or not str(interpreted_value).is_valid_float(): printerr("[Dialogic] Set Variable event failed because one value wasn't a float! [", original_value, ", ",interpreted_value,"]") finish() return - - if operation == Operations.SET: - result = interpreted_value - else: original_value = float(original_value) interpreted_value = float(interpreted_value) @@ -341,18 +341,15 @@ func _on_variable_editor_pressed() -> void: func update_editor_warning() -> void: - if _value_type == VarValueType.STRING and operation != Operations.SET: + if _value_type == VarValueType.STRING and operation != Operations.SET and operation != Operations.ADD: ui_update_warning.emit('You cannot do this operation with a string!') elif operation != Operations.SET: var type := DialogicUtil.get_variable_type(name) if not type in [DialogicUtil.VarTypes.INT, DialogicUtil.VarTypes.FLOAT, DialogicUtil.VarTypes.ANY]: - ui_update_warning.emit('The selected variable is not a number!') - else: - ui_update_warning.emit('') - else: - ui_update_warning.emit('') - - + if not (type == DialogicUtil.VarTypes.STRING and operation == Operations.ADD and _value_type == VarValueType.STRING): + ui_update_warning.emit('The selected variable is not a number!') + return + ui_update_warning.emit('') ####################### CODE COMPLETION ######################################## ################################################################################