• Hey! Register here to create your account, engage with the community, and talk about what is new!

Is there a "proper" way to organize your codespace?

Do you code it in twice or add a function?

  • Code it twice

  • Function


Results are only viewable after voting.

algebrqic

New member
Joined
Mar 12, 2022
Messages
4
Reaction score
3
I'm new to programming in general, and there are several tedious aspects of coding games, and you can definitely soft code a lot of them, some confuse me. A very simple example of this are games where a player spawns in the same place when they join the plot as when they die. Of course, using a teleport Player Action, it sends them to spawn. The question here is: do you make a function that has the teleport in it, or do you just have the teleport in your code twice? Is it really worth calling the function if its just for a teleport and possibly a setting change or inventory change? Again, this is just an example of different things I'm not sure about in the codespace.
 

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,260
Reaction score
357
Having a lot of functions organizes your code a lot, even if you are coding outside of df!


You can also make your functions better by making them do something general instead of specific, that will both save you space and make your code easier to manage.
 

ARMcPro

Forum adept
Overlord
Joined
Oct 20, 2020
Messages
1,260
Reaction score
357
Is it really worth calling the function if its just for a teleport and possibly a setting change or inventory change
Yeah, because as your game evolves, you will might need to add some stuff on respawn, possibly setting a score or giving invulnerability frames. And you will not lose much code space if you do it as a function.
 
Top Bottom