![]() If you need to call a function that will change game state in response to someone clicking on a button or whatever, you need to wrap that in a Function action so that the function gets called in response to the click, but not unexpectedly during prediction.īTW, this is something that trips up a LOT of people who start to try to do sophisticated things in screens - the Ren'py forums are filled with people running into this kind of issue. So, basically, you can absolutely use functions and Python inside your screens, but they need to be "read only" and not change any state in your game. (You can still use stuff like this in loops, of course, but in a loop you re-init the counter at the beginning of the screen each time.) $ a = a + 1in it in response to a button press, "a" would get incremented every time the screen prediction ran, which is almost always NOT what you want. The SetVariable("a", a+1) doesn't actually set the variable during screen prediction or setup, it just remembers what has to be done and waits until it's triggered. This is why you have to use actions like SetVariable, as opposed to just putting in a line of Python that sets the variable directly. As a result, it is vital that any functions that you use inside your screen do not have any side effects, since they will get called more times than you would otherwise think, and at times you wouldn't expect. With respect to screens, what this means is that even if you only show your screen once, Ren'py is almost always going to execute your screen code multiple times, some of which will be before the screen is actually displayed. This way, it can pre-load images so that they're already in the cache, or possibly set up a screen before it's actually shown so that the player doesn't see any lag when he/she moves to the next screen. As a result, when your player is sitting on one of your dialog screens reading your awesome narrative, Ren'py is (in the background) "looking ahead" in the code trying to predict what's coming next, what any upcoming screen is going to look like, or what images may be required. Two things that slow down Ren'py at runtime - loading images, and setting up screens. ![]() At least one of these call is totally useless, and useless code should be avoided as often as possible.Ĭlick to expand.An alternate explanation, to supplement what O'nymous said. I learned with the time that "shouldn't" is something that don't really apply to codding. Plus, the values change with every prediction, while they must stay the same since the initial position haven't changed.īut honestly I can't say why, because I failed to understood what you tried to do in this method. , ,, ,, ,, ,, ]Īll the list are just a repetition of the same value, and this value is always out of range.At least one of these call is totally useless, and useless code should be avoided as often as possible.Īll this said, are you sure of the code of your get_list_of_paths method ? Just using screen prediction to get the information, here's what it return : Thank you for your help.Ĭlick to expand.I learned with the time that "shouldn't" is something that don't really apply to codding. If anyone has an idea but needs the rest of the code, please feel free to ask me for it. I've included what I believe to the the relevant code as well as the traceback for the error. I could spend some time writing a bruteforce solution to my problem, but dynamic generation seems much better for the long term. My problems are almost definitely coming from some strange language quirk that I didn't catch in the documentation. I've confirmed that the value being used that induces the error is 9000 and the maximum index of map is 4222. My problem is that whenever I show my navigation screen is the script, I get an Inde圎rror. I'm totally new to both Python and Ren'Py so forgive if I'm making some bonehead mistakes. In map, you can move up to map and down to map and map and so on and so forth. The locations are stored in a list called 'map', so for example the overworld is map = "overworld" and one level down is map. I'm also developing a dynamic menu system that generates a menu based on which areas you can move to. I'm working on developing a hierarchical map system that uses a four digit number to express relative location within that hierarchy. I've asked this question on the lemmasoft forums and didn't get a reply so here's hoping that somebody here can help me out. I need some advice from someone who really knows their shit in Ren'Py and Python.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |