I'm seeking advice on how best to handle variable checks against a well "Variable Variable".
I've Multiple Characters with their own stats, skills and inventory.
Going into an Encounter you choose which character you want to use. I handle this with a POV = Name variable.
Each Encounters, checks either skill, inventory item or stats to dictate the outcome. Pretty standard.
The issue is how best to handle the checks to apply across all the characters.
For Example at the moment I'm using a set up kinda like this. Lets say "Ashley" is using a "Key"
If POV == Ashley and Ashley_ItemKey == True
Win
elif POV == Ashley and Ashely_ItemKey == False
Fail
elif POV == Mark and Mark_ItemKey == True
Win
elif POV == Mark and Mark_ItemKey == False
Fail
At the moment I have duplicate Item tags with every characters name. Since each inventory is separate.
ItemKey_character1
ItemKey_character2 ect ect.
That seems cumbersome. Surely there is an easier way to track that.
also the above If statement seems cumbersome as well.
Lets say an Encounter against a Monster allows for 3 options
Use a Gun (Available if you have Gun), Run (Check Against Agility), Hide (Check Against Stealth)
Using the IF statements set up like I have it gets pretty complicated but works. I just feel it can be streamlined. Any advice would be greatly appreciated.
Tips for efficient Variable checks across different characters.
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.
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.
Re: Tips for efficient Variable checks across different characters.
You should look into classes. Creating a class for your characters will help you a lot.
Sorry I don't have time to point out manuals or explain in detail here but you'll cretae class such as:
init python:
class CharacterClass(object):
def __init__(self, name, itemkey, *args, **kwargs):
self.name = name
self.itemkey = itemkey
Then you'd declare your default characters:
default Ashley = CharacterClass("Ashley",True)
default Mark = CharacterClass("Mark",False)
And later in the game when you have POV = Ashley (or whatever) you can simply use:
if POV.itemkey:
win
else:
fail
This is a very short explanation and you really should learn about classes as there's a whole bunch more you can do with it.
Sorry I don't have time to point out manuals or explain in detail here but you'll cretae class such as:
init python:
class CharacterClass(object):
def __init__(self, name, itemkey, *args, **kwargs):
self.name = name
self.itemkey = itemkey
Then you'd declare your default characters:
default Ashley = CharacterClass("Ashley",True)
default Mark = CharacterClass("Mark",False)
And later in the game when you have POV = Ashley (or whatever) you can simply use:
if POV.itemkey:
win
else:
fail
This is a very short explanation and you really should learn about classes as there's a whole bunch more you can do with it.
Re: Tips for efficient Variable checks across different characters.
Awesome
That will definitely be the next thing I research. Thank you 
Who is online
Users browsing this forum: Google [Bot], TioNick