So simple question i have two structs that have values that need added together. is there a cleaner way to do it? or am i just going to have some line spaghetti?
Here is a picture of what I have planned. breaking open the structs and then adding the floats together before setting them by ref.
As you can see these is quite a bit going on here. This is for the equipment of my game and equipment can affect many different aspects of the character. So if anyone has a suggestion on how to add stucts together more efficiently OR maybe a better idea for the system im all ears thank you.
Hey @AndracoDragons!
So what I’d do is have a few structs governing a few things, like:
Player Stats
Equipment Stats
Final Stats
Or even better, trade them out for MAP variables with String:Float setup so you can always just pick out the one you need and easily alter it.
Then when anything CHANGES, it runs through everything and does all of the math over again, yes. Because if there is anything computers are good at, it’s truthfully math. It’s really hard to make a computer slow down from math vs something like rendering.
Instead of a huge amount of lines like this, though, you can break it up into functions for reusable code!
Anything you find yourself doing more than once can be turned into a function to save time, that would definitely be the plan here. Not to mention you can nest the functions for cleanliness’s sake!
Hope that helps! Let me know if you need more- but also if you post more pics please have your lines not overlapping like that… It’s impossible to make sure things are hooked up correctly. 
1 Like
Thats exactly what im doing actually.
There is just alot of stats to possibly modify when equipment is put on. but its good to know i am already on the right track i appreciate it.
Just to let you know though, I’m noticing you’re not using “Set Members Of Struct”. You can use that to set an individual value instead of having to set the entire struct over again- because if even one value is left out when using “Set”, that value gets set to default! So keep that in mind!
To reiterate, though, you may have a better time with a struct of Maps instead of a struct of structs. They’re way more usable for this due to functions like “Find”, “Contains” etc where structs have no extra functionality, they are unsearchable containers.
1 Like
i didnt see the MAP suggestion at first i must of glazed over it, but youre right it would simplify things very much so. thank you i dont know why i didnt think to use them, i use maps everywhere else with the damage system.