THE NEW Miscellaneous Talk That Doesn't Deserve A New Thread Thread Thread (Part 2)

If statements are practically necessary to make a game if you have a value that should control a statement, I just used one in a sentence.
Else statements are more niche, but do have their uses when you’re sure your logic needs to be the exact opposite of your if statement, which can include another if statement.
The problem with YandereDevs if/else statements is that he was using it to check many conditions at once, of conditions that should not be dependant on one another;
I.E. If (age > 15){foo(age);}else if (age > 18){bar(age);}else if (age < 40){ETC} else {ETC},
These should not be checked dependantly on eachother because it can make extremely difficult to follow what age does what, since you have to read every if statement to understand what range of values you’re actaully checking.

2 Likes

No. Only some people who are really opinionated might say that else is bad. But “if-else” structures are really a core part of imperative programming.

Not knowing switch statements, it is a bad thing. Long chains of if-else are hard to understand, and as such are considered bad style. Instead switch statements should be used.

I think you’ve missed some important parts of the discussion around that. I’ve seen a video where someone recompiles the YandereSim game in Unity and runs it, and basically gets vastly improved framerate by cutting down on the useless checking of “is it time to do x in my schedule yet” all the objects constantly do.

Unless you take part in a challenge to specifically avoid if statements, you will use them in a game. There’s no good reason not to. This whole question is something only a beginner without any programming experience would ask.

This would be fine, and actually understandable if the values are written in a certain order like, is the age over 25, is the age over 15, is the age over 10, else do something different. Many programming languages don’t support switch cases to be value ranges. For those you literally just have to do such a chain of conditions. The only option would be to do an early return, but that isn’t better in all cases (and of course there are again people who are really against early returns, I’m personally in favour of them in many cases).

If you actually need to do different actions on different value ranges, you just have two options: put the checks in the most understandable order (like I mentioned above), or redesign the game to not have that kind of value range based conditions.


Coming back to that performance problem, what YandereDev should have done is some kind of event pattern where either the game entities are given the game time like once every few seconds (whenever the simulated in game time changes), or a more complex system where game entities register to listen to specific events like “previous class ended” and only then reacting to that.

If you have just one thing checking a list of 50 items to see if it is time to execute any of the actions yet for each frame of the game, that’s not too bad. But then when you need to duplicate that object 50 to 100 times. Suddenly you have an exponential growth of the needed code that has to run each frame.


I’m not sure why I bothered to write this long of a post, as only people who have grasped programming at least at a beginner level will be able to fully appreciate…

So he’s using if/else statements wrong and the gremlins know jack squat about programming?
I guess i can have my code cake and eat it too, huh…

A post was merged into an existing topic: Happy Birthday / Anniversary Thread

What is the origin of Thrivecoin/Thrivium?

It was an April fools joke

1 Like

Why did it age so badly?

it didn’t, it’s a meme about EA, a funny one at that.

1 Like

Hey, anyone here have chesscraft? If so, anyone want to play?

I can get it if you want.
Edit: i cant get past the starter levels please help
Edit: i got past the Peasant’s intro map without failing
Edit: i cant get past the wizard’s intro map! Please help!

@Lipovomit, if you want to start to learn how to code, I suggest you should learn Python or C# first.

Here’s a good tutorial for each:

You can also look for tutorials on YouTube if that helps.

So I’ve been looking at the statistics of every user, and I’ve been wondering this. How exactly does read time work? Certain users have a particularly large amount of posts read, but their total read time (in terms of days) amounts to far less than other users despite them having read less posts according to the stats. Does Discourse know when a user is skimming a thread versus when a user is sinking more time into reading each individual post?

I’m pretty sure the forums does actually know how long you have a thread open in a tab. There’s hopefully an upper limit without user interaction as I usually leave tabs open if there’s a post I want to reply to.

1 Like

If I try to put a ! before a link, the link breaks link

What do you mean? Raw links in markdown are converted to clickable links automatically. For more control you can use the actual markdown link syntax [text](https://link_goes_here), images can be embedded by putting a ! in front of a link like: ![image description](https://link_to_image.png).

1 Like

Just noticed that I have more read time than you.

At least im still the king of read time

2 Likes

Will TeaKing be the first to Ascend? Find out next time on…
THRIVE COMMUNITY FORUMS! DUN DUN DUNNN

As of now, TeaKing is currently in third place in terms of post creation (outranked by blackjacksike and hhyyrylainen, who have 3.2k and 4.2k posts created respectively.) So it seems that our friendly server admin is the closest to reaching the Ascension gate.

I’m the 5th closest to reaching ascension