Maybe just detach the Strawberry script entirely or comment it out? The ate_food thing only appears in 3 places from your search.
I duplicated the project and I’m removing all the unnecessary things currently.
Anytime I remove the Strawberry script the error goes away completely so it’s 100% something wrong with the Strawberry script - I’m not the best at signals so I know something is screwed up in there but no clue how to fix it. Might just rewrite the script from scratch.
Edit: or it has something to do with when the Strawberry is loading in and how it’s interacting with the signals on load in
Can you post the current Strawberry script again? The latest version that still gives the red error.
Yes, here it is:
class_name Strawberry extends Area2D
@export var type := "Berry"
var food_amount := 20 #how much food it gives
var animal_in_area := false #so you can't eat across the map / from anywhere
#var eatable = false
func _ready() -> void:
print("strawberry loaded.")
Messenger.ate_food.connect(_on_ate_food)
func _process(_delta: float) -> void:
#print(signal_check)
if animal_in_area == false:
return
elif animal_in_area == true:
pass
if Input.is_action_just_pressed("interact"):
_on_ate_food()
#if Messenger.has_signal("ate_food"):
#eaten()
#print("signal readY")
##Messenger.connect("ate_food(20)")
#Messenger.ate_food.emit(food_amount)
else:
return
func _on_area_entered(_area: Area2D) -> void:
animal_in_area = true
print("animal in area!")
#if eaten = stop existing
#have a game manager create more?
func _on_area_exited(_area: Area2D) -> void:
animal_in_area = true
print("animal left")
func _on_ate_food() -> void: #tell whoever ate me that they did and then disappear
print("eaten")
queue_free()
#
##func signal_checker():
##if Messenger.player_interaction.connect(eaten):
##signal_check = true
##else:
##signal_check = false
if memory serves, didn’t Messenger’s signal ate_food have one argument?
Yes it does
signal ate_food(amount:int)
try adding an argument to the function on ate food (food: int)…….. Edit: I meant currently there seems to be a mismatch between the number of arguments. I doubt it is the thing causing the error message that says there’s no signal ate_food, but worth trying.
I did try it, and I do think I need to adjust that for when this finally works haha but it still threw the error sadly.
Good news is is that the duplicated project does not have the error. I deleted a lot of stuff from it though but it works WITH the strawberry scene in the testmap so I don’t know how I did that but tomorrow I’m going to dissect it to figure out what went wrong. I am spent from trying to figure this stupid error out.
Hilarious finding though: I copy pasted both strawberry codes into a text comparison website (just in case I touched one) but they are the exact same on both projects.
I for sure thought the error would lie with the code in there ugh
Well at least it worked! Good luck!
I’m still suspecting some .tscn file. In Project Settings, you can look for “Search in File Extensions” and add “tscn” to it. Then Ctrl + Shift + F can be used to search in .tscn files as well.
I think it is this tbh, I deleted quite a few .tscn’s in the duplicated project haha I will lyk tomorrow
Okay so I wish I had a great answer as to what fixed the issue, I’m just going to mark deleting the .tscn files as the solution: but truth be told I don’t really know? The projects were completely identical in every way (at least when I combed through each script on both projects and each scene) and one was still screwing up while the other was fine.
I ended up copy pasting over the files from the fixed one to my original (to replace them in case I missed a single capitalization or misspelled something) and a bunch of my files got upset at that so I had to delete my globals and re-establish them as well as my ‘main scene’ and then it worked. Don’t really know why or how but it’s done so eh!
Thank you all for trying to help me troubleshoot for as many hours as you guys did - it means a lot.
You might want to reconsider the file organization. Right now you’re organizing the files by type if I’m reading it right. For a project of your size, it’s usually better to organize by systems. Once the project expands, having all the files logically grouped by systems will make it easier to find things. Even in the prototyping phase, I think this is worth considering.
For your bug, it could be also some weird uid issue. If i remember right, you can close godot, then delete the .godot (dot godot) folder. Then when you open the project again, it will ‘reconstruct’ the connections when you open godot again, but backup before you do.
This is a bit of a desperate move but it sometimes work. When you recreate the things, most likely the .godot had to be redone and maybe it fixed the connections.
Okay thank you, good idea. For the file organization by system, do you mean not just grouping things by assets, resources, scripts, ect but instead having like a folder for the player that contains all their scripts/scenes/ect?
I like to group by category, and then systems, minus the player assets, they get they’re own folder
Yes. Usually for smaller projects, you can go by type and it’s ok. But large projects often is easier to be by system first. You go system to subsystem to subsystem to type. For the libraries, you can go system to subsystem to type. For example, lets say you have your interactables. You can put them in folder ‘interactable’, then everything inside are things to do with interactables, their scripts and sprites etc. You can then have lets say subfolder ‘fruits’ like your strawberry.
Then inside you have your icons in one file, then scripts in another once you have a lot of fruit entries. It’s closer together in the file dock. Eventually you can even have libraries that comb through the whole folder to autogenerate things. And even if you don’t, just having tres files with their scripts right next to each other is easy. Lets say while you are fiddling around with your strawberry.tres and you thought of changing strawberry.gd or fruit.gd, it’s right next to you. Or if you thought of maybe adding an icon, it’s also right in the fruit subsystem. For data heavy and systems heavy project, I find it also sort of promote decoupling indirectly.
It’s just a suggestion for larger projects. In practice you just mix and match until you find the style that fits.