Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | LunarBeach |
Relevant code:
func _input(event):
buttons = get_tree().get_nodes_in_group(“Buttons”)
for button in buttons:
button.connect(“pressed”, self, “_some_button_pressed”, [button])
ready = Input.is_action_just_released(“accept”)
other function…
…for opt in turn_text.keys():
buttons[i].name = opt
i += 1
func _some_button_pressed(button):
branch = button.name
print(branch)
return branch
The JSON file it is pulling from:
[
{“name”:“Nat”, “expression”:“neutral”, “text”:{“a”:“Dean you are so cool and I love you so much.”}, “xp”:5 },
{“name”:“You”, “expression”:“neutral”, “text”:{“a”:“Pshh. What a nerd.”, “b”:“BBBBBBBBBBBBBBBBBBBBBB?”, “c”:“Wow look another option!”} },
{“name”:“Nat”, “expression”:“neutral”, “text”:{“a”:“abracadabra”, “b”:“Barn Yard”} },
{“name”:“You”, “expression”:“nervous”, “text”:{“a”:“Go away weirdo.”, “a1”:“I love you, Nat”} },
{“name”:“You”, “expression”:“neutral”, “text”:{“b”:“Barnicles!”, “b1”:“Butts and butts”} },
{“name”:“You”, “expression”:“neutral”, “text”:{“b”:“Lets eat a fancy dinner.”, “b1”:“I hate you.”} },
{“name”:“Nat”, “expression”:“neutral”, “text”:{“a”:“okay King, I love you.”, “a1”:“I hate you.”} }
]
It happens when I click “Barnicles!”
This happens when you have multiple instances of the same node with the same name at the same node path
So i suppose you could do branch = str(name.replace("@", "").replace(str(int(name)), ""))
Wakatta | 2020-12-22 20:45
That explains a lot. I was very curious as to why this was happening.
LunarBeach | 2020-12-22 23:46