Okay, I give. It's possible I'm not even messing with the right part of the code (I recently did a giant overhaul of the game's text just for fun before realizing that the text I was working with was obsolete/nonfunctional and just a few lines had been lifted to an entirely different part of the code, which was the part that actually mattered, sigh). It's possible that I'm overlooking something basic, or that the part of the code I'd actually need to mess with isn't even editable in the user-accessible text-style files, so here I am hoping for answers/guidance.
(Note: I'm a longtime hobbyist coder/game designer, and new to Godot/GDScript, but it's similar to many languages I've used over the years, and most of the basics are easy enough to grasp. So I expect I might be failing at some core distinctions or underlying foundational details.)
Anyway, so, in StatsTab.gd I found the section where some buttons pop up and you can order them to call you by a new name. So I figured I'd try to add a button that lets you change their name. Mostly I'm just copying what seems like a reasonable section of code and changing a few tidbits that seem like they won't break anything. (I do feel a bit like the classmates I tutored back in college, when I was already skilled in Visual Basic while they were randomly copy-pasting code with no grasp of the underlying structure and then getting confused why it broke.) It easily created a button, but of course the button doesn't do anything.
So I hunted through a few files, making some educated guesses, and happened across Mansion.tscn (I've only recently dug into files that aren't .gd), which does have the right variable names (callorder, callconfirm). So I copied some code there, changed names to match the other file, and gave it a shot. No dice. Button appears, but does not do anything.
I double-checked that I hadn't misspelled anything, and that all the references match the pattern of the original code ("callorder" becomes "namechange", "callconfirm" becomes "namechangeconfirm"). Nothing looks like it needs a particular uncopyable code (e.g. a unique numerical ID). It appears that having identical names (like "Label") is fine so long as they're under distinct Nodes. I finally got smart enough to open all the files collectively in Notepad++ and search for the variable name, and it appears that these are the only two files that reference it, out of the Scripts folder and the Files folder.
And just to test, I went through the original functions and changed the internal parts (not referencing the variable name) and got a functional change-name button. But changing all the references to "callorder" and "callconfirm" to "blahcallorder" and "blahcallconfirm" breaks the button entirely, so clearly there's something else going on here.
So now I'm stumped.
Here's the original code. To keep the code here shorter, I've omitted the Anchors and Margins, as I can't imagine they're part of the problem here (and I haven't messed with them, just copied them wholesale hoping the button would show up in the same place). Again, all I did was change "callorder" to "namechange" and "callconfirm" to "namechangeconfirm" in copied code in the same file:
Part 1 (in Mansion.tscn): [connection signal="pressed" from="MainScreen/slave_tab/stats/callorder/callconfirm" to="MainScreen/slave_tab/stats" method="_on_callconfirm_pressed"] Part 2 (in Mansion.tscn): [node name="callorder" type="Popup" parent="MainScreen/slave_tab/stats"] size_flags_vertical = 2 [node name="TextureRect" type="TextureRect" parent="MainScreen/slave_tab/stats/callorder"] texture = ExtResource( 44 ) expand = true [node name="Label" type="Label" parent="MainScreen/slave_tab/stats/callorder"] size_flags_horizontal = 2 size_flags_vertical = 0 text = "How should $name address you?" align = 1 [node name="callconfirm" type="Button" parent="MainScreen/slave_tab/stats/callorder"] size_flags_horizontal = 2 size_flags_vertical = 2 text = "Confirm" [node name="LineEdit" type="LineEdit" parent="MainScreen/slave_tab/stats/callorder"] size_flags_horizontal = 2 size_flags_vertical = 2 caret_blink = true Part 3 (in StatsTab.gd): func callorder(): get_node("callorder").popup() ## Improved phrasing get_node("callorder/Label").set_text(person.dictionary("How should $name address you?")) get_node("callorder/LineEdit").set_text(person.masternoun) get_node("callorder/LineEdit").set_placeholder(person.getMasterNoun()) func _on_callconfirm_pressed(): get_node("callorder").visible = false var text = "" ## Improved phrasing plus support for characters who don't speak with their mouths if !person.traits.has("Mute"): text = "You have ordered $name to call you '$master' from now on. " else: text = "Since $name cannot speak, you teach $him a way to sign '$master'." person.masternoun = get_node("callorder/LineEdit").get_text() get_tree().get_current_scene().close_dialogue() get_tree().get_current_scene().popup(person.dictionary(text)) Part 4 (in StatsTab.gd): buttons.append({text = person.dictionary("Order to call you ..."), function = 'callorder'}) SAMPLES OF MY VERSION: ## Testing to see if I can add a button buttons.append({text = person.dictionary("Change Name"), function = 'namechange'}) #That part worked fine, but the rest doesn't: [node name="namechange" type="Popup" parent="MainScreen/slave_tab/stats"] [connection signal="pressed" from="MainScreen/slave_tab/stats/namechange/namechangeconfirm" to="MainScreen/slave_tab/stats" method="_on_namechangeconfirm_pressed"] func _on_namechangeconfirm_pressed():
Note: I'm not adding interior line breaks or tabs in the actual code unless they're there in the code I'm working from. The copy is identical except for the variable name changes, the obvious strings (like "Order to call you..." to "Change Name", which works fine), and a bit of If/Else code (which I'm not having any trouble with elsewhere and doesn't seem to be related to the problem).
Any clue what I'm missing?