Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions addons/dialogic/Modules/Variable/event_variable.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 ########################################
################################################################################
Expand Down