Python Variable issue. I'm hoping this has a simple solution.

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
nhguy03276
Regular
Posts: 40
Joined: Thu Jan 29, 2015 12:48 pm
Contact:

Python Variable issue. I'm hoping this has a simple solution.

#1 Post by nhguy03276 » Sun Mar 18, 2018 3:02 pm

So I've run into a bit of a snag in my inventory system I am working on. I'm trying to make equippable items panel, and so far it has been working as intended... except when trying to replace the already equipped item...

To add a item to inventory I'm using the call:

Inventory.Add(LeatherArmor)

To drop it:

Inventory.Drop(LeatherArmor)

To Equip the item I'm using:

Code: Select all

               if EquippedArmor == "":
                   equiparmor.add(self)
                   inventory.drop(self)
                   EquippedArmor = self.itemname
               else:
                   
                   inventory.add (EquippedArmor)
                   equiparmor.drop (EquippedArmor)
                   EquippedArmor = self.itemname
                   equiparmor.add(self)
                   inventory.drop(self)
 
But this doesn't work, at least on the re-equip, as inventory.add is looking at "EquippedArmor" as a string instead of Variable. Is there a way to tell the code it is a Variable and not a String? Or am I going to have to go a different route?

nhguy03276
Regular
Posts: 40
Joined: Thu Jan 29, 2015 12:48 pm
Contact:

Re: Python Variable issue. I'm hoping this has a simple solution.

#2 Post by nhguy03276 » Sun Mar 18, 2018 8:51 pm

Ok, Found the solution... at least for this issue....

inventory.add (equiparmor.items[0])

Took me far longer to figure out than it should have... But it works now.

Post Reply

Who is online

Users browsing this forum: No registered users