Ren'Py Tutorial: Simple Inventory
Hello friends! In this tutorial, I'm going to show you how to make an easy inventory system for Ren'Py 8.1.3.
This inventory system will allow you to:
Create an icon, like a purse, to open and close the inventory.
Add inventory items, like coins, to the inventory.
Click on the inventory item to see a bigger version of the item.
Click on the item again to close the bigger version.
Let's get started!
Images Needed (save these in the "images" folder of your game):
inv_icon_closed.png - Inventory icon when closed
inv__icon_open.png - Inventory icon when open
inv_item1.png - Inventory item
inv_item2.png - Add inventory items as needed
inv_item1_big.png - A bigger version of inventory item 1
inv_item2_big.png - Add bigger versions as needed
inv_background.png - Inventory bar background
inv_overlay.png - Prevents the screen from being clickable while larger item is displayed (so the story does not continue)
Copy & paste into your script.rpy file:
# Add an init block to set up the initial state of the inventory
init:
$ hovered_item = None # Nothing is hovered on
$ inventory_open = False # The inventory is closed
$ inventory = [] # The inventory is empty
# Controls what happens when you click on the inventory icon and when the icon is clicked, what appears (First Click: inventory bar, overlay, and items if there are any; Second Click: closes inventory)
label click_inv_icon:
if not inventory_open:
show screen inventory_overlay
show screen inventory_bar
show screen inventory_items
$ inventory_open = True
$ renpy.pause(hard=True)
else:
hide screen inventory_overlay
hide screen inventory_bar
hide screen inventory_items
$ inventory_open = False
$ renpy.pause(hard=False)
# Start label to start the game
label start:
show screen inv_icon # Shows the inventory icon
"This is a game." # Dialogue
"With an inventory."
"Here, have an item."
$ inventory.append({
"name": "item1",
"image": "inv_item1.png",
"display_image": "inv_item1_big.png",
"description": "Description of item."
}) # Adds the item to inventory within the game flow. You will have to copy this code and change the item information every time an item is acquired for the inventory.
"Thanks."
Copy & paste into your screens.rpy file:
# Define the screen for displaying the larger image
screen large_item_display():
zorder 15 # Set a higher zorder to ensure it's above other screens
hbox:
xalign 0.5
yalign 0.5
if hovered_item is not None:
vbox:
add hovered_item["display_image"] xalign 0.5 yalign 0.5
text hovered_item["description"] # Display the description
# Define the screen for the inventory overlay
screen inventory_overlay():
zorder 4
modal True
add "inv_overlay.png" # Adjust the image and size as needed
# Define the screen for the inventory bar that displays when the inventory is open
screen inventory_bar():
zorder 5
hbox:
spacing 10
xalign 0.0 # Adjust the X-alignment as needed
yalign 0.0 # Adjust the Y-alignment as needed
add "inv_background.png" size (1280, 100)
# Define the screen for the inventory items
screen inventory_items():
zorder 10 # Set a higher zorder to ensure it's above other screens
vbox:
xpos 100 ypos 10
for item in inventory:
imagebutton:
idle item["image"]
action If(hovered_item != item, [SetVariable("hovered_item", item), Show("large_item_display")],
[Hide("large_item_display"), SetVariable("hovered_item", None)])
text item["name"]
# Define the screen for the inventory icon
screen inv_icon():
zorder 7
hbox:
xalign 0.0 # Adjust the X-alignment as needed
yalign 0.0 # Adjust the Y-alignment as needed
imagebutton idle "inv_icon_closed.png" hover "inv_icon_open.png" action Call("click_inv_icon")
And there you go! This is a simple and customizable way to create an inventory for your Ren'Py game!
Drop a note if you run into any problems. :)
11 notes
·
View notes
It was late. It was very late.
[Name Redacted] was snoring loudly on the bed. He hadn’t forced her to come out from under it. She was afraid. As he’d been falling asleep, his breath was interspersed with chuckles, if that was the right word for something that sounded so sinister.
Last night- earlier that night, she supposed- had been close. Too close. She was stupid for trying to contact them. She should have known better than to listen when he read what they said out loud.
What they said had made her feel safer. Less alone. Of course it had. And she let her guard down.
When Xigbar- he didn’t read the url but she knew- pointed out the mousepad, she’d laughed.
Of course she did.
That had been a mistake. As soon as it was out, she’d ducked for cover. He hesitated in retrieving her (which was odd) and then when he did eventually grab her, he stopped before really hurting her. She was unharmed, minus some pulled hairs. Which was stranger.
And then he chuckled.
Peeking out from under the bed, she saw a sliver of light coming from… the door? Did he leave the door open?
There must be. There must be. Flour on the floor. So he could see if she. Or some other thing. It had to be a trap.
She stared at the light.
What choice did she have?
[Name Redacted] was sleeping on the right side of the bed, which was odd. So much was odd. It left her a clear path to just go.
This was a trap.
But what choice did she have?
Maybe. Maybe Xigbar had threatened him. With his true name. To let her go. That sounded. That sounded possible. Maybe this wasn’t a trap. He’d said he was coming. He’d said he cared about her (“cannonball”).
She crept out from under the bed.
Stranger and stranger. Her phone was on the left bedside table. Where she could reach. Where she could reach and [name redacted] couldn’t.
And her bag. Not hidden. The sash, in plain sight.
He must have done something. What, she didn’t know. She thought about it as she silently collected her items and tiptoed (not that she should do anything else) towards the door.
Yes. He must have. He must have. Well, she wasn’t sure what he must have done. But something. He’d done something to help her.
It was more than she’d ever gotten before. Outside help was not something she was used to.
An apartment door with her name on it, down the hall. Key in the lock.
She carefully scraped the letters off of the door and wrapped them in the sash. They’d said “Showrunner”, not [OMITTED LAYER 2] or even [LAYER 1], which she appreciated. But there was no use in letting [name redacted] know where she was if he didn’t plan this. If it really was just an escape.
She entered the apartment, firmly locking the door behind her and then pushing a nightstand up against it. She was alone. She was safe.
She pulled the curtains on the window tightly closed and then got out of that gods-forsaken wedding dress. As if she would ever wear something like that willingly.
Curling up in the blankets (on the left side of the bed), she pulled out her phone and- damn, right, the fucking-
Getting out of bed and pulling out the potato battery she’d hidden in her makeup wipes, she sat back on the bed and pulled the blanket over her like a cloak.
She clumsily opened tumblr (for some reason it was easier than using the built-in texting- too many buttons for her to accidentally misclick- and navigated to- ugh. There were the posts he’d made. She couldn’t scroll well enough to delete them. Maybe she’d ask Xigbar to report them for community guidelines violations. Surely they qualified. Even under the new rules.
But if they were reported- ah, better safe than sorry. She’d make a new blog. That one (however much she was fond of that url) was tainted, anyway.
It took her about 30 minutes, but she managed to make a new account- @shshshshshowrunner , and then did some privacy work before navigating to Xigbar’s ask box (and following, of course), and typing the following:
“Xbbar dod ypo dp sonetbing?? Om ob a dpfferwbt apaprntnent amd om sake fpr no pw. Male a nrw blos. Amsnwe tbos adle provahgeky pleas. Amd report all pf hos posts pm mu pld be lood. Bock jom please. Om not bsdly knhiroed. Pbly mt war. Amd mu hapr. Ir cpmmwnt anput thw mpthspad wzd dfimmy byq.
Spull camt scrppl
-jdodkoe”
Looking back on it, even she wasn’t quite sure what it said. But he would know. He always seemed to know.
Sure enough, less than two minutes later, she got her reply:
“I promised I'd get you out of there doll
He's not gonna hurt you anymore. I got him to back off. Permanently.
Ill report it all. Especially the stuff you're in dont worry
Glad you think im funny tho lmao”
She smiled. He got her out of there.
Of course he did.
A pause.
She could probably even venture to,,,
She clumsily clicked on the texted reply. It brought up “Unsaved Number” (yyy-yyy-yyyy). And next to that… the call icon…
Feeling brave, she clicked it. And then tried again, because she missed. It took above seven tries but then she heard it ring.
She held it up to her ear, crossing her fingers-
"Hey, doll."
She let the breath she’d been holding out, “Hey!” She let out a relieved laugh, “Hey.”
"Good to know he actually listened to me." His voice had a tinge of relief to it. "Promised I'd get you out."
Her smile fell like a ton of bricks, “L- listened to you? You mean, when you… threatened him?”
"I let him know exactly what would happen if he didn't let you go. Still planning on killing him eventually, but he doesn't have to know that."
“It’s a good thing you didn’t get the chance- our life forces are tied. Something this tournament runner is doing. I think it’s cruel.”
"... Shit, yeah, it is a good thing. Honestly, I don't know if I would've been able to stop myself from just taking him out the second I saw the bastard."
He paused.
"It's not just cruel, it's weird. I guess insurance to keep the couples from killing each other?"
“Maybe,” She said, cringing at the word ‘couples’. She paused, and there was a moment of silence.
“Look,” She said, “I don’t- I don’t- it’s not your fault. That I- that he- that i-” she couldn’t quite get the words out. Her brain felt like cotton. Tired, probably. The last time she’d fallen asleep had been in her apartment in the arena, “I- because you texted me, or taunted him, or because I laughed at the- the mousepad, I don’t want- it’s not-”
The words died in her brainfog.
“I’d have rathered you text me and I get hurt than you not text me and I don’t. If that makes sense.” She sounded like it didn’t, to her.
"... I missed you, too."
She inhaled sharply. And didn’t answer. For a while. Thinking.
“You know,” She said at length, “I think that’s the first time I’ve ever heard that.”
"Hopefully I won't have to say it too much," His voice sounded playful. "Any more rescues like this, and I might have to start charging you."
The smile that had died at the beginning of the conversation returned, “What, is this too difficult for you? Sounds like a skill issue to me.”
"As if. This is just sooooo much time, and energy, and having to talk to people that drive me insane, …" He trailed off, mumbling something under his breath.
She checked the charge on her phone- 70%- and then set the potato battery aside and layed down in bed, a wave of exhaustion washing over her. She didn’t need to sleep as much as other people did, but she did still need it. Same with food, which- the thought back- gods, had the last thing she’d had to drink been swamp sauce? Embarrassing. If asked, she’d lie and say it had been something with more flavor.
“Insane, yeah?” She said with a yawn, not really expecting an answer. Just wanting to keep him talking.
"You had me talking to Sora. I swear if I hear that kid start talking about friendship one more time…"
She faintly frowned in confusion, “You were making fun of [name redacted] with Stanley and talking to Sora? At the same time?”
"No, I talked to him earlier. That's what you were saying with the emojis, right?"
She couldn’t help it. She laughed.
“Right?”
She laughed, not feeling the dread she had felt the last time the sound had escaped her lips. Struggling to speak, she said, “Darling, no, I was making fun of him. Clown shoes,” She giggled, “But I appreciate it.”
She got herself under control, “I really do. You anticipated me. The second reference- the clown shoes picture I had him send- that was ‘Talk to Sora’. You were ahead of the game,” She smiled, “I figured- well I don’t know much about keyblades, but they’re magic, right? And they’re keys? He was keeping the apartment door locked, I was hoping maybe he could use it to let me out. Is that something he could do? Do keyblade do that? What even is a keyblade? Where are you from? I’ve never seen a demigod that could teleport before.”
"Demigod? I'm not- What are you talking about?" He paused again. "I can't tell you all that. Not yet. But I can tell you that the keyblade would've been able to open the door, yeah. … You know I have one too, though, right? I could've just done that myself."
Another pause.
"'Darling', huh?" She could hear the shit eating grin in his voice. "Keep callin' me that and I might just let this slide."
“How was I supposed to know you have a keyblade? You never use it,” She said, remembering returning his arrowguns (and then her pointing one of those guns at him because she thought he was [name redacted] [what she wouldn’t do for an arrowgun]), “And you only mentioned it in relation to Sora- if you have a keyblade, why did you need me to return the-?”
"Honestly? Arrowguns are more fun for me. … Also I don't need the Master's disembodied eye watching my every move, but… that's a story for another time."
“Master?” She asked, instantly worried, “Like-” She paused in confusion. She was too tired and hungry for this, “Is this someone you need taken care of? The kins, they could-”
"Relax. It's not like that. It's mostly classified information, but the most I can say is he's kind of my teacher. Or at least, he was. For now it's a sort of gray area."
“I know about gray areas,” She muttered, rubbing the bruise on her shoulder, “How- if- Sora has one, is the Master watching him? Or?”
"No, he can only see through the keyblades with his eyeball implanted in them. It's gross. I've always thought it was gross. I don't want to carry around someone else's eyeball."
She idly thought of his eyepatch, and the scar. She was silent for a while. She could hear the faint sound of his breathing through the other end of the line.
“As long as you’re safe,” she yawned again, “Anyway-” She frowned, trying to think back- “Oh, right,” She said tiredly, “Demigod. You’re a Janus kid, right? You have-” (yawn) “-you have that vibe.”
"I have no idea what you're talking about, doll. Maybe you should get some sleep."
“Oh come on,” She muttered, “You’re all about doors, and- and-” she yawned “And you can go through them. ”
"That is how doors work, yeah."
She giggled, “I can’t explain it right now… you know Percy and water?”
"... No? Did you take the swamp sauce with you or something-"
“You don’t know about Water Boy? Mr. Hurricane? Blew up Mt. St. Helens? Mr. Turned down Immortality? Mr. Walked Through Hell?”
A pause.
“Why did you think I needed Annabeth as leverage? I couldn’t handle Percy on my own,” She yawned, “He could beat me even with the force field nerf.”
A pause.
“He’s a son of Poseidon? Water go brr?”
"... I'm starting to think I should've taken his threats more seriously."
She let out a laugh, “No, no, it’s all part of the bluff. Act more powerful than you are and he’ll believe it,” she smiled, “That’s what i’m doing with the- with the theatrics! The forcefield, the army, the- the you- you know, my mother, Aphrodite-”
“What?”
A pause, “Xigbar, I thought you looked up my name.”
"I looked up his. Found yours by mistake. … That reminds me, I said the next time we talked I'd tell you something. My name – it's Braig."
“Braig,” She said, trying out the way it sounded, really stretching it out, “Braig. [OMITTED LAYER 2]. Braig. Are you scottish?”
"Italian, I think."
“Hm,” She said, and then repeated quietly, “Braig.”
A pause.
“Wait.”
A pause.
“Hold on.”
She was holding back a laugh now.
“Wait wait wait. Did you rearrange your name and then stick an ‘X’ in there? For what, fun? Spice?”
"As if. I didn't have anything to do with that development. Something my old boss did. Stupid loyalty thing. It really just gave him a way to track everyone. … Don't worry, he's been dead a while now."
A pause.
“What name should I use? For you?”
"I don't mind either. Just- Keep to Xigbar around the others."
“Okay. Okay.”
Pause.
“Braig, were you in a cult?”
"Pretty much. That's where I got the coat- Everyone wore one. I was there for like, 12 years."
She was silent for a moment.
“12 years is a long time.”
"I guess when you're thinking about it in the present. In the grand scheme of things, it's not that long. Been alive way longer."
“Got a number?”
"Lost track after a few hundred years. I don't know. Maybe around 2,000 ish? If I had to ballpark it? Old enough."
“Brave of you to keep track that long,” Her smile turned into a yawn, “I lost track after, what, 50? Add 20 to that, then add the rise and fall of Rome, then the dark ages, and then that thing with the- with the boats? When they found the- the “new world”- not new, but you get it. Then tack on, what, 600? I don’t know why i’m trying to do math. I’m like 2,000, too. Ish.”
"... You aged a lot better than I did."
She let out another laugh, “You try being carved by someone who doesn’t want you to age,” Then realizing that got dark, she pivoted, “I think you look good.”
"You do, huh?" He chuckled a bit. "Good to know, doll."
“What were we talking about? Before age? Oh, demigods. My mother- ‘’’’’’’’mother’’’’’’’’,” She said, and you could hear every quote, “She didn’t even give me any powers? Rude, right?”
"I know what you mean. I had to get what I do on my own."
She yawned, “I mean- like- you know how I just described Percy? Motherfuck he got powers. Like the only thing he can’t do is, like, keep his footing? Fuck’s up with that? I don’t even have charmspeak. Charmspeak. Even Percy thinks I should have charmspeak, he accused me of using it on Stanley.”
"I don't know what charmspeak is."
“Imagine, if, like, you wanted some kind of thing, yeah? And you went up, and you said ‘Hey, you want to give me that so bad you look stupid’, and it, like, worked? But then it wore off. I don’t even have charmspeak. Do you know how easily i could have gotten away from [name redacted] if I had charmspeak? ‘Hey, kill yourself’ and boom! I’m free. But nooo, little [LAYER2] was made to be one thing and one thing only, a [censored], and let me tell you, when he started getting old- like not you old, you’re fine, and you will continue to be fine, but- he sent you a picture, yeah? He aged backwards since i last saw him, last i saw him he was, like, fuck, 90? And he was all like grab grab and i was like ‘kill yourself’ but I Don’t Have Charmspeak! It’s not that hard! Just- I mean, she brought me to life, i was a statue, she can bestow that miracle and- fuck, i don’t know, whatever else, but I don’t get the power of Extra Pretty Please?”
A pause.
“You know what? Now that i’m thinking about it, I think I only said yes to Stanley and Cesare asking please because I’m salty. Team ‘They Said Please’ what about I Say Please? Do I Not Get To Say Please? If I can’t give them charmspeak the least I can do is say yes when they ask not to die,” She rolled her eyes, “even, like, Annabeth- Athena doesn’t give her kids, like, powers powers, but Annabeth can still, like, weave really good and survive trudging through Tartarus. I’m over here, fuckin, I don’t know, Pleaseless. Fuck.”
She stretched out on the bed with a yawn, “Is that too much to ask?”
"... It worked on me."
“Hey, now, don’t say that. No magic involved, I don’t have it. Fucks that quote?- ‘Yet, by your gracious patience, I will a round unvarnished tale deliver- of my whole course of love: what drugs? What charms? What conjuration? And what mighty magic? For such proceeding I am charged withal- I won his- fuck, Xigbar, I guess. Hey, that even fits with the meter. Anyway don’t worry I didn’t use the magic I don’t have on you, alright?”
"That's not what I meant, doll."
Her brain felt like cotton, and she frowned, “...fuck were we talking about?”
"Go to sleep already," he laughed. "You sound half dead."
“If you- don’t you dare hang up the phone or i’ll say please myself out of the window,” She yawned. And paused. “Stay on the line with me? And then maybe if he comes in, if you hear him, you can yell in my ear real loud and I can fight him off? Or we could just hang out. On the phone i mean. Not me and [nickname redacted], obviously, that’s so dumb-”
Xigbar laughed, “[nickname redacted]? Like the animal?”
“He is one!” She said, “He is one. You should hear him when he-” A pause “-nevermind. Stay on the line? You can go to bed, too, just keep the call open? Please?”
"Okay, doll. Promise."
“Okay. Okay,” She was surprised at how calm she was. Not 30 minutes ago she was cowering for her life. “Okay,” She yawned, “Okay.”
“Having fun with that word?”
“Silence, goon.”
He laughed, and she stretched out to go to sleep.
Safe. She was safe.
11 notes
·
View notes