Infinite, Stackable Inventory/Crafting/Vendor - UPDATED v1.5
Forum rules
Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Updated for Ren'py 6.99.10, see first post.
- Donmai
- Eileen-Class Veteran
- Posts: 1963
- Joined: Sun Jun 10, 2012 1:45 am
- Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
- Projects: Slumberland
- Location: Brazil
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Thank you so much, my favourite cactus
.
![Smile :)](./images/smilies/icon_smile.gif)
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)
TOIRE NO HANAKO (A Story About Fear)
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
You're welcome, my favorite Donmai. ![Wink :wink:](./images/smilies/icon_wink.gif)
![Wink :wink:](./images/smilies/icon_wink.gif)
- Heiden
- Regular
- Posts: 140
- Joined: Sat May 11, 2013 3:20 pm
- Completed: Elvine, The Life Threads, Helena's Flowers, Dr. Frank's Build-A-Boyfriend, Beyond the Deep, The Bog's Heart, The Girl With the Gray Hair Awakens, The Far Rings, NB107A
- Projects: The Town Pages, Kill the Prince?! [Nano 2020]
- Tumblr: heidengames
- itch: Heiden
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Thank you so so so much for this!!!!!
I was looking through it, and it seems like I keep running into an error when I try looking at my inventory at the end of the demo.
Specifically I get the error:
I am running Renpy 6.99.10.1227
I was looking through it, and it seems like I keep running into an error when I try looking at my inventory at the end of the demo.
Specifically I get the error:
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 101, in script
$ renpy.pause()
File "game/script.rpy", line 101, in <module>
$ renpy.pause()
Exception: Required parameter first_inventory has no value.
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 101, in script
$ renpy.pause()
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\ast.py", line 806, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\python.py", line 1577, in py_exec_bytecode
exec bytecode in globals, locals
File "game/script.rpy", line 101, in <module>
$ renpy.pause()
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\exports.py", line 1254, in pause
rv = renpy.ui.interact(mouse='pause', type='pause', roll_forward=roll_forward)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\ui.py", line 277, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 2425, in interact
repeat, rv = self.interact_core(preloads=preloads, **kwargs)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 2693, in interact_core
root_widget.visit_all(lambda i : i.per_interact())
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 396, in visit_all
d.visit_all(callback)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 396, in visit_all
d.visit_all(callback)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 396, in visit_all
d.visit_all(callback)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\screen.py", line 386, in visit_all
callback(self)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 2693, in <lambda>
root_widget.visit_all(lambda i : i.per_interact())
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\screen.py", line 396, in per_interact
self.update()
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\screen.py", line 565, in update
self.screen.function(**self.scope)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\ast.py", line 149, in apply_arguments
return parameters.apply(args, kwargs, ignore_errors)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\ast.py", line 118, in apply
raise Exception("Required parameter %s has no value." % name)
Exception: Required parameter first_inventory has no value.
Windows-8-6.2.9200
Ren'Py 6.99.10.1227
Inventory System 1.5
Completed: Elvine (GxB), The Life Threads, Helena's Flowers (GxG)(As Writer, Coder), Dr. Frank's Build-A-Boyfriend (BxB), Beyond the Deep (GxB)(As Artist), The Bog's Heart, The Girl with the Gray Hair Awakens, The Far Rings, NB107A.
All available to play on my itch.io page!
All available to play on my itch.io page!
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Oh, good catch, thank you! I forgot to update the Inventory button.
Line 131 should be:
Line 131 should be:
Code: Select all
textbutton "Inventory" action Show("inventory_screen", first_inventory=jane_inv)
- Heiden
- Regular
- Posts: 140
- Joined: Sat May 11, 2013 3:20 pm
- Completed: Elvine, The Life Threads, Helena's Flowers, Dr. Frank's Build-A-Boyfriend, Beyond the Deep, The Bog's Heart, The Girl With the Gray Hair Awakens, The Far Rings, NB107A
- Projects: The Town Pages, Kill the Prince?! [Nano 2020]
- Tumblr: heidengames
- itch: Heiden
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
It's half working! I'm able to open the inventory, but when I click on Crafting mode, I get-
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 101, in script
$ renpy.pause()
File "game/script.rpy", line 101, in <module>
$ renpy.pause()
File "game/inventory.rpy", line 147, in execute
screen inventory_screen(first_inventory, second_inventory=False, trade_mode=False, bank_mode=False):
File "game/inventory.rpy", line 147, in execute
screen inventory_screen(first_inventory, second_inventory=False, trade_mode=False, bank_mode=False):
File "game/inventory.rpy", line 151, in execute
frame:
File "game/inventory.rpy", line 153, in execute
vbox:
File "game/inventory.rpy", line 154, in execute
hbox:
File "game/inventory.rpy", line 156, in execute
vbox:
File "game/inventory.rpy", line 163, in execute
if not second_inventory:
File "game/inventory.rpy", line 165, in execute
if crafting_screen:
File "game/inventory.rpy", line 166, in execute
use crafting(inventory)
File "game/inventory.rpy", line 166, in <module>
use crafting(inventory)
NameError: name 'inventory' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 101, in script
$ renpy.pause()
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\ast.py", line 806, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\python.py", line 1577, in py_exec_bytecode
exec bytecode in globals, locals
File "game/script.rpy", line 101, in <module>
$ renpy.pause()
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\exports.py", line 1254, in pause
rv = renpy.ui.interact(mouse='pause', type='pause', roll_forward=roll_forward)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\ui.py", line 277, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 2425, in interact
repeat, rv = self.interact_core(preloads=preloads, **kwargs)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 2693, in interact_core
root_widget.visit_all(lambda i : i.per_interact())
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 396, in visit_all
d.visit_all(callback)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 396, in visit_all
d.visit_all(callback)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 396, in visit_all
d.visit_all(callback)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\screen.py", line 386, in visit_all
callback(self)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\core.py", line 2693, in <lambda>
root_widget.visit_all(lambda i : i.per_interact())
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\screen.py", line 396, in per_interact
self.update()
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\display\screen.py", line 565, in update
self.screen.function(**self.scope)
File "game/inventory.rpy", line 147, in execute
screen inventory_screen(first_inventory, second_inventory=False, trade_mode=False, bank_mode=False):
File "game/inventory.rpy", line 147, in execute
screen inventory_screen(first_inventory, second_inventory=False, trade_mode=False, bank_mode=False):
File "game/inventory.rpy", line 151, in execute
frame:
File "game/inventory.rpy", line 153, in execute
vbox:
File "game/inventory.rpy", line 154, in execute
hbox:
File "game/inventory.rpy", line 156, in execute
vbox:
File "game/inventory.rpy", line 163, in execute
if not second_inventory:
File "game/inventory.rpy", line 165, in execute
if crafting_screen:
File "game/inventory.rpy", line 166, in execute
use crafting(inventory)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\ast.py", line 181, in evaluate
args.append(renpy.python.py_eval(v, locals=scope))
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\python.py", line 1606, in py_eval
return py_eval_bytecode(code, globals, locals)
File "C:\Users\NO\Pictures\Games\my game\renpy-6.18.3-sdk\renpy\python.py", line 1601, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "game/inventory.rpy", line 166, in <module>
use crafting(inventory)
NameError: name 'inventory' is not defined
Windows-8-6.2.9200
Ren'Py 6.99.10.1227
Inventory System 1.5
Completed: Elvine (GxB), The Life Threads, Helena's Flowers (GxG)(As Writer, Coder), Dr. Frank's Build-A-Boyfriend (BxB), Beyond the Deep (GxB)(As Artist), The Bog's Heart, The Girl with the Gray Hair Awakens, The Far Rings, NB107A.
All available to play on my itch.io page!
All available to play on my itch.io page!
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Hmmm, looks like someone needs to test their code more thoroughly! Not mentioning any names. *clears throat delicately*
Similar issue, but needed to make a slight screen adjustment as well. I have updated the files in the first post. Thank you for catching that.
Similar issue, but needed to make a slight screen adjustment as well. I have updated the files in the first post. Thank you for catching that.
-
- Regular
- Posts: 32
- Joined: Sat Oct 29, 2011 8:52 pm
- Completed: Re∞Birth [BL]
- Projects: Ferfecir [BL]
- Organization: Milky Cherry
- Location: NZ
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Thank you so much for sharing this!
-
- Newbie
- Posts: 2
- Joined: Mon Nov 21, 2016 10:23 am
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Hi! This works well. But after restart items in the inventory do not save. what to do? ;(
I use ver. 6.99.11.1749
I use ver. 6.99.11.1749
- noeinan
- Eileen-Class Veteran
- Posts: 1153
- Joined: Sun Apr 04, 2010 10:10 pm
- Projects: Ren'Py QuickStart, Crimson Rue
- Organization: Statistically Unlikely Games
- Deviantart: noeinan
- Github: noeinan
- Location: Washington State, USA
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Hey! I've been working more with this code again (thanks so much saguaro, it's awesome!) and I was wondering if anyone ended up making the changes suggested in this post? viewtopic.php?f=51&t=25579&start=15#p326925
Specifically, if anyone managed to divorce the crafting screen from item actions so that you can have an apple that can be eaten to restore health or crafted into a better item. Also, if anyone had success with item classes, so you can have different types of crafting! (Cooking only at a stove, blacksmithing only at a forge, etc.)
I'm trying to do these things, but I am not very familiar with Python so my learning process is very messy and I usually end up with code that is probably not optimized. (Let's try changing this and see what it does! Oh, I broke something, I'm going to undo that, google some things, and try again.) If anyone else already did this successfully and would be okay sharing the code I would greatly appreciate it!
The endgame of what I'm trying to accomplish:
-Anywhere, anytime, the player can craft a set of basic recipes. (Ex. player can tie a rock to a stick if they have a stick, string, and a rock.)
-When player is at a stove, they can create cooking recipes. When player is at the workbench, they can create recipes that require tools.
-It would be nice if the same item could be used in both types of crafting to produce different recipes, but I can make due if that is not possible. (Ex. if you need to set the variable that allows you to cook to an item instead of to a recipe.) I can see a way around this by adding a refinement process that allows a base item to change to a new item class, like you have an apple and if you want to cook with it you first have to craft it using the basic craft menu, which processes it into a "sliced apple" which is now a cooking item, then you can go to the stove and craft the sliced apple.
-Maybe instead of one cookbook, you would have multiple cookbooks that track different types of recipes? So, if you discover a cooking recipe, it shows up in the cook book. If you unlock a simple recipe it shows up in your inventory. Workbench recipes show up in the workbench "tab" of your cookbook. Alternatively, instead of having a screen to view all recipes, it would be that when you're at the stove only cooking recipes show up on the right and when you're away from a crafting station only simple recipes show up, etc.
Specifically, if anyone managed to divorce the crafting screen from item actions so that you can have an apple that can be eaten to restore health or crafted into a better item. Also, if anyone had success with item classes, so you can have different types of crafting! (Cooking only at a stove, blacksmithing only at a forge, etc.)
I'm trying to do these things, but I am not very familiar with Python so my learning process is very messy and I usually end up with code that is probably not optimized. (Let's try changing this and see what it does! Oh, I broke something, I'm going to undo that, google some things, and try again.) If anyone else already did this successfully and would be okay sharing the code I would greatly appreciate it!
The endgame of what I'm trying to accomplish:
-Anywhere, anytime, the player can craft a set of basic recipes. (Ex. player can tie a rock to a stick if they have a stick, string, and a rock.)
-When player is at a stove, they can create cooking recipes. When player is at the workbench, they can create recipes that require tools.
-It would be nice if the same item could be used in both types of crafting to produce different recipes, but I can make due if that is not possible. (Ex. if you need to set the variable that allows you to cook to an item instead of to a recipe.) I can see a way around this by adding a refinement process that allows a base item to change to a new item class, like you have an apple and if you want to cook with it you first have to craft it using the basic craft menu, which processes it into a "sliced apple" which is now a cooking item, then you can go to the stove and craft the sliced apple.
-Maybe instead of one cookbook, you would have multiple cookbooks that track different types of recipes? So, if you discover a cooking recipe, it shows up in the cook book. If you unlock a simple recipe it shows up in your inventory. Workbench recipes show up in the workbench "tab" of your cookbook. Alternatively, instead of having a screen to view all recipes, it would be that when you're at the stove only cooking recipes show up on the right and when you're away from a crafting station only simple recipes show up, etc.
- noeinan
- Eileen-Class Veteran
- Posts: 1153
- Joined: Sun Apr 04, 2010 10:10 pm
- Projects: Ren'Py QuickStart, Crimson Rue
- Organization: Statistically Unlikely Games
- Deviantart: noeinan
- Github: noeinan
- Location: Washington State, USA
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
I've done a lot of modification to this code and thought I'd share what I've done in case it will help anyone else. :3
First, I made a craft screen that is separate from the inventory screen. You click a button, like a forge for example, and then it will open this screen up. This screen also has it's own set of recipes, allowing you to have a different list at the forge compared to the kitchen. First, I went into the script file and made a list of all the recipes I wanted to show up. You *must* define your items before making a manual list or else it won't work.
Then I copied the inventory screen, set default crafting_screen to True, and removed all the if statements regarding having a second inventory-- including the button that toggles the craft screen on and off. (I just wanted a permanent craft screen.)
I also needed to add a custom crafting screen for the kitchen. I replace "cookbook" with my manual recipe list.
Another thing I did was make it so the inventory_popup which appears when you craft an item shows a picture as well as text. I just thought this added a nice touch. You just duplicate inventory_popup, give it a new name, and make these changes:
Should be noted that this code uses the item's name, which appears in text, instead of its variable name, so you'll have to name your files accordingly. You also need to change the crafting def under the Inventory class so that it will use this new screen instead of the old one.
Still working on a few more features-- like the ability to have items be both craftable and useable, and also I'm going to try to make recipes that produce more than one item. (We'll see how that goes because it seems hard. But I want to make it so I can, for example, have a recipe that takes a bottle of oil and a bottle of wine, then produces a the end product + an empty bottle.)
First, I made a craft screen that is separate from the inventory screen. You click a button, like a forge for example, and then it will open this screen up. This screen also has it's own set of recipes, allowing you to have a different list at the forge compared to the kitchen. First, I went into the script file and made a list of all the recipes I wanted to show up. You *must* define your items before making a manual list or else it won't work.
Code: Select all
$ cookbook = list()
call define_items
call define_inventories
$ cooklist = [sandwich,apple_pie,potato_soup,tea,chocolate_milk,grilled_cheese,cookies]
Code: Select all
screen inventory_kitchen(first_inventory, second_inventory=False, trade_mode=False, bank_mode=False):
default crafting_screen = True
tag menu
modal True
frame:
style_group "invstyle"
hbox:
spacing 25
vbox:
label first_inventory.name
use money(first_inventory, second_inventory, bank_mode)
use inventory_view(first_inventory, second_inventory, trade_mode)
use view_nav(first_inventory)
use sort_nav(first_inventory)
textbutton "Close" action Hide("inventory_kitchen")
use crafting_kitchen(first_inventory)
Code: Select all
screen crafting_kitchen(inventory):
vbox:
label "Recipes"
hbox:
xmaximum 600 xminimum 600 xfill True
text "Name" xalign 0.5
text "Ingredients" xalign 0.5
side "c r":
area (0,0,600,400)
viewport id "cooklist":
draggable True
mousewheel True
vbox:
for item in cooklist:
hbox:
first_spacing 25 spacing 10
hbox:
xmaximum 250 xminimum 250 xfill True box_wrap True
if item.icon:
add im.FactorScale(item.icon, 0.33)
if inventory.check_recipe(item):
textbutton item.name action Function(inventory.craft,item)
else:
text item.name
for i in item.recipe:
if i[0].icon:
add im.FactorScale(i[0].icon, 0.33)
else:
text i[0].name
if inventory.qty(i[0]) >= i[1]:
text "x" + str(i[1]) bold True
else:
text "x" + str(i[1])
vbar value YScrollValue("cooklist")
Code: Select all
screen inventory_popup2(message,item):
zorder 100
imagebutton idle "gui/"+item+"_notification.png" xalign 0.5 yalign 0.35
frame:
style_group "msgstyle"
vbox:
text message
timer 0.8 action Hide("inventory_popup2")
Code: Select all
def craft(self, item):
for line in item.recipe:
self.drop(line[0], line[1])
self.take(item)
message = "Crafted %s!" % (item.name)
renpy.show_screen("inventory_popup2", message=message,item=item.name)
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
This my first post, and iam kind of noob with coding, and i have couple of question.
instead of crafting iam using it as cooking
so, add a variable in class Item
the code is like this
iam tried to make a cafe gameplay example
so, iam change the items acts to jump to label test if we clicked the icon and then iam put this code in label test
but i got an error, said: name 'item' isn't defined, then what the right code of it ?
instead of crafting iam using it as cooking
so, add a variable in class Item
the code is like this
Code: Select all
class Item(store.object):
def __init__(self, name, desc, icon=False, value=0, dishOrg=0, act=Show("inventory_popup", message="Nothing happened!"), type="item", recipe=False):
global cookbook
self.name = name
self.desc = desc
self.icon = icon
self.value = value
self.dishOrg = dishOrg
self.act = act # screen action
self.type = type # type of item
self.recipe = recipe # nested list of [ingredient, qty]
if recipe:
cookbook.append(self)
cookbook.sort(key=lambda i: i.name) #alpha order
so, iam change the items acts to jump to label test if we clicked the icon and then iam put this code in label test
Code: Select all
label test:
if item[0].dishOrg > 50:
$costumerhappy = + 6
call Satisfied_costumer from Satisfied_costumer
- noeinan
- Eileen-Class Veteran
- Posts: 1153
- Joined: Sun Apr 04, 2010 10:10 pm
- Projects: Ren'Py QuickStart, Crimson Rue
- Organization: Statistically Unlikely Games
- Deviantart: noeinan
- Github: noeinan
- Location: Washington State, USA
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
I am not an expert by any means, but here is my best guess:Yadi wrote: iam tried to make a cafe gameplay example
so, iam change the items acts to jump to label test if we clicked the icon and then iam put this code in label testbut i got an error, said: name 'item' isn't defined, then what the right code of it ?Code: Select all
label test: if item[0].dishOrg > 50: $costumerhappy = + 6 call Satisfied_costumer from Satisfied_costumer
Everywhere else in the code that uses item directly is a function, inside a python block. Variables inside of functions aren't defined outside of that function. It seems to me that you will need to make a function that takes in information about the item and then calls "Satisfied_customer" if the conditions are met.
- sataneku
- Newbie
- Posts: 4
- Joined: Tue Jan 24, 2017 6:51 am
- Tumblr: kirnura
- Deviantart: coolcat790
- Skype: sataneku
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Is there a way that I can change the background of the inventory, but not the bar in top left corner? I know it uses frame.png, I just want the inventory to use a different background and the top left bar to use frame.png
- noeinan
- Eileen-Class Veteran
- Posts: 1153
- Joined: Sun Apr 04, 2010 10:10 pm
- Projects: Ren'Py QuickStart, Crimson Rue
- Organization: Statistically Unlikely Games
- Deviantart: noeinan
- Github: noeinan
- Location: Washington State, USA
- Contact:
Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Hey, so I did another thing with this awesome code and wanted to share in case it would be useful to anyone else. :3 I wanted to make it so that when you craft items, any extra containers are added to your inventory. For example, if I have water (in a bottle), oil (in a bottle), and beeswax (in a tin), and you combine all those things into *one* bottle, you get the final product (in a bottle) PLUS the unused bottle and unused tin.
First, I added a new variable, "containers" to the Item class, right after recipes:
Then I added the containers, similar to how the recipe lists work. The containers list only has the *extra* containers in it, so you don't add the container that the final product uses.
And for any recipes that don't have extra containers, you need to add an empty container list or else you get errors:
Lastly, I modified the craft function so that after it removes the ingredients from your inventory, it adds the extra bottles:
Hope this helps other folks who wanted a similar feature!
First, I added a new variable, "containers" to the Item class, right after recipes:
Code: Select all
init python:
import renpy.store as store
class Item(store.object):
def __init__(self, name, desc, icon=False, value=0, act=Show("inventory_popup", message="Nothing happened!"), type="item", recipe=False, containers=False):
global cookbook
self.name = name
self.desc = desc
self.icon = icon
self.value = value
self.act = act # screen action
self.type = type # type of item
self.recipe = recipe # nested list of [ingredient, qty]
self.containers = containers
if recipe:
cookbook.append(self)
cookbook.sort(key=lambda i: i.name) #alpha order
def change(self, name, desc=False, icon=False, value=False, act=False, recipe=False, containers=False):
self.name = name
if desc:
self.desc = desc
if icon:
self.icon = icon
if value:
self.value = value
if act:
self.act = act
if recipe:
self.recipe = recipe
if containers:
self.containers = containers
Code: Select all
$ cream001 = Item("Thistle Cream", "Medicine applied to the skin.", "inv/jar.medicine04.png", 2400, recipe=[[empty_jar,1],[water,2],[wax,1],[herb_oil001,1]], containers=[[empty_bottle,3], [empty_tin,1]])
Code: Select all
$ herb_oil001 = Item("Thistle Oil", "Made by soaking herbs in oil.", "inv/bottle.extract.png", 800, recipe=[[oil,1],[herb001,1]], containers=[])
Code: Select all
def craft(self, item):
for line in item.recipe:
self.drop(line[0], line[1])
for line in item.containers:
self.take(line[0], line[1])
self.take(item)
message = "Crafted %s!" % (item.name)
renpy.show_screen("inventory_popup2", message=message,item=item.name)
Who is online
Users browsing this forum: No registered users