Re: Infinite, Stackable Inventory/Crafting/Vendor - UPDATED
Posted: Tue May 17, 2016 7:59 am
Updated for Ren'py 6.99.10, see first post.
Supporting creators of visual novels and story-based games since 2003.
https://lemmasoft.renai.us/forums/
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
Code: Select all
textbutton "Inventory" action Show("inventory_screen", first_inventory=jane_inv)
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
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)
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
Code: Select all
label test:
if item[0].dishOrg > 50:
$costumerhappy = + 6
call Satisfied_costumer from Satisfied_costumer
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
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)