Hey guys,

So me and my friend are starting up a simple Text-Based-Post-Apocalyptic-Role-Playing-Game.
Both of us have had 2 or so months of experience, we are no experts.
So, I will appreciate any tips.
I have been lurking these forums for a little while now, and decieded this is the best place for answers.
I will split my question into 2 parts.

Part 1:
An example of our statclass:

Scavenger={'st':3, 'dex':5, 'luck':12, 'intel':1}
item_wornboots=['Worn Boots', statclass['luck'] + 0.5]

print statclass

Is there a way of permanently changing the value of 'luck' when the boots would be applied?
So that the luck becomes 12.5?

Part 2:
We want to be able to let the user be able to type 'i' at anytime to print their inventory which would be kept in a separate .txt file.
Is there a function that could be placed at the beginning of the main script to allow them to do so without having to have an 'if' statement EVERYWHERE?


#The somethingrather up here.
tq=raw_input ("Welcome to Town Square. ")
    if tq==('n'):
        """Movement to new scene"""
    elif tq==('e'):
        """Movement to new scene"""
    elif tq==('s'):
        """Movement to new scene"""
    elif tq==('w'):
        """Movement to new scene"""
    #I would like not to put another 'elif' statement here just to check inventory
    #And, so they can check iventory ANYWHERE
6 Years
Discussion Span
Last Post by D3BuG

For Part 2:
I would like to see the rest of your code, so that I know how you are transitioning.

You might make a function and just put that in the code, I've got to go.

Edited by Geemon: n/a


2nd part:
Do something like this

func_dict = {'n':north, 's':south, 'e':east, 'w':west, 'i':inventory}
# This dictionary uses the key letter you want, and the function you want to use
letter = raw_input('Welcome to Town Square.\n').lower() 
# Letter is always lowercase by using '.lower()'
if func_dict.has_key(letter):
    print 'Invalid key'

I am using you are using functions by this, however


uh. I strongly discourage the use of if-elif-else structure for text commands.
I recommend a language parser, I have one written, you can see if that fits you. Link is in my signature. (TAG Engine)


Thanks a bunch, redyugi.
Any suggestions for the stat changes?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.