-
Notifications
You must be signed in to change notification settings - Fork 3
/
UniversalFunctions.gd
133 lines (122 loc) · 4.39 KB
/
UniversalFunctions.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
extends Node
signal language_set
onready var dialogueBox : Node2D = get_tree().get_root().get_node_or_null("/root/world/Commandprompt")
onready var synthia : Node2D = get_tree().get_root().get_node_or_null("/root/world/Virtualhell")
onready var world : Node2D = get_tree().get_root().get_node_or_null("/root/world/")
onready var nervousTimer : Timer = get_tree().get_root().get_node_or_null("/root/world/NervousTimer")
var dialogueJson
var dialogueEnded = false
var loneliness = 44
var disgust = 15
var locked = false
var interest = ""
var firstName = "null"
var lastName = "null"
var variableOptions = "AdaSurprise"
var emptyFilled = "stillEmpty"
var nameReaction = "nameNormal"
var TalkAbout = {"SpendTime":false,
"WhatWereYouLike":false,
"ElfTalk":false,
"RequiresBlowAWish": true,
"AdaSurpriseUgly":false,
"AdaNonSurpriseUgly":true,
"Oscilator":true,
"OscilatorNon":true,
"CultDirect":true,
"CultNonDirect":true,
"DungeonsAndDragonsCont":true}
var adaOrYou = "you"
var foundationSnippet = "noFoundation"
var ending = "firedBest"
var generating = false
var whatsYourNameContinue = ""
var language = ""
var languageOptionPosition = {
"_CN":[59, 48, 37],
"_CNFileSystem":10
}
func reset():
dialogueBox = get_tree().get_root().get_node_or_null("/root/world/Commandprompt")
synthia = get_tree().get_root().get_node_or_null("/root/world/Virtualhell")
nervousTimer = get_tree().get_root().get_node_or_null("/root/world/NervousTimer")
world = get_tree().get_root().get_node_or_null("/root/world/")
var file = File.new()
assert(file.file_exists("res://Resources/Text/Text"+language+".json"))
file.open("res://Resources/Text/Text"+language+".json", file.READ)
dialogueJson = parse_json(file.get_as_text())
func set_text():
var file = File.new()
assert(file.file_exists("res://Resources/Text/Text"+language+".json"))
file.open("res://Resources/Text/Text"+language+".json", file.READ)
dialogueJson = parse_json(file.get_as_text())
emit_signal("language_set")
func play_dialogue_JSON(dialogue : String):
if nervousTimer != null:
nervousTimer.stop()
get_tree().get_root().get_node_or_null("/root/world/Commandprompt/Options/Option1").visible = false
get_tree().get_root().get_node_or_null("/root/world/Commandprompt/Options/Option2").visible = false
get_tree().get_root().get_node_or_null("/root/world/Commandprompt/Options/Option3").visible = false
dialogue = dialogue.replace("{Var}", UniversalFunctions.whatsYourNameContinue)
if dialogueJson.has(dialogue) == false:
dialogueBox.dialogue = dialogueJson["dialogueError"]
dialogueBox.currentTree = dialogue
if disgust < 20:
if loneliness <60:
if dialogueJson.has("fine"+dialogue):
dialogueBox.dialogue = dialogueJson["fine"+dialogue]
dialogueBox.currentTree = "fine"+dialogue
elif loneliness >= 60:
if dialogueJson.has("sad"+dialogue):
dialogueBox.dialogue = dialogueJson["sad"+dialogue]
dialogueBox.currentTree = "angry"+dialogue
elif disgust >=20:
if dialogueJson.has("angry"+dialogue):
dialogueBox.dialogue = dialogueJson["angry"+dialogue]
dialogueBox.currentTree = "angry"+dialogue
else:
dialogueBox.dialogue = dialogueJson[dialogue]
dialogueBox.currentTree = dialogue
#makes sure the past dialogue plays the right dialogue
if dialogueBox.dialogue != dialogueJson["dialogueError"]:
if dialogueBox.pastDialogue[-1]["name"] == dialogue:
dialogueBox.pastDialogue[-1]["name"] = dialogueBox.currentTree
dialogueBox.page = 0
dialogueBox.endpoint = dialogueBox.dialogue.size() - 1
dialogueBox.firstline = true
dialogueBox._play_dialog()
yield(dialogueBox, "done")
if nervousTimer != null:
nervousTimer.start()
func change_scenes_reload(scene):
set_text()
get_tree().change_scene(scene)
func change_scenes_reset(scene):
get_tree().change_scene(scene)
dialogueJson
dialogueEnded = false
loneliness = 44
disgust = 15
locked = false
interest
firstName = "null"
lastName = "null"
variableOptions = "AdaSurprise"
emptyFilled = "stillEmpty"
nameReaction = "nameNormal"
TalkAbout = {"SpendTime":false,
"WhatWereYouLike":false,
"ElfTalk":false,
"RequiresBlowAWish": true,
"AdaSurpriseUgly":false,
"AdaNonSurpriseUgly":true,
"Oscilator":true,
"OscilatorNon":true,
"CultDirect":true,
"CultNonDirect":true,
"DungeonsAndDragonsCont":true}
adaOrYou = "you"
foundationSnippet = "noFoundation"
ending = "firedBest"
generating = false
whatsYourNameContinue = ""