[SOLVED] Inventory v 1.5 Crafting Issues

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
thexerox123
Regular
Posts: 131
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

[SOLVED] Inventory v 1.5 Crafting Issues

#1 Post by thexerox123 »

Well, now that my last issue's solved, right on to the next problem! lol

I'm using saguaro's inventory system code with some modifications, and in trying to make use of the recipes/crafting system for the first time, I've come up against an issue. The crafting panel opens up just fine, until I add recipes to some item definitions.

Here's the traceback:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 807, in script
    $ renpy.pause(hard=True)
  File "game/script.rpy", line 807, in <module>
    $ renpy.pause(hard=True)
  File "game/inventory.rpy", line 152, in execute
    screen inventory_screen(first_inventory, second_inventory=False, trade_mode=False, bank_mode=False):
  File "game/inventory.rpy", line 152, in execute
    screen inventory_screen(first_inventory, second_inventory=False, trade_mode=False, bank_mode=False):
  File "game/inventory.rpy", line 164, in execute
    frame:
  File "game/inventory.rpy", line 166, in execute
    hbox:
  File "game/inventory.rpy", line 182, in execute
    if crafting_screen:
  File "game/inventory.rpy", line 183, in execute
    use crafting(first_inventory)
  File "game/inventory.rpy", line 258, in execute
    screen crafting(inventory):
  File "game/inventory.rpy", line 258, in execute
    screen crafting(inventory):
  File "game/inventory.rpy", line 259, in execute
    vbox:
  File "game/inventory.rpy", line 265, in execute
    side "c r":
  File "game/inventory.rpy", line 267, in execute
    viewport id "cookbook":
  File "game/inventory.rpy", line 270, in execute
    vbox:
  File "game/inventory.rpy", line 271, in execute
    for item in cookbook:
  File "game/inventory.rpy", line 272, in execute
    hbox:
  File "game/inventory.rpy", line 274, in execute
    hbox:
  File "game/inventory.rpy", line 278, in execute
    if inventory.check_recipe(item):
  File "game/inventory.rpy", line 278, in <module>
    if inventory.check_recipe(item):
  File "game/inventory.rpy", line 66, in check_recipe
    if self.qty(i[0]) >= i[1]:
TypeError: '>=' not supported between instances of 'NoneType' and 'int'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 807, in script
    $ renpy.pause(hard=True)
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\ast.py", line 1138, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\python.py", line 1122, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "game/script.rpy", line 807, in <module>
    $ renpy.pause(hard=True)
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\exports.py", line 1633, in pause
    rv = renpy.ui.interact(mouse='pause', type='pause', roll_forward=roll_forward, pause=delay, pause_modal=modal)
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\ui.py", line 299, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\display\core.py", line 3471, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, pause_modal=pause_modal, **kwargs) # type: ignore
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\display\core.py", line 3922, in interact_core
    root_widget.visit_all(lambda d : d.per_interact())
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\display\core.py", line 605, in visit_all
    d.visit_all(callback, seen)
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\display\core.py", line 605, in visit_all
    d.visit_all(callback, seen)
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\display\core.py", line 605, in visit_all
    d.visit_all(callback, seen)
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\display\screen.py", line 476, in visit_all
    callback(self)
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\display\core.py", line 3922, in <lambda>
    root_widget.visit_all(lambda d : d.per_interact())
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\display\screen.py", line 487, in per_interact
    self.update()
  File "C:\Users\thexe\Downloads\renpy-8.0.3-sdk\renpy\display\screen.py", line 680, in update
    self.screen.function(**self.scope)
  File "game/inventory.rpy", line 152, in execute
    screen inventory_screen(first_inventory, second_inventory=False, trade_mode=False, bank_mode=False):
  File "game/inventory.rpy", line 152, in execute
    screen inventory_screen(first_inventory, second_inventory=False, trade_mode=False, bank_mode=False):
  File "game/inventory.rpy", line 164, in execute
    frame:
  File "game/inventory.rpy", line 166, in execute
    hbox:
  File "game/inventory.rpy", line 182, in execute
    if crafting_screen:
  File "game/inventory.rpy", line 183, in execute
    use crafting(first_inventory)
  File "game/inventory.rpy", line 258, in execute
    screen crafting(inventory):
  File "game/inventory.rpy", line 258, in execute
    screen crafting(inventory):
  File "game/inventory.rpy", line 259, in execute
    vbox:
  File "game/inventory.rpy", line 265, in execute
    side "c r":
  File "game/inventory.rpy", line 267, in execute
    viewport id "cookbook":
  File "game/inventory.rpy", line 270, in execute
    vbox:
  File "game/inventory.rpy", line 271, in execute
    for item in cookbook:
  File "game/inventory.rpy", line 272, in execute
    hbox:
  File "game/inventory.rpy", line 274, in execute
    hbox:
  File "game/inventory.rpy", line 278, in execute
    if inventory.check_recipe(item):
  File "game/inventory.rpy", line 278, in <module>
    if inventory.check_recipe(item):
  File "game/inventory.rpy", line 66, in check_recipe
    if self.qty(i[0]) >= i[1]:
TypeError: '>=' not supported between instances of 'NoneType' and 'int'

Windows-10-10.0.22621 AMD64
Ren'Py 8.1.0.23031701+nightly
Escape the North 0.1
Sat Mar 18 17:17:02 2023

My altered code for inventory.rpy:

Code: Select all

##Ren'Py Inventory System v. 1.5 provided under public domain by saguaro

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):
            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]   
            
            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): 
            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   

        def __eq__(self, other):
            return self.name == other.name             
            
    class Inventory(store.object):
        def __init__(self, name, money=0, barter=100):
            self.name = name
            self.money = money
            self.barter = barter #percentage of value paid for items            
            self.inv = []  # items stored in nested list [item object, qty]
            self.sort_by = self.sort_name
            self.sort_order = True #ascending, descending
            self.grid_view = True
            
        def buy(self, item, price):            
            self.deposit(price)            
            self.take(item[0])                

        def check(self, item):
            if self.qty(item):
                for i in self.inv:
                    if i[0] == item:        
                        return self.inv.index(i) # returns item index (location)     
                               
        def qty(self, item):
            for i in self.inv:
                if i[0] == item:   
                    return i[1] # returns quantity 

        def check_recipe(self, item): # verify all ingredients are in inv
            checklist = list()
            for i in item.recipe:
                if self.qty(i[0]) >= i[1]:
                    checklist.append(True)
            if len(checklist) == len(item.recipe):
                return True
            else:
                return False        
                
        def craft(self, item):
            for line in item.recipe:
                self.drop(line[0], line[1])
            self.take(item)  
            message = "Crafted a %s!" % (item.name)
            renpy.show_screen("inventory_popup", message=message)   
                            
        def deposit(self, amount):
            self.money -= amount   
                            
        def drop(self, item, qty=1):
            if self.qty(item):
                item_location = self.check(item)
                if self.inv[item_location][1] > qty:
                    self.inv[item_location][1] -= qty
                else:
                    del self.inv[item_location]                      
                              
                    
        def sell(self, item, price):
            self.withdraw(price)
            self.drop(item[0])
            
        def sort_name(self):
            self.inv.sort(key=lambda i: i[0].name, reverse=self.sort_order)
            
        def sort_qty(self):
            self.inv.sort(key=lambda i: i[1], reverse=self.sort_order)
                      
        def sort_value(self):
            self.inv.sort(key=lambda i: i[0].value, reverse=self.sort_order)
           
        def take(self, item, qty=1):
            if self.qty(item):
                item_location = self.check(item)            
                self.inv[item_location][1] += qty                  
            else:
                self.inv.append([item,qty])  

        def withdraw(self, amount):
            self.money += amount
            
    def calculate_price(item, buyer):
        if buyer:
            price = item[0].value * (buyer.barter * 0.01)
            return int(price)
        
    def money_transfer(depositor, withdrawer, amount):
        if depositor.money >= amount:
            depositor.deposit(amount)
            withdrawer.withdraw(amount) 
        else:
            message = "Sorry, %s doesn't have %d!" % (buyer.name, amount) 
            renpy.show_screen("inventory_popup", message=message) 

    def trade(seller, buyer, item):
        seller.drop(item[0])
        buyer.take(item[0])              
        
    def transaction(seller, buyer, item):
        price = calculate_price(item, buyer)
        if buyer.money >= price:   
            seller.sell(item, price)
            buyer.buy(item, price)
        else:
            message = "Sorry, %s doesn't have enough money!" % (buyer.name)
            renpy.show_screen("inventory_popup", message=message)

    transfer_amount = 0
                
screen tooltip(item=False,seller=false):      
    if item:
        hbox:
            xalign 0.5 yalign 1.0
            if seller:
                text ("[item[0].name]: [item[0].desc] (Sell Value: " + str(calculate_price(item, seller)) + ")")
            else:
                text "[item[0].name]: [item[0].desc] (Value: [item[0].value])" 

screen inventory_screen(first_inventory, second_inventory=False, trade_mode=False, bank_mode=False):
    default crafting_screen = False
    tag menu
    zorder 2000
    modal True      
    vbox:
        imagebutton:
            idle "images/GreenBagSel.png"
            hover "images/GreenBag.png"
            xpos 50
            ypos 50
            action Hide("inventory_screen")  
    frame:
        style_group "invstyle"          
        hbox:
            spacing 25
            vbox:
                label first_inventory.name
                textbutton "Inventory" action Show("inventory_screen", first_inventory=foster_inv)                   
                if second_inventory:
                    use money(first_inventory, second_inventory, bank_mode) 
                use inventory_view(first_inventory, second_inventory, trade_mode)                          
                if not second_inventory:
                    textbutton "Crafting Mode" action ToggleScreenVariable("crafting_screen")
                textbutton "Close" action Hide("inventory_screen")
            if second_inventory:
                vbox:
                    label second_inventory.name  
                    use money(second_inventory, first_inventory, bank_mode)                       
                    use inventory_view(second_inventory, first_inventory, trade_mode)
            if crafting_screen:
                use crafting(first_inventory)
                
screen inventory_view(inventory, second_inventory=False, trade_mode=False, single_inventory=True):     
    side "c r":
        style_group "invstyle"
        area (0, 0, 1400, 700) 
        vpgrid id ("vp"+inventory.name):
            draggable True   
            mousewheel True
            allow_underfull True
            xsize 1400 ysize 700
            if inventory.grid_view:
                cols 3 spacing 50
            else:
                cols 3 spacing 50
            for item in inventory.inv:
                $ name = item[0].name
                $ desc = item[0].desc
                $ value = item[0].value
                $ qty = str(item[1])
                hbox:
                    if item[0].icon:
                        $ icon = item[0].icon
                        $ hover_icon = im.Sepia(icon)                              
                        imagebutton:
                            idle LiveComposite((370,320), (0,0), icon, (0,0), Text(qty))
                            hover LiveComposite((370,320), (0,0), hover_icon, (0,0), Text(qty))
                            action (If(not second_inventory, item[0].act, (If(trade_mode, Function(trade,inventory, second_inventory, item), Function(transaction,inventory, second_inventory, item)))))
                        if not inventory.grid_view:
                            vbox:
                                text name
                                if not trade_mode:
                                    text "List Value: [value]"                                        
                                    if second_inventory:                                            
                                        text ("Sell Value: " + str(calculate_price(item, second_inventory)) + ")")
                    
                    else:                               
                        textbutton "[name] ([qty])" action (If(not second_inventory, item[0].act,(If(trade_mode, Function(trade,inventory, second_inventory, item), Function(transaction,inventory, second_inventory, item))))) hovered Show("tooltip",item=item,seller=second_inventory) unhovered Hide("tooltip")
                        if not inventory.grid_view:
                            vbox:                        
                                text "List Value: [value]"
                                if not trade_mode and second_inventory:
                                    text "Sell Value: " + str(calculate_price(item, second_inventory)) + ")"
            
            ## maintains spacing in empty inventories.
            if len(inventory.inv) == 0:
                add Null(height=100,width=100)
                                    
        vbar value YScrollValue("vp"+inventory.name)

    
screen money(inventory, second_inventory, bank_mode=False):    
    hbox:
        style_group "invstyle"
        text "Money: [inventory.money]"
        if bank_mode and inventory.money:
            textbutton "Transfer" action Show("banking", depositor=inventory, withdrawer=second_inventory)
    
screen banking(depositor, withdrawer):    
    modal True
    frame:
        style_group "invstyle"        
        vbox:
            label "Money Transfer"
            text "Amount: [transfer_amount]"
            bar value VariableValue("transfer_amount", depositor.money, max_is_zero=False, style='scrollbar', offset=0, step=0.1) xmaximum 200
            
            hbox: #examples of the types of controls you can set up                
                for amount in [50,100,250,depositor.money]:
                    if depositor.money>=amount:
                        textbutton str(amount) action SetVariable("transfer_amount", amount)              
            hbox:
                textbutton "Transfer" action [Function(money_transfer, depositor, withdrawer, transfer_amount), SetVariable("transfer_amount", 0), Hide("banking")]
                textbutton "Cancel" action Hide("banking")

screen crafting(inventory):
    vbox:            
        label "Recipes"
        hbox:
            xmaximum 400 xminimum 400 xfill True         
            text "Name" xalign 0.5   
            text "Ingredients" xalign 0.5   
        side "c r":
            area (0,0,400,400)
            viewport id "cookbook":           
                draggable True
                mousewheel True
                vbox:
                    for item in cookbook:
                        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("cookbook") 
        textbutton "Hide" action ToggleScreenVariable("crafting_screen") xalign 0.5            

screen inventory_popup(message):
    zorder 5000
    frame:
        style_group "invstyle"
        hbox:
            text message
    timer 1.5 action Hide("inventory_popup")
    
init -2: 

    ## STYLES ##
    style invstyle_frame:
        xalign 0.5
        yalign 0.5
        
    style invstyle_label_text:
        size 30
        
    style invstyle_label:
        xalign 0.5    
    
screen green_inventory_button:
    zorder 1
    vbox:
        imagebutton:
            idle "images/GreenBag.png"
            hover "images/GreenBagSel.png"
            xpos 50
            ypos 50
            action [Jump("Inventory")]

Script.rpy:

Code: Select all

    define cookbook = list() 

    default foster_inv = Inventory("Green", 0, 100)
    default lily_inv = Inventory("Red", 0, 100)
    define tinywings = Item(name="Tiny Wings", desc="A pair of tiny, beautiful, enchanted wings.", icon="images/items/Tiny Wings.png", act=Show("inventory_popup", message="A pair of tiny, beautiful, enchanted wings."))
    define doll = Item(name="Doll", desc="A doll.", icon="images/items/Doll.png", act=Show("inventory_popup", message="A doll."))
    define plumdoll = Item(name="Sugar Plum Doll", desc="A Sugar Plum Fairy Doll, straight out of The Nutcracker.", icon="images/items/Sugar Plum Doll.png", act=Show("inventory_popup", message="A Sugar Plum Fairy Doll, straight out of The Nutcracker."), recipe=[[doll,1],[tinywings,1]])
      

Also, if I can get this working, what would be the easiest way to make an action that then disassembles the crafted items and gives the component parts back?

Would I basically just invert the method of:

Code: Select all

        def craft(self, item):
            for line in item.recipe:
                self.drop(line[0], line[1])
            self.take(item)  
            message = "Crafted a %s!" % (item.name)
            renpy.show_screen("inventory_popup", message=message)
Last edited by thexerox123 on Sun Mar 19, 2023 11:02 am, edited 1 time in total.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Inventory v 1.5 Crafting Issues

#2 Post by _ticlock_ »

thexerox123 wrote: Sat Mar 18, 2023 9:38 pm I'm using saguaro's inventory system code with some modifications, and in trying to make use of the recipes/crafting system for the first time, I've come up against an issue. The crafting panel opens up just fine, until I add recipes to some item definitions.
I haven't used this inventory before, so I could be wrong. I took a quick look at the traceback and method self.qty. It seems to me that this method is supposed to `return 0` if you don't have an item in the inventory:

Code: Select all

def qty(self, item):
            for i in self.inv:
                if i[0] == item:   
                    return i[1] # returns quantity 
            return 0 # returns zero if no item in the inventory
thexerox123 wrote: Sat Mar 18, 2023 9:38 pm Also, if I can get this working, what would be the easiest way to make an action that then disassembles the crafted items and gives the component parts back?
Something like that. Drop the item, and take the ingredients. (Again, I could be wrong)

thexerox123
Regular
Posts: 131
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Inventory v 1.5 Crafting Issues

#3 Post by thexerox123 »

_ticlock_ wrote: Sat Mar 18, 2023 11:51 pm I haven't used this inventory before, so I could be wrong. I took a quick look at the traceback and method self.qty. It seems to me that this method is supposed to `return 0` if you don't have an item in the inventory:

Code: Select all

def qty(self, item):
            for i in self.inv:
                if i[0] == item:   
                    return i[1] # returns quantity 
            return 0 # returns zero if no item in the inventory
Hmm. I'm getting the same traceback error whether I have an item in my inventory or not. :\ And previously had no issues opening the crafting screen one way or another, before I added definitions for items with recipes (which makes sense, as the error is in the check for recipes... but I still don't know how to fix it.)

I already got some advice on another issue that I'd had with a qty check with this code, and ended up adding an __eq__ method to refer to name instead.

I tried one other change suggested in that thread since running into this issue:

Code: Select all

if i[0] == item:   
# change to
if i[0].name == item.name:
But no luck.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Inventory v 1.5 Crafting Issues

#4 Post by _ticlock_ »

thexerox123 wrote: Sun Mar 19, 2023 12:00 am Hmm. I'm getting the same traceback error whether I have an item in my inventory or not. :\ And previously had no issues opening the crafting screen one way or another, before I added definitions for items with recipes (which makes sense, as the error is in the check for recipes... but I still don't know how to fix it.)
The traceback says
if self.qty(i[0]) >= i[1]:
TypeError: '>=' not supported between instances of 'NoneType' and 'int'

Code: Select all

for i in item.recipe:
                if self.qty(i[0]) >= i[1]:
If the recipe is correct (recipe = [[doll,1],[tinywings,1])
i[0] == doll
i[1] == 1
it seems self.qty(doll) return None


Add print lines to method `check_recipe` to see where the problem comes from:

Code: Select all

            print("item.recipe = {}".format(item.recipe))
            for i in item.recipe:
                print("self.qty(i[0]) = {}".format(self.qty(i[0])))
                if self.qty(i[0]) >= i[1]:
After error, click `Console`. What is printed before the traceback?

thexerox123
Regular
Posts: 131
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Inventory v 1.5 Crafting Issues

#5 Post by thexerox123 »

_ticlock_ wrote: Sun Mar 19, 2023 12:16 am After error, click `Console`. What is printed before the traceback?
Image


Do I maybe also need an __eq__ method for qty to direct it properly?

thexerox123
Regular
Posts: 131
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Inventory v 1.5 Crafting Issues

#6 Post by thexerox123 »

I also tried an alternate version of check_recipe from the thread:

Code: Select all

        
        def check_recipe(self, item): # verify all ingredients are in inv
            for i in item.recipe:
                if self.qty(i[0]) < i[1]:
                    return False
            return True
But it didn't help... but I guess it wouldn't if (i[0]) is returning None regardless.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Inventory v 1.5 Crafting Issues

#7 Post by _ticlock_ »

thexerox123 wrote: Sun Mar 19, 2023 12:33 am Do I maybe also need an __eq__ method for qty to direct it properly?
Possibly, but only if you have items that are equal but actually two different instances of items. Based on how your piece of code, I don’t think it is the case.

If you look at the print line, the recipe is correct, but qty method return None.

Looking at the qty method:

Code: Select all


def qty(self, item):
            for i in self.inv:
                if i[0] == item:   
                    return i[1] # returns quantity 
The only way it return None if the ‘for’ loop ended. By default every function returns None. That’s why I suggest to add return 0 if that happens.

Code: Select all

        def qty(self, item):
            for i in self.inv:
                if i[0] == item:   
                    return i[1] # returns quantity 
            return 0 # returns zero if no item in the inventory
If it works but the method qty returns 0 even if you have all items in the inventory, maybe you need to take care of __eq__ method for class Item. But I’d suggest to to add print line to qty method to check that it is the case:

Code: Select all

        def qty(self, item):
            for i in self.inv:
                print("qty method : i[0] = {}, item = {} ".format(i[0], item))
                if i[0] == item:   
                    return i[1] # returns quantity 
            return 0 # returns zero if no item in the inventory

thexerox123
Regular
Posts: 131
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Inventory v 1.5 Crafting Issues

#8 Post by thexerox123 »

_ticlock_ wrote: Sun Mar 19, 2023 10:46 am The only way it return None if the ‘for’ loop ended. By default every function returns None. That’s why I suggest to add return 0 if that happens.
Ahhhh sorry, I'd missed that you'd added that line; thank you for reiterating!

That indeed did fix the problem! :D

Thank you once again so much, _ticlock_, I appreciate your patience and the generosity of your advice and time! :)

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Inventory v 1.5 Crafting Issues

#9 Post by _ticlock_ »

thexerox123 wrote: Sun Mar 19, 2023 11:02 am That indeed did fix the problem! :D

Thank you once again so much, _ticlock_, I appreciate your patience and the generosity of your advice and time! :)
Glad, it worked. Don’t forget to remove print lines to avoid unnecessary printing in the console.

Also you can post this change to the inventory system post you referred to help others avoid this problem.

thexerox123
Regular
Posts: 131
Joined: Fri Jan 20, 2023 3:21 pm
itch: thexerox123
Contact:

Re: Inventory v 1.5 Crafting Issues

#10 Post by thexerox123 »

_ticlock_ wrote: Sun Mar 19, 2023 12:15 pm Glad, it worked. Don’t forget to remove print lines to avoid unnecessary printing in the console.

Also you can post this change to the inventory system post you referred to help others avoid this problem.
Oh, yes, thank you for the reminder.

And yeah, will do! This forum is such a useful resource. :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]