I'm sure that there's a learning curve to any particular programming language. I wouldn't really know - I'm barely fluent in HTML, and I have a very loose grasp on Python as it is.
That said, I've started to get pretty good with using Ren'Py, and recently came across this little tidbit that makes my life so much easier now that I understand it correctly.
Today, I'm talking about the difference between a jump and a call.
When making any project in Ren'Py, you could theoretically place everything into a single file... but doing so is a nightmare in practice, especially when it comes to finding particular scenes. So you split the script up into different files. Not every Visual Novel (or game in general) needs to have a linear progression, but it's usually nice to allow some amount of player agency, or to offer branching paths. Even if it's just something as simple as letting the player choose which scene plays out next, you need to be able to make that happen in the code somehow.
So, you use the jump command to go over to a label. This is telling the code "look for this thing I defined and run it immediately". Most of the time, this works really well, but then sometimes, you need something just a little bit more complex.
Let's pretend that you're like me, and you want a game with some kind of a day planner. Or has a hub menu that you make choices from. You make selections and scenes play out. But how do you get to return to the hub? Well, you could jump to it, but that's not always the ideal way to go about matters - especially if you've got a previously-running script that needs to keep executing (like a day planner). You need some way to return to where you were when executing your code, and a jump command just won't do.
In these cases, you use the call command instead. One way to think of it is putting a bookmark where you just were, so that at the end of your scene you can use the return command to take you right back to where you came from. You could think of it as inserting a new block - whatever is inside runs, and then returns to the previous block (unless you make a new block inside of that one).
So, what happens if you use the jump command, and then end your scene with return? Well, if you do that, you go back to the main menu. This is not the ideal way of doing things, especially not if there's more game planned after that!
The reason is because, as I mentioned above, using the jump command treats everything as though it were running in the same block of code. If you're in the main block, then when you return, there's nothing left to go back to except the start of the game - meaning your main menu.
In a lot of simpler games, jump is more than enough to get you where you want to go. But if you need something a little more involved, call will become your best friend.
Hopefully this helps someone better understand these tools. It's taken me awhile to get this far, but I've got to say it's really rewarding to finally understand these things.
THANK YOU A LOT!
ReplyDeleteThank you for this post!
ReplyDeleteThanks! I was wondering about this for a bit now...
ReplyDelete