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.
Everything seems to be in place when I replace the "item" in the function with "melee_blunt1" but in order to make it work for all items I would need to specify the item that is going to be equipped in its own definition somehow. I cannot leave it like this because it gives me: NameError: name 'melee_blunt1' is not defined
Is it possible to somehow specify the item in its own definition, or will I have to make an equip function for every item seperately?
Last edited by Stapper on Sat May 17, 2014 6:54 pm, edited 1 time in total.
So is this Item class also yours, or what? Because what I see as being a problem is that act=equip(blah) doesn't do what you think it does. Specifically, this will call the function equip with melee_blunt1 at the time the code declaring the item is run. So even if this code worked, it seems that it would just try to equip the item then, and because the equip function doesn't return anything, it would pass act=None to the Item declaration. Not what you want at all. But I'd need more information about this Item class to determine what you actually do want.
Sorry for the confusion, I will try and explain it better...
I'm using the inventory system from saguaro as a base: http://lemmasoft.renai.us/forums/viewto ... 51&t=25579
He used the 'act' to call the crafting screen when you click an item in the inventory, it only triggers then. But I substituted this in order to equip items instead. Here is the item class (I removed the standard 'act' to show the message nothing happens:
class Item(store.object):
def __init__(self, name, desc, icon=False, value=0, act=Hide("Null"), recipe=False):
global cookbook
self.name = name
self.desc = desc
self.icon = icon
self.value = value
self.act = act # action executed from the single inventory screen
self.recipe = recipe # nested list of [ingredient, qty]
So all I try to do is that when a weapon with 'act=equip' is clicked in the inventory, the item is set as the variable 'equip_melee'. From there I can check in battles which weapon they have equipped.
I hope this makes more sense this way... my apologies if it doesn't but I'm not sure what else I can tell about it
Notice how the code in inventory.rpy curries all the things that get called with arguments? You need to do that too if you want to pass arguments to functions that are being provided as actions. The eval is simply so that the code is run after melee_blunt1 exists- not sure if there's a better way to do that.