From 29cdea6778007b013439af0df12e6bfbda17f11b Mon Sep 17 00:00:00 2001 From: bhgt Date: Sun, 13 Feb 2022 15:20:54 +0530 Subject: [PATCH] Added Condition functionality --- addons/dialogue_nodes/NodeEditor.tscn | 6 +- .../dialogue_nodes/nodes/ConditionNode.tscn | 80 +++++++++++++++++ addons/dialogue_nodes/nodes/SetNode.tscn | 88 +++++-------------- addons/dialogue_nodes/nodes/SignalNode.tscn | 24 ++--- addons/dialogue_nodes/nodes/conditionNode.gd | 53 +++++++++++ addons/dialogue_nodes/nodes/setNode.gd | 6 +- addons/dialogue_nodes/nodes/signalNode.gd | 2 +- addons/dialogue_nodes/objects/dialogueBox.gd | 65 ++++++++++++++ examples/Demo.tscn | 4 +- examples/Example1.json | 2 +- examples/Example2.json | 2 +- examples/Example3.json | 2 +- examples/Example4.json | 2 +- 13 files changed, 239 insertions(+), 97 deletions(-) create mode 100644 addons/dialogue_nodes/nodes/ConditionNode.tscn create mode 100644 addons/dialogue_nodes/nodes/conditionNode.gd diff --git a/addons/dialogue_nodes/NodeEditor.tscn b/addons/dialogue_nodes/NodeEditor.tscn index 81970ad..4b67c60 100644 --- a/addons/dialogue_nodes/NodeEditor.tscn +++ b/addons/dialogue_nodes/NodeEditor.tscn @@ -55,7 +55,7 @@ margin_right = 114.0 margin_bottom = 22.0 keep_pressed_outside = true text = "Add Node" -items = [ "StartNode", null, 0, false, false, 0, 0, null, "", false, "DialogueNode", null, 0, false, false, 1, 0, null, "", false, "CommentNode", null, 0, false, false, 2, 0, null, "", false, "SignalNode", null, 0, false, false, 3, 0, null, "", false, "SetNode", null, 0, false, false, 4, 0, null, "", false ] +items = [ "StartNode", null, 0, false, false, 0, 0, null, "", false, "DialogueNode", null, 0, false, false, 1, 0, null, "", false, "CommentNode", null, 0, false, false, 2, 0, null, "", false, "SignalNode", null, 0, false, false, 3, 0, null, "", false, "SetNode", null, 0, false, false, 4, 0, null, "", false, "ConditionNode", null, 0, false, false, 5, 0, null, "", false ] switch_on_hover = true [node name="RunMenu" type="MenuButton" parent="Main/ToolBar"] @@ -76,7 +76,7 @@ script = ExtResource( 7 ) __meta__ = { "_edit_use_anchors_": false } -nodeScenes = [ "res://addons/dialogue_nodes/nodes/StartNode.tscn", "res://addons/dialogue_nodes/nodes/DialogueNode.tscn", "res://addons/dialogue_nodes/nodes/CommentNode.tscn", "res://addons/dialogue_nodes/nodes/SignalNode.tscn", "res://addons/dialogue_nodes/nodes/SetNode.tscn" ] +nodeScenes = [ "res://addons/dialogue_nodes/nodes/StartNode.tscn", "res://addons/dialogue_nodes/nodes/DialogueNode.tscn", "res://addons/dialogue_nodes/nodes/CommentNode.tscn", "res://addons/dialogue_nodes/nodes/SignalNode.tscn", "res://addons/dialogue_nodes/nodes/SetNode.tscn", "res://addons/dialogue_nodes/nodes/ConditionNode.tscn" ] [node name="SidePanel" type="VSplitContainer" parent="Main/Workspace"] margin_right = 1016.0 @@ -134,7 +134,7 @@ __meta__ = { [node name="PopupMenu" type="PopupMenu" parent="Main/Workspace/Graph"] margin_right = 16.0 margin_bottom = 16.0 -items = [ "StartNode", null, 0, false, false, 0, 0, null, "", false, "DialogueNode", null, 0, false, false, 1, 0, null, "", false, "CommentNode", null, 0, false, false, 2, 0, null, "", false, "SignalNode", null, 0, false, false, 3, 0, null, "", false, "SetNode", null, 0, false, false, 4, 0, null, "", false ] +items = [ "StartNode", null, 0, false, false, 0, 0, null, "", false, "DialogueNode", null, 0, false, false, 1, 0, null, "", false, "CommentNode", null, 0, false, false, 2, 0, null, "", false, "SignalNode", null, 0, false, false, 3, 0, null, "", false, "SetNode", null, 0, false, false, 4, 0, null, "", false, "ConditionNode", null, 0, false, false, 5, 0, null, "", false ] allow_search = true __meta__ = { "_edit_use_anchors_": false diff --git a/addons/dialogue_nodes/nodes/ConditionNode.tscn b/addons/dialogue_nodes/nodes/ConditionNode.tscn new file mode 100644 index 0000000..d5303ce --- /dev/null +++ b/addons/dialogue_nodes/nodes/ConditionNode.tscn @@ -0,0 +1,80 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/dialogue_nodes/nodes/conditionNode.gd" type="Script" id=1] + +[node name="ConditionNode" type="GraphNode"] +margin_right = 240.0 +margin_bottom = 110.0 +title = "ConditionNode" +show_close = true +slot/0/left_enabled = true +slot/0/left_type = 0 +slot/0/left_color = Color( 1, 1, 1, 1 ) +slot/0/right_enabled = false +slot/0/right_type = 0 +slot/0/right_color = Color( 1, 1, 1, 1 ) +slot/1/left_enabled = false +slot/1/left_type = 0 +slot/1/left_color = Color( 1, 1, 1, 1 ) +slot/1/right_enabled = true +slot/1/right_type = 0 +slot/1/right_color = Color( 0.647059, 0.937255, 0.67451, 1 ) +slot/2/left_enabled = false +slot/2/left_type = 0 +slot/2/left_color = Color( 1, 1, 1, 1 ) +slot/2/right_enabled = true +slot/2/right_type = 0 +slot/2/right_color = Color( 1, 0.364706, 0.364706, 1 ) +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +margin_left = 16.0 +margin_top = 24.0 +margin_right = 224.0 +margin_bottom = 48.0 + +[node name="Value1" type="LineEdit" parent="HBoxContainer"] +margin_right = 77.0 +margin_bottom = 24.0 +hint_tooltip = "The property to set the value of." +size_flags_horizontal = 3 +placeholder_text = "Value" + +[node name="Operator" type="OptionButton" parent="HBoxContainer"] +margin_left = 81.0 +margin_right = 126.0 +margin_bottom = 24.0 +hint_tooltip = "The type of the value to set." +text = "==" +items = [ "==", null, false, 0, null, "!=", null, false, 1, null, ">", null, false, 2, null, "<", null, false, 3, null, ">=", null, false, 4, null, "<=", null, false, 5, null ] +selected = 0 + +[node name="Value2" type="LineEdit" parent="HBoxContainer"] +margin_left = 130.0 +margin_right = 208.0 +margin_bottom = 24.0 +hint_tooltip = "The value to set the property to. +Eg: Bob, 12, 0.5, false, etc." +size_flags_horizontal = 3 +placeholder_text = "Value" + +[node name="TrueLabel" type="ItemList" parent="."] +margin_left = 16.0 +margin_top = 49.0 +margin_right = 224.0 +margin_bottom = 76.0 +mouse_filter = 2 +items = [ "True", null, false ] +auto_height = true + +[node name="FalseLabel" type="ItemList" parent="."] +margin_left = 16.0 +margin_top = 77.0 +margin_right = 224.0 +margin_bottom = 104.0 +mouse_filter = 2 +items = [ "False", null, false ] +auto_height = true diff --git a/addons/dialogue_nodes/nodes/SetNode.tscn b/addons/dialogue_nodes/nodes/SetNode.tscn index 9be39f7..6ee8ae6 100644 --- a/addons/dialogue_nodes/nodes/SetNode.tscn +++ b/addons/dialogue_nodes/nodes/SetNode.tscn @@ -3,9 +3,9 @@ [ext_resource path="res://addons/dialogue_nodes/nodes/setNode.gd" type="Script" id=1] [node name="SetNode" type="GraphNode"] -margin_right = 160.0 -margin_bottom = 100.0 -title = "Set Value" +margin_right = 240.0 +margin_bottom = 60.0 +title = "SetNode" show_close = true slot/0/left_enabled = true slot/0/left_type = 0 @@ -13,86 +13,42 @@ slot/0/left_color = Color( 1, 1, 1, 1 ) slot/0/right_enabled = true slot/0/right_type = 0 slot/0/right_color = Color( 1, 1, 1, 1 ) -slot/1/left_enabled = false -slot/1/left_type = 0 -slot/1/left_color = Color( 1, 1, 1, 1 ) -slot/1/right_enabled = false -slot/1/right_type = 0 -slot/1/right_color = Color( 1, 1, 1, 1 ) -slot/2/left_enabled = false -slot/2/left_type = 0 -slot/2/left_color = Color( 1, 1, 1, 1 ) -slot/2/right_enabled = false -slot/2/right_type = 0 -slot/2/right_color = Color( 1, 1, 1, 1 ) -slot/3/left_enabled = false -slot/3/left_type = 0 -slot/3/left_color = Color( 1, 1, 1, 1 ) -slot/3/right_enabled = false -slot/3/right_type = 0 -slot/3/right_color = Color( 1, 1, 1, 1 ) -slot/4/left_enabled = false -slot/4/left_type = 0 -slot/4/left_color = Color( 1, 1, 1, 1 ) -slot/4/right_enabled = false -slot/4/right_type = 0 -slot/4/right_color = Color( 1, 1, 1, 1 ) script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } -[node name="VariableLabel" type="Label" parent="."] +[node name="HBoxContainer" type="HBoxContainer" parent="."] margin_left = 16.0 margin_top = 24.0 -margin_right = 144.0 -margin_bottom = 38.0 -text = "Variable" +margin_right = 224.0 +margin_bottom = 48.0 -[node name="Variable" type="LineEdit" parent="."] -margin_left = 16.0 -margin_top = 39.0 -margin_right = 144.0 -margin_bottom = 63.0 +[node name="Variable" type="LineEdit" parent="HBoxContainer"] +margin_right = 81.0 +margin_bottom = 24.0 hint_tooltip = "The property to set the value of." - -[node name="HBoxContainer" type="HBoxContainer" parent="."] -margin_left = 16.0 -margin_top = 64.0 -margin_right = 144.0 -margin_bottom = 84.0 - -[node name="OperatorLabel" type="Label" parent="HBoxContainer"] -margin_top = 3.0 -margin_right = 61.0 -margin_bottom = 17.0 -text = "Operator " +size_flags_horizontal = 3 +placeholder_text = "Variable" [node name="Type" type="OptionButton" parent="HBoxContainer"] -margin_left = 65.0 -margin_right = 128.0 -margin_bottom = 20.0 +margin_left = 85.0 +margin_right = 122.0 +margin_bottom = 24.0 hint_tooltip = "The type of the value to set." -size_flags_horizontal = 3 text = "=" items = [ "=", null, false, 0, null, "+=", null, false, 1, null, "-=", null, false, 2, null, "*=", null, false, 3, null, "/=", null, false, 4, null ] selected = 0 -[node name="ValueLabel" type="Label" parent="."] -margin_left = 16.0 -margin_top = 85.0 -margin_right = 144.0 -margin_bottom = 99.0 -text = "Value:" - -[node name="Value" type="LineEdit" parent="."] -margin_left = 16.0 -margin_top = 100.0 -margin_right = 144.0 -margin_bottom = 124.0 +[node name="Value" type="LineEdit" parent="HBoxContainer"] +margin_left = 126.0 +margin_right = 208.0 +margin_bottom = 24.0 hint_tooltip = "The value to set the property to. Eg: Bob, 12, 0.5, false, etc." +size_flags_horizontal = 3 +placeholder_text = "Value" -[connection signal="text_changed" from="Variable" to="." method="set_variable"] +[connection signal="text_changed" from="HBoxContainer/Variable" to="." method="set_variable"] [connection signal="item_selected" from="HBoxContainer/Type" to="." method="set_type"] -[connection signal="text_changed" from="Value" to="." method="set_value"] +[connection signal="text_changed" from="HBoxContainer/Value" to="." method="set_value"] diff --git a/addons/dialogue_nodes/nodes/SignalNode.tscn b/addons/dialogue_nodes/nodes/SignalNode.tscn index 5fe54c1..8a50fc8 100644 --- a/addons/dialogue_nodes/nodes/SignalNode.tscn +++ b/addons/dialogue_nodes/nodes/SignalNode.tscn @@ -3,8 +3,8 @@ [ext_resource path="res://addons/dialogue_nodes/nodes/signalNode.gd" type="Script" id=1] [node name="SignalNode" type="GraphNode"] -margin_right = 160.0 -margin_bottom = 80.0 +margin_right = 200.0 +margin_bottom = 60.0 title = "Signal" show_close = true slot/0/left_enabled = true @@ -13,29 +13,17 @@ slot/0/left_color = Color( 1, 1, 1, 1 ) slot/0/right_enabled = true slot/0/right_type = 0 slot/0/right_color = Color( 1, 1, 1, 1 ) -slot/1/left_enabled = false -slot/1/left_type = 0 -slot/1/left_color = Color( 1, 1, 1, 1 ) -slot/1/right_enabled = false -slot/1/right_type = 0 -slot/1/right_color = Color( 1, 1, 1, 1 ) script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } -[node name="Label" type="Label" parent="."] -margin_left = 16.0 -margin_top = 24.0 -margin_right = 144.0 -margin_bottom = 38.0 -text = "Value:" - [node name="SignalValue" type="LineEdit" parent="."] margin_left = 16.0 -margin_top = 39.0 -margin_right = 144.0 -margin_bottom = 63.0 +margin_top = 24.0 +margin_right = 184.0 +margin_bottom = 48.0 hint_tooltip = "The String value passed in the signal parameter." +placeholder_text = "Value" [connection signal="text_changed" from="SignalValue" to="." method="_on_node_modified"] diff --git a/addons/dialogue_nodes/nodes/conditionNode.gd b/addons/dialogue_nodes/nodes/conditionNode.gd new file mode 100644 index 0000000..9747bdd --- /dev/null +++ b/addons/dialogue_nodes/nodes/conditionNode.gd @@ -0,0 +1,53 @@ +tool +extends GraphNode + +enum {EQUAL, NEQUAL, GREATER, LESS, GEQUAL, LEQUAL} + +signal modified + +onready var value1 = $HBoxContainer/Value1 +onready var operator = $HBoxContainer/Operator +onready var value2 = $HBoxContainer/Value2 + +onready var trueLabel = $TrueLabel +onready var falseLabel = $FalseLabel + + +func _to_dict(graph): + var dict = {} + dict['value1'] = value1.text + dict['operator'] = operator.selected + dict['value2'] = value2.text + + dict['true'] = 'END' + dict['false'] = 'END' + + for connection in graph.get_connection_list(): + if connection['from'] == name: + if connection['from_port'] == 0: + dict['true'] = connection['to'] + elif connection['from_port'] == 1: + dict['false'] = connection['to'] + + return dict + + +func _from_dict(_graph, dict): + value1.text = dict['value1'] + operator.selected = dict['operator'] + value2.text = dict['value2'] + + + return [dict['true'], dict['false']] + + +func set_type(_new_type): + _on_modified() + + +func set_value(_new_val): + _on_modified() + + +func _on_modified(): + emit_signal("modified") diff --git a/addons/dialogue_nodes/nodes/setNode.gd b/addons/dialogue_nodes/nodes/setNode.gd index 2624116..ed09179 100644 --- a/addons/dialogue_nodes/nodes/setNode.gd +++ b/addons/dialogue_nodes/nodes/setNode.gd @@ -5,9 +5,9 @@ enum {STRING, INT, FLOAT, BOOL} signal modified -onready var variable = $Variable +onready var variable = $HBoxContainer/Variable onready var type = $HBoxContainer/Type -onready var value = $Value +onready var value = $HBoxContainer/Value func _to_dict(graph): @@ -19,7 +19,7 @@ func _to_dict(graph): var next_nodes = graph.get_next(name) if len(next_nodes) > 0: - dict['link'] = graph.get_next(name)[0] + dict['link'] = next_nodes[0] else: dict['link'] = 'END' diff --git a/addons/dialogue_nodes/nodes/signalNode.gd b/addons/dialogue_nodes/nodes/signalNode.gd index 88c6d28..2f14aa5 100644 --- a/addons/dialogue_nodes/nodes/signalNode.gd +++ b/addons/dialogue_nodes/nodes/signalNode.gd @@ -14,7 +14,7 @@ func _to_dict(graph): var next_nodes = graph.get_next(name) if len(next_nodes) > 0: - dict['link'] = graph.get_next(name)[0] + dict['link'] = next_nodes[0] else: dict['link'] = 'END' diff --git a/addons/dialogue_nodes/objects/dialogueBox.gd b/addons/dialogue_nodes/objects/dialogueBox.gd index d6b448f..5d1e4e8 100644 --- a/addons/dialogue_nodes/objects/dialogueBox.gd +++ b/addons/dialogue_nodes/objects/dialogueBox.gd @@ -155,6 +155,9 @@ func proceed(idx): emit_signal("variable_changed", var_name, variables[var_name]) proceed(var_dict['link']) + '5': + # condition + handle_condition(dict[idx]) _: if dict[idx].has('link'): proceed(dict[idx]['link']) @@ -217,6 +220,20 @@ func process_text(text : String): return text +func get_variable(text : String): + # Find tag position + var tag_start = text.find('{{')+2 + var tag_len = text.find('}}') - tag_start + + # Find variable value + var var_name = text.substr(tag_start, tag_len) + var value = 'undefined' + if variables.has(var_name): + value = variables[var_name] + + return value + + func set_variable(var_name, type, value, operator = 0): # Set datatype of value @@ -249,6 +266,54 @@ func set_variable(var_name, type, value, operator = 0): variables[var_name] /= value +func handle_condition(cond_dict): + var value1 = cond_dict['value1'] + var value2 = cond_dict['value2'] + var type = TYPE_STRING + + # Get variables if needed + if value1.count('{{') > 0: + value1 = get_variable(value1) + type = typeof(value1) + if value2.count('{{') > 0: + value2 = get_variable(value2) + type = typeof(value2) + + # Set datatype of values + match type: + TYPE_STRING: + value1 = str(value1) + value2 = str(value2) + TYPE_INT: + value1 = int(value1) + value2 = int(value2) + TYPE_REAL: + value1 = float(value1) + value2 = float(value2) + TYPE_BOOL: + value1 = bool(value1) + value2 = bool(value2) + + # Perform operation + var result : bool = false + match cond_dict['operator']: + 0: + result = value1 == value2 + 1: + result = value1 != value2 + 2: + result = value1 > value2 + 3: + result = value1 < value2 + 4: + result = value1 >= value2 + 5: + result = value1 <= value2 + + # Proceed + proceed(cond_dict[str(result).to_lower()]) + + func _set_options_alignment(value): options_alignment = value if options: diff --git a/examples/Demo.tscn b/examples/Demo.tscn index 7099686..c4b1611 100644 --- a/examples/Demo.tscn +++ b/examples/Demo.tscn @@ -202,8 +202,8 @@ script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } -dialogue_file = "res://examples/Example4.json" -start_id = "SETGET" +dialogue_file = "res://examples/Example1.json" +start_id = "START" custom_effects = [ SubResource( 13 ) ] [node name="Button" type="Button" parent="."] diff --git a/examples/Example1.json b/examples/Example1.json index 6bb0cf9..82ad8fc 100644 --- a/examples/Example1.json +++ b/examples/Example1.json @@ -1 +1 @@ -{"0_1":{"link":"1_1","offset":{"x":0,"y":0},"start_id":"START"},"1_1":{"dialogue":"[wait]What's up dude?","offset":{"x":200,"y":0},"options":{"0":{"link":"END","text":"All good!"}},"size":{"x":200,"y":200},"speaker":"Fred"},"2_1":{"comment":"I'm a sample comment!","offset":{"x":-20,"y":80},"size":{"x":200,"y":100.000031}},"comments":{"0":"2_1"},"start":{"START":"0_1"},"strays":{},"variables":{}} +{"0_1":{"link":"1_1","offset":{"x":0,"y":0},"start_id":"START"},"1_1":{"dialogue":"Hey there!","offset":{"x":200,"y":0},"options":{"0":{"link":"END","text":"Hi!"}},"size":{"x":200,"y":200.000015},"speaker":"Fred"},"2_1":{"comment":"A simple example of a dialogue tree.","offset":{"x":-20,"y":80},"size":{"x":205,"y":119.000015}},"comments":{"0":"2_1"},"start":{"START":"0_1"},"strays":{},"variables":{}} diff --git a/examples/Example2.json b/examples/Example2.json index 1768cb5..b337dd7 100644 --- a/examples/Example2.json +++ b/examples/Example2.json @@ -1 +1 @@ -{"0_1":{"link":"1_2","offset":{"x":0,"y":0},"start_id":"START"},"0_2":{"link":"1_4","offset":{"x":0,"y":400},"start_id":"START2"},"1_1":{"dialogue":"You had to take the blue pill, silly!","offset":{"x":480,"y":-60},"options":{"0":{"link":"END","text":"Oh"}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_2":{"dialogue":"Which pill do you take?","offset":{"x":200,"y":0},"options":{"0":{"link":"1_1","text":"Red pill"},"1":{"link":"1_3","text":"Blue pill"}},"size":{"x":200,"y":201},"speaker":"Fred"},"1_3":{"dialogue":"Wrong! It was the red pill, LOL!","offset":{"x":480,"y":160},"options":{"0":{"link":"END","text":"Oh"}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_4":{"dialogue":"You can have multiple conversations in the same file if you want.","offset":{"x":200,"y":400},"options":{"0":{"link":"1_5","text":""}},"size":{"x":200,"y":200},"speaker":"Hannah"},"1_5":{"dialogue":"Isn't that handy?","offset":{"x":600,"y":400},"options":{"0":{"link":"END","text":""}},"size":{"x":200,"y":200},"speaker":"Hannah"},"2_1":{"comment":"Branching\n& Multiple trees!","offset":{"x":-20,"y":80},"size":{"x":200,"y":100}},"comments":{"0":"2_1"},"start":{"START":"0_1","START2":"0_2"},"strays":{},"variables":{}} +{"0_1":{"link":"1_2","offset":{"x":0,"y":0},"start_id":"START"},"0_2":{"link":"1_4","offset":{"x":0,"y":400},"start_id":"START2"},"1_1":{"dialogue":"You had to take the blue pill, silly!","offset":{"x":480,"y":-60},"options":{"0":{"link":"END","text":"Oh"}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_2":{"dialogue":"Which pill do you take?","offset":{"x":200,"y":0},"options":{"0":{"link":"1_1","text":"Red pill"},"1":{"link":"1_3","text":"Blue pill"}},"size":{"x":238,"y":201.000015},"speaker":"Fred"},"1_3":{"dialogue":"Wrong! It was the red pill, LOL!","offset":{"x":480,"y":160},"options":{"0":{"link":"END","text":"Oh"}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_4":{"dialogue":"You can have multiple conversations in the same file if you want.","offset":{"x":200,"y":400},"options":{"0":{"link":"1_5","text":""}},"size":{"x":381,"y":200},"speaker":"Hannah"},"1_5":{"dialogue":"Isn't that handy?","offset":{"x":600,"y":400},"options":{"0":{"link":"END","text":""}},"size":{"x":200,"y":200},"speaker":"Hannah"},"2_1":{"comment":"Branching\n& Multiple trees!","offset":{"x":-20,"y":80},"size":{"x":200,"y":100.000015}},"comments":{"0":"2_1"},"start":{"START":"0_1","START2":"0_2"},"strays":{},"variables":{}} diff --git a/examples/Example3.json b/examples/Example3.json index b2e9184..ffbd860 100644 --- a/examples/Example3.json +++ b/examples/Example3.json @@ -1 +1 @@ -{"0_1":{"link":"1_2","offset":{"x":0,"y":0},"start_id":"START"},"1_2":{"dialogue":"Do you want learn about [u]bbcodes[/u]?","offset":{"x":200,"y":0},"options":{"0":{"link":"1_6","text":"yah"},"1":{"link":"1_4","text":"Nah"}},"size":{"x":200,"y":201},"speaker":"Fred"},"1_4":{"dialogue":"[shake rate=20 level=6]Oh too bad. :([/shake]","offset":{"x":540,"y":220},"options":{"0":{"link":"1_6","text":"On second thoughts..."},"1":{"link":"END","text":"Sorry"}},"size":{"x":200,"y":201},"speaker":"Fred"},"1_6":{"dialogue":"Ok so, in the dialogue section of a dialogue Node, you can insert special keywords between [ ] to have certain effects.","offset":{"x":540,"y":-60},"options":{"0":{"link":"1_7","text":""}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_7":{"dialogue":"For example:\nputting the letter u between [ ] gives [u]text an underline[/u].\nEnd the effect with [/*], where * is the name of the effect (here, u).","offset":{"x":800,"y":-60},"options":{"0":{"link":"1_8","text":""}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_8":{"dialogue":"Some more examples:\n[ [fade length=5] fade [/fade] ]\n\n[ [color=red] color=red [/color] ]\n\n[ [shake rate=20 level=6] shake rate=15 level=6 [/shake] ]\n\n[ [wave] wave [/wave] ]\n\n[ [tornado] tornado [/tornado]]\n\n[ [rainbow] rainbow [/rainbow] ]","offset":{"x":1060,"y":-60},"options":{"0":{"link":"1_9","text":""}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_9":{"dialogue":"you can even combine effects like:\n[E1] [E2] text [/E2] [E1]\nWhere E1 and E2 could be anything.\n\n[rainbow] [wave] Example: Rainbow + Wave [/wave] [/rainbow]","offset":{"x":1320,"y":-60},"options":{"0":{"link":"1_6","text":"One more time?"},"1":{"link":"END","text":"Ok got it!"}},"size":{"x":200,"y":201},"speaker":"Fred"},"2_1":{"comment":"This example shows how to use bbcodes in your dialogues, as well as an example of a looping dialogue tree.","offset":{"x":-20,"y":100},"size":{"x":200.000061,"y":200}},"comments":{"0":"2_1"},"start":{"START":"0_1"},"strays":{},"variables":{}} +{"0_1":{"link":"1_2","offset":{"x":0,"y":0},"start_id":"START"},"1_2":{"dialogue":"Do you want learn about [u]bbcodes[/u]?","offset":{"x":200,"y":0},"options":{"0":{"link":"1_6","text":"yah"},"1":{"link":"1_4","text":"Nah"}},"size":{"x":200,"y":201.000015},"speaker":"Fred"},"1_4":{"dialogue":"[shake rate=20 level=6]Oh too bad. :([/shake]","offset":{"x":540,"y":220},"options":{"0":{"link":"1_6","text":"On second thoughts..."},"1":{"link":"END","text":"Sorry"}},"size":{"x":200,"y":201},"speaker":"Fred"},"1_6":{"dialogue":"Ok so, in the dialogue section of a dialogue Node, you can insert special keywords between [ ] to have certain effects.","offset":{"x":540,"y":-60},"options":{"0":{"link":"1_7","text":""}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_7":{"dialogue":"For example:\nputting the letter u between [ ] gives [u]text an underline[/u].\nEnd the effect with [/*], where * is the name of the effect (here, u).","offset":{"x":800,"y":-60},"options":{"0":{"link":"1_8","text":""}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_8":{"dialogue":"Some more examples:\n[ [fade length=5] fade [/fade] ]\n\n[ [color=red] color=red [/color] ]\n\n[ [shake rate=20 level=6] shake rate=15 level=6 [/shake] ]\n\n[ [wave] wave [/wave] ]\n\n[ [tornado] tornado [/tornado]]\n\n[ [rainbow] rainbow [/rainbow] ]","offset":{"x":1060,"y":-60},"options":{"0":{"link":"1_9","text":""}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_9":{"dialogue":"you can even combine effects like:\n[E1] [E2] text [/E2] [E1]\nWhere E1 and E2 could be anything.\n\n[rainbow] [wave] Example: Rainbow + Wave [/wave] [/rainbow]","offset":{"x":1320,"y":-60},"options":{"0":{"link":"1_6","text":"One more time?"},"1":{"link":"END","text":"Ok got it!"}},"size":{"x":200,"y":201},"speaker":"Fred"},"2_1":{"comment":"This example shows how to use bbcodes in your dialogues, as well as an example of a looping dialogue tree.","offset":{"x":-20,"y":100},"size":{"x":200.000061,"y":200.000015}},"comments":{"0":"2_1"},"start":{"START":"0_1"},"strays":{},"variables":{}} diff --git a/examples/Example4.json b/examples/Example4.json index d9d79a5..96b7cf4 100644 --- a/examples/Example4.json +++ b/examples/Example4.json @@ -1 +1 @@ -{"0_1":{"link":"1_1","offset":{"x":0,"y":0},"start_id":"EXPLODE"},"0_2":{"link":"1_5","offset":{"x":0,"y":400},"start_id":"SETGET"},"1_1":{"dialogue":"Wanna see an explosion?","offset":{"x":200,"y":0},"options":{"0":{"link":"3_1","text":"Yeah!"},"1":{"link":"1_2","text":"Nah!"}},"size":{"x":200,"y":201},"speaker":"Fred"},"1_2":{"dialogue":"Bye bye!","offset":{"x":620,"y":0},"options":{"0":{"link":"END","text":""}},"size":{"x":200,"y":200},"speaker":"Fred"},"1_5":{"dialogue":"You have {{Coins}} coins.","offset":{"x":200,"y":400},"options":{"0":{"link":"4_1","text":"Buy item"}},"size":{"x":200,"y":200},"speaker":"Luke"},"1_6":{"dialogue":"Now, you have {{Coins}} left!","offset":{"x":620,"y":400},"options":{"0":{"link":"END","text":""}},"size":{"x":200,"y":200},"speaker":"Luke"},"2_1":{"comment":"You can add Signal Nodes in the paths to emit signals.","offset":{"x":-20,"y":80},"size":{"x":200,"y":130}},"2_2":{"comment":"You can even add, get and set variables within the dialogue tree.","offset":{"x":-20,"y":480},"size":{"x":200,"y":141}},"3_1":{"link":"1_2","offset":{"x":420,"y":0},"signalValue":"explode"},"4_1":{"link":"1_6","offset":{"x":420,"y":400},"type":2,"value":"3","variable":"Coins"},"comments":{"0":"2_1","1":"2_2"},"start":{"EXPLODE":"0_1","SETGET":"0_2"},"strays":{},"variables":{"Coins":{"type":2,"value":"10"}}} +{"0_1":{"link":"1_1","offset":{"x":0,"y":0},"start_id":"SIGNALS"},"0_2":{"link":"1_5","offset":{"x":0,"y":400},"start_id":"SETGET"},"0_3":{"link":"1_3","offset":{"x":0,"y":800},"start_id":"CONDITION"},"1_1":{"dialogue":"Wanna see an explosion?","offset":{"x":200,"y":0},"options":{"0":{"link":"3_1","text":"Yeah!"},"1":{"link":"1_2","text":"Nah!"}},"size":{"x":200,"y":201.000015},"speaker":"Fred"},"1_2":{"dialogue":"Bye bye!","offset":{"x":680,"y":0},"options":{"0":{"link":"END","text":""}},"size":{"x":200,"y":200.000015},"speaker":"Fred"},"1_3":{"dialogue":"This item costs $8","offset":{"x":200,"y":800},"options":{"0":{"link":"5_1","text":"Buy it!"}},"size":{"x":200,"y":255.000061},"speaker":"Harold"},"1_4":{"dialogue":"Ok","offset":{"x":720,"y":720},"options":{"0":{"link":"END","text":""}},"size":{"x":200,"y":228.000061},"speaker":"Harold"},"1_5":{"dialogue":"You have {{Coins}} coins.","offset":{"x":200,"y":400},"options":{"0":{"link":"4_1","text":"Buy item"}},"size":{"x":200,"y":200},"speaker":"Luke"},"1_6":{"dialogue":"Now, you have {{Coins}} left!","offset":{"x":720,"y":400},"options":{"0":{"link":"END","text":""}},"size":{"x":200,"y":200},"speaker":"Luke"},"1_7":{"dialogue":"You can't afford that!","offset":{"x":720,"y":960},"options":{"0":{"link":"END","text":""}},"size":{"x":200,"y":200.000122},"speaker":"Harold"},"2_1":{"comment":"You can add Signal Nodes in the paths to emit signals.","offset":{"x":-20,"y":80},"size":{"x":200,"y":130.000015}},"2_2":{"comment":"You can even add, get and set variables within the dialogue tree.","offset":{"x":-20,"y":480},"size":{"x":200,"y":141.000061}},"2_3":{"comment":"Condition nodes can be used to control the flow of dialogues.","offset":{"x":-20,"y":880},"size":{"x":201,"y":143.000061}},"3_1":{"link":"1_2","offset":{"x":440,"y":0},"signalValue":"explode"},"4_1":{"link":"1_6","offset":{"x":440,"y":400},"type":2,"value":"3","variable":"Coins"},"5_1":{"false":"1_7","offset":{"x":440,"y":800},"operator":4,"true":"1_4","value1":"{{Coins}}","value2":"8"},"comments":{"0":"2_1","1":"2_2","2":"2_3"},"start":{"CONDITION":"0_3","SETGET":"0_2","SIGNALS":"0_1"},"strays":{},"variables":{"Coins":{"type":2,"value":"10"}}}