


"A reshing beverage" if money.level >= 1: Let’s say we want to show different dialog choices base on a certain resource i.e. Thank’s to RenPy’s fantastic support for conditional statements, this turns out to be pretty trivial. Our S&I system is all setup and ready to go. Or inline using RenPy’s $ syntax for single line Python: $love = resource(0) Inside a Python control block (recommended for stats): label start: When we put it all together, we can now declare new resources in two different ways. Where amount will default to 1 if we do not provide one. In this case, I never wanted to increase or decrease by more than one, but if you wanted to, say if the character has a job and has just earned $100 you could use something like this: def inc(self,amount=1): This function is used to increase our resource. We put a simple check in the function to make sure that resource values do not go into the negative. This function handles decreasing our resources. We can create a new resource “love” later on using the following code: love = resource(0) In this case, that means how we create new resources for our Player Character. This is a special Python method that handles how the class is instantiated. In this case we defined three methods for resources. A resource is simply anything that we need to track if the character has it (or not) and how much they have.įor convenience, we create a resource class that is going to handle how accruable resources behave. 18 HP, 32 Heart, or even a single use item i.e. I use the concept of a resource in this example which could be currency i.e. The init python: block tells RenPy that the following lines will be python code. If self.level > 0: self.level = self.level - 1ĭef inc(self): self.level = self.level + 1 Init python:#declare a python black so we can write python codeĬlass resource:#this is a convenience class for handling resources Here’s an example from the sample RenPy game found here: # The script of the game goes in this file.
#Slime key a wizards lizard code#
The easiest way to implement S&I (Stats and Inventory) is to simply declare a Python code block at the top of your scritp.rpy file.
#Slime key a wizards lizard how to#
If you’re reading this article, you’re interested in the fastest, most efficient way to set up stats and/or inventory management in RenPy and how to use stats/inventory to impact the player’s experience and dialog options. Recursive menus that continue until all options are exhausted.The other articles are listed below, links will be added as the articles come out. We’ll show you how to implement a simple inventory system and build an intelligent menu for a shop/vending machine that reacts and responds appropriately to player inventory and stats. This is part 1 of a 4 article series on some useful techniques for making a RenPy game.
