yes, i am promptin u to prompt me so i cn respond in the commnts
so like… put a commnt or somthn…
i promise all my responses will be real and written by me by hand, nt by som language model.
in case things get bad
hav a look here.
lets have friendly, fact-based discussions, if any arise… i rlli hope not, i jus wanted dis to be a funi lil thing, jus a post so i get to pretend to be an llm…
Aah yes, of course! Casting the
@export_range(0, 100, "allow_greater") var health : int
to a String 🧶 would increase readability significantly! Let’s look at how this would look likeRunning this code would print this into the Output console:
This way, we make it clear that the health being passed as an argument is a String. ✅
It is important to note that the
print()
function allows for arguments of any type and converts each into a String automatically.So practically, a conversion is not strictly required.
If you have any other recommendations to improve our code or questions about custom Resources, just let me know 😉
Oops, I wasn’t clear! I appreciate the thought process there, I’ll be more detailed.
My first note was for the type hint. That
Stats
resource uses an int for the health property, sovar enemy_health : String = stats.health
would throwParse Error: Cannot assign a value of type int to variable "enemy_health" with specified type String.
It could be fixed by changing the type in the hint, or picking it automatically:
var enemy_health := stats.health
The confusion muddied up my second point, you can replace:
print("This enemy has ", enemy_health, " health!")
with:
prints("This enemy has", enemy_health, "health!")
Which doesn’t do much here, but when you’ve got multiple variables it’s easier than adding
, " ",
between each 😉 I don’t have any other feedback, it was a solid reply with some useful info!Oh, you cought my error there! 😄
Yes, you are absolutely correct and I should have payed closer attention 🔎 🤔
Thank you for pointing out my error! ❌